Closed eric24601 closed 2 weeks ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'm also interested in this. Anyone knows if it's a simple port or if more involved?
Some notes that might help us:
Converting a Chrome extension from Manifest V2 to Manifest V3 involves several key changes and considerations. The JSON snippet you've provided gives a good overview of the extension's current structure under Manifest V2. Let's go through the main points of conversion to Manifest V3:
Background Scripts: In Manifest V3, traditional background pages are replaced by service workers. If
background.js
contains long-running scripts or relies on DOM APIs, it will need significant modifications. Service workers in V3 are designed to be ephemeral, waking up when needed (e.g., to handle events) and shutting down when idle.Browser Action: The
browser_action
field is replaced byaction
in Manifest V3. This is a straightforward change, primarily involving renaming the key in the manifest.Permissions: The permissions model remains largely the same in Manifest V3, but you should review them to ensure they align with the new privacy and security standards of V3.
Host Permissions: If your extension uses host permissions (not visible in the provided snippet), they need to be migrated to the new
host_permissions
field.Content Security Policy (CSP): Manifest V3 enforces a more stringent CSP. This might require changes if your extension loads external resources.
Manifest Version: Update
manifest_version
to3
.Storage: If your extension uses persistent background pages to store state, you may need to migrate to using the
storage
API, as service workers are terminated when idle.Event Pages: If the extension uses event pages, they need to be migrated to use service workers.
Commands: The commands section seems straightforward and likely requires minimal changes, but you should verify compatibility with V3.
Overall, the difficulty of converting to Manifest V3 largely depends on how
background.js
and other scripts are structured. If they heavily rely on long-running scripts or synchronous XHR, the conversion can be complex. However, if the extension primarily reacts to events and doesn't rely on a persistent background page, the conversion should be relatively straightforward.Remember to thoroughly test the extension after conversion, as some changes might affect its behavior in subtle ways.
Some more notes on how involved changes to background.js might need to be:
After reviewing the
background.js
script from your Chrome extension, here are some key points regarding its conversion to Manifest V3:
Service Workers vs. Persistent Background Scripts: The current script seems to be designed as a persistent background script. With Manifest V3, this needs to be converted to a service worker, which is ephemeral and gets terminated when not in use. This means that you will need to refactor long-running or stateful processes. For example, the use of
setTimeout
andsetInterval
should be reviewed, as service workers can be terminated by the browser at any time.Event Listeners: The script uses various Chrome event listeners (
chrome.tabs.onUpdated
,chrome.tabs.onActivated
, etc.), which are compatible with Manifest V3. However, you should ensure that these listeners are registered each time the service worker starts up, as the worker may be stopped and started frequently.Global State: The script maintains global state (like
tabs
,closedTabs
, etc.). In Manifest V3, due to the ephemeral nature of service workers, you might need to persist this state externally (e.g., using thechrome.storage
API) and restore it when the service worker starts.Local Storage Access: The script uses
localStorage
for storing settings and state. In Manifest V3, you should migrate this to thechrome.storage
API, which is more suitable for extensions and works asynchronously.Background Page Functionality: If any functionality in your background script relies on a persistent background page (e.g., maintaining a DOM or executing long-running tasks), it will need to be adapted for the service worker model, which does not support a persistent background page.
Message Passing: The script uses
chrome.runtime.onConnect
for message passing. This is still valid in Manifest V3, but ensure that the communication pattern aligns with the ephemeral nature of service workers.Timers and Delays: Your script uses functions like
setTimeout
for delayed execution. In Manifest V3's service worker environment, these will need careful handling to ensure they're not dependent on the worker staying alive.Permissions and Manifest Changes: Besides updating the script, remember to update the manifest file to reflect Manifest V3 requirements, including updating the
manifest_version
to3
and making any necessary changes to the permissions and other fields.In summary, converting this extension to Manifest V3 will require significant refactoring, particularly around the state management and the transition from a persistent background script to an ephemeral service worker. The complexity of this conversion will depend on how deeply the current functionality is tied to the persistent background model and how much state needs to be managed across potential service worker restarts.
Maybe it can be done easier than what's suggested here?
Thanks for these notes, I'm trying to find some time to migrate Quick Tabs but life is crazy :)
I really wish I had the time but I'm kidding myself :|.
The effort to migrate to the v3 manifest is just more work than I have time to undertake and I imagine Google will stop supporting v2 soon which is a shame.
@babyman That should not be hard. I could do this migration if you accept a pull request and make a release. Cause seems you do not have time even for this.
@hababr I'm very supportive of that and can make time to review and merge a migration. That would be fantastic!
If anyone is willing to test the migrated version that would be nice. https://github.com/hababr/quick-tabs-chrome-extension/tree/master
I need to do a couple of things before I make a pull request, but everything should work already.
I just tried load unpacked and see a few errors:
@tberry2112 Thank you for the report! These issues happened on fresh install only, now they are fixed.
I'm running the latest V3 version and it seems to be working well. Thank you for taking this on! I did have to disable the old extension, then re-update the popup keyboard shortcut in chrome in order to get it to open on shortcut.
Hi @babyman, I opened a PR. Please ask anything if you are not sure about my changes.
Amazing, I'll take a look and let you know!
Thanks for this effort.
I have submitted the update to the Chrome Store for review, if it passes it will be published automatically. Thank you all for your efforts, very much appreciated!
I'll close this ticket once it's published.
And published, even with a Featured badge!
Woot! and congrats
@hababr I just wanted to say a huge THANK YOU for saving this must-have extension from extinction (and as always, thank you @babyman for creating it in the first place) I would like to buy you a coffee, if there was some way to make a donation to say thank you.
I would like to buy you a coffee, if there was some way to make a donation to say thank you.
Hi @hababr, I think this is the link for donations: https://ko-fi.com/quicktabs :-)
@rb-109 Agree with you this is a great extension. Babyman has a donation link in this repo.
@rb-109 Agree with you this is a great extension. Babyman has a donation link in this repo.
@hababr Thank you. In fact, I had found that link and have already donated to babyman, but in this case, I was asking whether YOU also had a donation page, because I wanted to thank you as well for writing the code to make the migration to manifest v3
@rb-109 thank you but that was unnecessary! I agree with you, this release really belongs to @hababr!
Hi, any plans to migrate the extension to manifest v3?
Thanks,
Eric