simonlindholm / toggle-gifs

Toggle animated GIFs (Firefox extension)
https://addons.mozilla.org/en-US/firefox/addon/toggle-animated-gifs/
51 stars 2 forks source link

Port to WebExtensions #43

Open ssokolow opened 7 years ago

ssokolow commented 7 years ago

Mozilla will be dropping support for XUL extensions in Firefox 57, so this needs to be ported to the WebExtensions APIs before then if you want to keep it working. (And I'd really appreciate if that were the case)

If it can't be accomplished using WebExtensions APIs, you need to get onto Bugzilla A.S.A.P. to start a discussion on how to extend the APIs.

simonlindholm commented 7 years ago

... yeah. :( I hope to have time to do this during the summer. It requires pretty much a complete rewrite and getting API's for GIF manipulation into Firefox.

ssokolow commented 7 years ago

According to a discussion I had in #firefox, the shut-off is tied to the version number, so you only have until August 7th if you want to avoid disruption for users on the Aurora/DeveloperEdition channel. (another 6 weeks sooner for nightlies if their deadlines don't slip)

That's why I said A.S.A.P. about getting on Bugzilla. You need to get them designing and writing that API pronto.

EDIT: And please mention the bug here when you do open it, so I can follow the discussion.

simonlindholm commented 7 years ago

Thanks for the information about timing. I wonder when in the Nightly cycle it will land... Still, seems like I should have time in June and July if not before.

My (naive?) hope is that the API is small enough that I can just design and land it myself, without a very long discussion phase. (And FWIW if for whatever reason I don't manage to get APIs accepted into Firefox, I'll make them available as a webextension experiment so I can continue using the extension myself.)

ssokolow commented 7 years ago

Assuming no slipped deadlines, it'll land in Nightly on June 12th.

(I've been doing some serious research into this whole "XUL is going away" thing.)

simonlindholm commented 7 years ago

https://bugzilla.mozilla.org/show_bug.cgi?id=1378939 (and note also https://bugzilla.mozilla.org/show_bug.cgi?id=1364972 )

ssokolow commented 7 years ago

Thanks. I'm now following both of those.

suy commented 6 years ago

Hi. I see that https://bugzilla.mozilla.org/show_bug.cgi?id=1364972 is resolved, and some new API is added for FF 57. This doesn't seem as complete as fully controlling everything, but, can a pause/play button be implemented with that?

simonlindholm commented 6 years ago

Kind of - I suspect changing the setting only affects future page loads though. I'm currently experimenting with whether it's possible to exploit Firefox bugs/quirks to get the behavior I want. (In particular, image animation state is shared between images with the same source even across frames, and window.stop() stops image animation along with its other effects.)

simonlindholm commented 6 years ago

I rather missed the deadline here, but, anyway. Here's a possible plan for a port:

Hopefully I'll have time for all this at some point... In the mean time, the addon continues to work on Nightly, about:config's image.animation_mode = none still works, and with image.animation_mode = normal https://addons.mozilla.org/en-US/firefox/addon/superstop/ might be an alternative.

rredford commented 6 years ago

Hope you find a way. :) I miss this plugin so hard.

mahpooya commented 6 years ago

Looking forward to it! Thanks in advance.

Mcinwwl commented 6 years ago

Sorry for filling your comments... Just wanted to let you know that more people are awaiting WebExt version. Good luck.

simonlindholm commented 6 years ago

Thanks for the encouragement, all. I have some work-in-progress on the web-ext branch; current status is that it's buggy. Hopefully it's fixable, if not I guess I could do something more like https://github.com/buzzfeed/libgif-js or https://github.com/adamfur/GifJam. Still haven't tested performance.

SuperSentient commented 6 years ago

I noticed a bug with Firefox 57, it doesn't want to play animated gifs and I tried removing Toggle Animated Gifs (even though its still a legacy add-on) and it didn't help. My guess is that something got corrupted in Firefox when updating to version 57. Also good luck with updating TAG to a Web Extension.

simonlindholm commented 6 years ago

I suspect that's because the addon sets the image.animation_mode pref in about:config to none, and doesn't revert it on uninstall because Firefox 57 doesn't run uninstall code for legacy addons. You should be able to fix it by going to about:config and setting image.animation_mode to normal. Sorry for the inconvenience.

SuperSentient commented 6 years ago

@simonlindholm Thanks, But I already got some help last night from the Mozilla forums about this.:)

danbruegge commented 6 years ago

@simonlindholm hi, what is the status of the port? Do you need help?

simonlindholm commented 6 years ago

Thanks for asking. Life caught up with me, and I haven't had any time to look at this for the last two months... If you're interested in helping out, there's some work in progress in the 'web-ext' branch, and I could try giving some detail on how the code works. Status is that most of the big comment above is implemented, and sometimes it even works. However, it's buggy in a few ways:

So the way I'd continue this if I had time (likely won't for the next 1-2 months either) would be to first fix the redirect thing (to avoid false positives when testing), and do further testing of how stable the method is. Depending on that, either tweak things like resetting to work reliably and then ship an update, or re-think the approach and either implement my own custom GIF rendering or look into standization.

danbruegge commented 6 years ago

Thanks for the response. I'll check it out after my vacation. :)

danyright commented 6 years ago

Hey guys! Any news regarding the port? I don't have much time to help you code, but I could help you test if you need some testers. Thanks for your work

simonlindholm commented 6 years ago

Not much has happened since the last update. I may start to get time for this addon soon, though.

Mcinwwl commented 5 years ago

Hey, any chances project will move on any time soon? You have a bunch of fans, and your plugin has no replacement for Firefox 53 onwards.

ghost commented 5 years ago

On a related note, is anyone aware of an alternative with feature-parity? I don't want to disable GIF and HTML video autoplay entirely, only be default and play the files at will.

ghost commented 5 years ago

Even only implementing GIF-support would be very helpful, I occasionally come across older forums where every post seems to have animated GIFs (avatars, signatures, the message content). As far as I've understood implementing support for HTML video is delaying development.

sergeevabc commented 5 years ago

@simonlindholm, godspeed from still snow-covered Moscow.

rredford commented 5 years ago

Curious on what is current status on port. :)

danbruegge commented 5 years ago

Hej. Life got in the way. I had an idea of making a small gif only extension which only stops/starts a gif-image. But didn't found the time.

mahpooya commented 5 years ago

@simonlindholm Have you some required API missing, to continue developing this lovely addon? Do you defined missing APIs in bugzilla.mozilla.org? If you have, i will be glad to support it by adding my vote in them.

alexolog commented 4 years ago

Really missing this add-on. Willing to donate if it helps.

alexolog commented 4 years ago

Can the suggestions in the following work? https://stackoverflow.com/questions/3688460/stopping-gif-animation-programmatically/4276742 https://stackoverflow.com/questions/3062229/animated-gif-in-html5-canvas/6017468#6017468 https://github.com/ctrl-freaks/freezeframe.js

Janaue commented 3 years ago

any news ? I love the addon and is a big miss on quantum

rredford commented 3 years ago

I wish I knew enough to make one. I recently made an addon, cool but its very simple compared to this one.

danbruegge commented 3 years ago

Can the suggestions in the following work? https://stackoverflow.com/questions/3688460/stopping-gif-animation-programmatically/4276742 https://stackoverflow.com/questions/3062229/animated-gif-in-html5-canvas/6017468#6017468 https://github.com/ctrl-freaks/freezeframe.js

For a simple addon this links are good. But this addon especially aims to stop the gif in place. So hit stop/pause and play again where you stopped the gif.

Evengard commented 3 years ago

At least the addon won't have problems with cross-domain policy, which actually saves a ton of headache. There are libs which can parse GIFs in JS (eg https://github.com/buzzfeed/libgif-js or https://github.com/benwiley4000/gif-frames), all we need is to actually replace all the gifs into canvases, get the gif frames, get the gif animation speed and then just playback manually. But that solution isn't very performant. There is another way - to convert the gif into a video, and instead rendering it to canvas, just render it to a video tag - and we get play/pause out of the box. There is even libs which can do such a conversion (aka https://github.com/Kagami/webm.js), which I guess could be tweaked for the lossless encoding (as we don't really care about the resulting file size, and lossless is faster), but that would need some kind of caching and/or background and/or lazy loading. That sure gives better results, but that also kind of changes semantics - aka a video tag is not an img tag, so it can break some things as well - also won't probably work with background-image CSS tag gifs (although animated gifs in background - is that even a thing?)

There are ways, but they sure are messy than this one which basically could "hack" into the Firefox gif playing engine and set the state directly for the gifs themselves. Too bad Mozilla dropped XUL support =(

benoit-pierre commented 3 years ago

This is the user script I've made and been using for some time: Animate GIFs.user.js.

RodrigoDiazDVivar commented 1 year ago

This is the user script I've made and been using for some time: Animate GIFs.user.js.

Sorry I cant code (LOL) where should i put this code in to use on firefox?

alexolog commented 1 year ago

Install TamperMonkey and be happy

alexolog commented 1 year ago

This is the user script I've made and been using for some time: Animate GIFs.user.js

Doesn't work for me. I see an icon on the GIF but clicking it does nothing

lonix1 commented 1 year ago

I doubt that script works, it hadn't been updated in years. Doesn't work for me anyway.

The real solution is a webextension, like this one. But seems like it's abandoned.

RodrigoDiazDVivar commented 1 year ago

Doesn't work for me. I see an icon on the GIF but clicking it does nothing

It actually does, i think it starts the gif back from the begining when you click on it. Still useless

alexolog commented 1 year ago

I did seem to degrade the quality of the GIF. Oh well.

And userscripts can do most of what webextensions do.

RodrigoDiazDVivar commented 1 year ago

there's a webapp in chrome called gif scrubber. I think it worked for some time (but is dead now) i think this should be an integrated function in firefox tbh. i dont get why software companies keep trying to push things nobody ever wanted, while fail to provide basic common sense services (specially microsoft and google). I got pretty mad for firefox ending XUL but i'm back after 5 years

rredford commented 1 year ago

yeah I hate it when control is taken away. I hate how youtube just autoplays and same for gifs. This was awesome till it stopped working.

ssokolow commented 1 year ago

yeah I hate it when control is taken away. I hate how youtube just autoplays and same for gifs. This was awesome till it stopped working.

As long as I middle-click instead of left-clicking when changing videos, and toggle auto-advance off in the YouTube player widget (it does a pretty good job of staying off until I restart the browser), I'm pretty comfortable with the level of non-autoplay I get out of YouTube without breaking particularly indirect play-button-to-video-element connections on other sites.

Here are the relevant about:config keys I currently have set to non-default values:

media.autoplay.ask-permission   true
media.autoplay.default  1   
media.autoplay.enabled  false   
media.autoplay.enabled.user-gestures-needed true

The more annoying part was that I had to write a CSS Userstyle to force the issue on YouTube's insistence on constantly turning CC on. (.captions-text { display: none !important; })

rredford commented 1 year ago

I will always want captions on myself :D but otherwise thanks.

benoit-pierre commented 1 year ago

I've pushed the current version of my script here.