Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Manifest V3 #236

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aybanda
Copy link

@aybanda aybanda commented Sep 23, 2024

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
Copy link

user334 commented Sep 23, 2024

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: #234 (comment)

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

@trekshcool
Copy link

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
Copy link

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

@ThisIsSammysAccount
Copy link

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
Copy link

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
Copy link

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

@AlexByte
Copy link

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

@trekshcool
Copy link

@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
Copy link

user334 commented Sep 27, 2024

@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
Copy link

AlexByte commented Sep 27, 2024

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

@trekshcool
Copy link

@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?

@aybanda aybanda marked this pull request as draft September 29, 2024 16:12
@AlexByte
Copy link

AlexByte commented Oct 1, 2024

@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
Copy link

@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
Copy link

AlexByte commented Oct 1, 2024

@trekshcool it wasn't rebranded.

@trekshcool
Copy link

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

@ThisIsSammysAccount
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants