reddit-moderator-toolbox icon indicating copy to clipboard operation
reddit-moderator-toolbox copied to clipboard

Manifest v3 support

Open creesch opened this issue 3 years ago • 4 comments

I could have sworn we already had an issue but I can't find it.

https://developer.chrome.com/docs/extensions/mv3/

We can start working on it but only reasonably implement it once firefox is also ready unless we want to keep two versions of the manifest and the affected areas in the code. https://blog.mozilla.org/addons/2021/05/27/manifest-v3-update/

Looking at these are some areas we need to make changes to:

The deadline for this appears to be the start of 2023.

creesch avatar Feb 15 '22 00:02 creesch

Started looking into this a little bit again. Caching does seem to be the biggest hurdle as far as I can tell. The way our caching is set up it times out after a certain period, we use active timers for that. Once of those timers expires, the background page sends an event to all tabs so cache is cleared across the board.

This doesn't work with service workers because they are event based and don't stay active. However, it seems like for whatever reason (I honestly can't remember) this event is only handled in TBCore here: https://github.com/toolbox-team/reddit-moderator-toolbox/blob/master/extension/data/tbcore.js#L1431

We also use local storage right now, but that isn't really an issue.

My current thinking is something along the lines of:

  • We start storing cache together with a timestamp.
  • If a cache value is requested we check against the timestamp if it might be stale.
  • If we do need a proactive timer on caching (needs investigating) we move that to the content_scripts where it basically will trigger based on whatever frontend script first times out after which that script will send a global event to all other tabs. (We already do have this mechanism).

Naturally this needs a bit more refining, I also do need to look into our caching once more to trace back my thoughts on implementing this.

creesch avatar Aug 24 '22 10:08 creesch

Modqueue caching is a seperate mechanism, it uses a local map to store it's cache. This likely needs to be moved to an extension storage object.

creesch avatar Aug 24 '22 10:08 creesch

Instead of refactoring all the cache related timeouts we might be able to leverage alarms

  • https://developer.chrome.com/docs/extensions/reference/alarms/
  • https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/alarms
  • https://stackoverflow.com/questions/66391018/how-do-i-call-a-function-periodically-in-a-manifest-v3-chrome-extension

Seems like it might be a good fit... but the behavior I am reading does need some more consideration.

creesch avatar Aug 24 '22 11:08 creesch

For some reason we still have a jquery ajax call in the background scripts https://github.com/toolbox-team/reddit-moderator-toolbox/blob/master/extension/data/background/handlers/notifications.js#L136

Needs to be replaced with a regular request.

creesch avatar Aug 24 '22 11:08 creesch

I don't think there's anything left in this issue that needs addressing, so I'm closing it now. We can track moving to MV3 for Firefox in a separate issue, but I don't think it makes sense for us to prioritize that right now since Chrome and FF are on completely different schedules for that, so I won't bother making anything for that until it comes up

eritbh avatar Aug 02 '23 01:08 eritbh