Coder Social home page Coder Social logo

Comments (5)

ClawhammerLobotomy avatar ClawhammerLobotomy commented on July 29, 2024 1

This appears to be fixable by modifying this piece of the userscript.
I don't know how to apply this to the actual project, and have just manually modified the userscript to test.
I don't know much about coffeescript, and the code in ImageCommon.coffee is not aligning with my installed userscript when I try to compile it, even before changes.

ImageCommon = {
//Other functions
    download: function(e) {
      var download, href, ref;
      if (this.protocol === 'blob:') {
        return true;
      }
      e.preventDefault();
      ref = this, href = ref.href+'?foo', download = ref.download;
      return CrossOrigin.file(href, function(blob) {
        var a;
        if (blob) {
          a = $.el('a', {
            href: URL.createObjectURL(blob),
            download: download,
            hidden: true
          });
          $.add(d.body, a);
          a.click();
          return $.rm(a);
        } else {
          return new Notice('warning', "Could not download " + href, 20);
        }
      });
    }
}

Specifically this line:
ref = this, href = ref.href, download = ref.download;
to:
ref = this, href = ref.href+'?foo', download = ref.download;

Adding ?ANYTHING after the image href when downloading will download the original size.

from 4chan-x.

yomukana avatar yomukana commented on July 29, 2024

@ClawhammerLobotomy Wow thank you very much! Looking at the discussion in your pull request, I tried to make a 'random' version of your userscript-version provided here. However writing something like this:
testnegneg = '?' + Math.random().toString(36).slice(2)
ref = this, href = ref.href + testnegneg, download = ref.download;
breaks the download button's functionality. Do you have any solution to this?
Thanks for your great insight.

from 4chan-x.

ClawhammerLobotomy avatar ClawhammerLobotomy commented on July 29, 2024

@yomukana
Did you check out my pull request?
It should already be updated with the randomized version, and it is working for me with the download button.

Your issue seems to be that you haven't declared testnegneg prior to using it, unless you didn't add it in your example.
The variables are defined at the start of the function for this. I added "search" here.

download: function(e) {
  var download, href, ref, search;
  if (this.protocol === 'blob:') {
    return true;
  }
  e.preventDefault();
  ref = this, href = ref.href, download = ref.download;
  search = Date.now() + Math.random().toString(20).substring(2);
  href = href + '?' + search;

from 4chan-x.

yomukana avatar yomukana commented on July 29, 2024

@ClawhammerLobotomy Thanks! Yes I did read your pull request but it used the & operator which seemed unnecessary to me so I wanted to make my own version, but now everything is solved. Should I close the issue or wait until your new pull is merged?

from 4chan-x.

ClawhammerLobotomy avatar ClawhammerLobotomy commented on July 29, 2024

It should probably remain open in case someone else searches for the issue.
Not sure how often pull requests are reviewed.
This info could at least serve as a workaround for someone who cares enough about the compression to implement themselves.

from 4chan-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.