gioxx / MarvellousSuspender

A chrome extension for suspending all tabs to free up memory, based on the original TGS 7.1.6, without tracking. Find more information about that on https://gioxx.org/tms
https://go.gioxx.org/download-tms
GNU General Public License v2.0
1.06k stars 87 forks source link

Migrate to Manifest V3 #236

Open aybanda opened 1 week ago

aybanda commented 1 week ago

PR Title: Migrate to Manifest V3 and Update Options Page

Description:

This PR migrates the Chrome extension to Manifest V3 and updates the options page to ensure compatibility and improved

functionality. The following changes have been made:

Manifest V3 Migration:

Updated manifest.json to use manifest_version: 3. Replaced background scripts with service_worker. Moved URL patterns from permissions to host_permissions.

Options Page Update:

Changed options_page to options_ui in manifest.json. Ensured options.html exists and handles URL parameters (e.g., ?firstTime).

Content Security Policy:

Updated content_security_policy to comply with Manifest V3 requirements.

General Improvements:

Verified the existence of all necessary files (e.g., options.html, icons).

Ensured all functionalities work as expected after migration.

Testing

Screenshot 2024-09-23 at 4 04 34 PM Screenshot 2024-09-23 at 4 29 34 PM

Notes

Users need to manually enable "Allow access to file URLs" in the Chrome extension settings for file URL access. The extension now requires Chrome version 88 or higher.


Summary

This PR ensures that the Chrome extension is fully compatible with Manifest V3 and improves the options page functionality. Please review the changes and provide feedback.

Feel free to adjust the description as needed to better fit your project's context and any additional details you might want to include.

If you want this to be merged and needs changes let me know


If you feel like supporting me you can do that by: https://buymeacoffee.com/aybanda

user334 commented 1 week ago

Hey @aybanda! It's awesome you've decided to help this project to move to MV3. Thanks for your contribution!

I wanted to ask if you've seen the previous PR here. The blocking thing there is that the extension is not only need to "just" switch to mv3, but know about the Chrome's tab grouping feature. So is your new code aware of such a function? Please check this out: https://github.com/gioxx/MarvellousSuspender/pull/234#issuecomment-2326117079

And again, thanks for your effort! I really hope this PR would get merged.

trekshcool commented 1 week ago

I am having a little trouble trying to load this pull request I downloaded this branches zip from here - https://github.com/aybanda/MarvellousSuspender/tree/migrate-to-Manifest-V3

After that I tried to load the folder into chromes bata branch but I got the following error Manifest file missing error After that I tried to go into the scr folder which has the manifest file to try to load it but then I got this error. Manifest background error

Any suggestions on what I am doing wrong here?

Technetium1 commented 1 week ago

Thanks for this, consider marking it as a draft until it's been fully tested.

ThisIsSammysAccount commented 1 week ago

Thanks for your help. Regarding the loading issue, I believe the service_worker path for background.js in manifest.json needs to be changed to js/background.js so it can find the file. Also, a number of existing TMS functions in background.js were removed. I assume that was intentional given your comment "// Other functions and event listeners..." in place of the prior code, but let me know if I just missed something.

trekshcool commented 1 week ago

Thanks for your help. Regarding the loading issue, I believe the service_worker path for background.js in manifest.json needs to be changed to js/background.js so it can find the file. Also, a number of existing TMS functions in background.js were removed. I assume that was intentional given your comment "// Other functions and event listeners..." in place of the prior code, but let me know if I just missed something.

After changing the background.js to js/background.js the extension loaded with the following errors.

Uncaught NetworkError Failed to execute importScripts on WorkerGlobalScope Service worker registration failed error

trekshcool commented 1 week ago

@aybanda How did you manage to test it and get no errors?

AlexByte commented 1 week ago

@trekshcool Why are you testing the extension in Windows Sandbox?

trekshcool commented 1 week ago

@AlexByte Because I dont want to install the beta branch on my actual pc and mess up all my v2 extensions and tabs and then have to go though the hassle of uninstalling and downgrading chrome and recovering all my data.

It shouldn't make a different anyway its essentially a VM.

user334 commented 6 days ago

@trekshcool you can easily install a different branch of Chrome alongside your main one. Like a Dev or Canary. It'd be a completely separate browser and any mess that can happen there won't leak to the Stable.

But it's interesting that Windows now has such a feature. Here on macOS we don't have anything useful like this.

AlexByte commented 6 days ago

@trekshcool are you using a beta branch as the main one?

trekshcool commented 6 days ago

@AlexByte I am using the beta branch as it has manifest v3, current stable does not.

@user334 Yeah its a pretty new future and very easy to use, interesting that you can install both beta and main alongside one another didn't know that.

Have you guys managed to load the extensions or are you getting the same errors?

AlexByte commented 2 days ago

@trekshcool The stable version supports Manifest V3 and Manifest V2. Sandbox is an old feature from 2018.

Manifest V3 is supported generally in Chrome 88 or later

trekshcool commented 2 days ago

@AlexByte Wasn't it called something else before? I think they rebranded it. Either way I have now tested on stable too and its giving the same errors.

AlexByte commented 2 days ago

@trekshcool it wasn't rebranded.

trekshcool commented 2 days ago

@AlexByte Yup goggling around a bit your right, looks like I was misinformed by a youtube short.

ThisIsSammysAccount commented 2 days ago

Finally had a chance to check out the PR and take a look. To get the extension to load you need to run npm install and then npm run build, which will create a build directory with the unpacked extension and a zipped file. Part of the gruntfile moves backgrounds.js up a directory, which is why you were seeing path errors without running the build first. Unfortunately, once the extension is built and loaded it still has issues. Part of the migration to the service worker model in v3 requires replacing chrome.extension.getBackgroundPage(), which has not been done yet. https://developer.chrome.com/docs/extensions/develop/migrate/api-calls?hl=en#replace-mv2-function

So, the good news is that the extension will load. The bad news, it doesn't work yet, and there are missing features as I previously noted. Until @aybanda has a chance to make updates this isn't ready for testing.