Hi!
As an early “proof-of-concept” (to sleep well at night), I tried to see how difficult it would be to migrate my Flickr Fixr webextension to MV3. Following the guide, I ended up only doing changes to the manifest.json file. So that was easy… Except the end-result didn’t work at all in Firefox, and I have no clue on why?!..
My non-persistent background-script (Event Page or what it is to be called now?) runs, and opens my “onboarding” page on install. And I can also open my extension’s Options page. But my content-script (Stigs_Flickr_Fixr.user.js) is totally ignored it seems. I have enabled a lot of log-statements in the content-script, but there are no log-lines to be found anywhere, nor any errors from the extension.
Completely lost on why it didn’t work, I tried replacing the non-persistent background script with a service-worker and installed the extension in Chrome. And voilà! Everything in the extension - including content-script - works fine (in Chrome)!
Does anybody have a clue on what could be going wrong in Firefox? I have tried both Nightly and Developer Edition, and I have changed the relevant flags in about:config.
Old MV2 manifest.json:
{
"manifest_version": 2,
"name": "Flickr Fixr",
"short_name": "Flickr Fixr",
"description": "Makes Flickr almost awesome - while waiting for SmugMug to fully fix it ;-)",
"version": "1.12.0",
"author": "Stig Nygaard",
"homepage_url": "https://github.com/StigNygaard/Stigs_Flickr_Fixr",
"permissions": [
"https://*.flickr.com/*",
"storage"
],
"content_security_policy": "script-src 'self'; object-src 'none'",
"icons": {
"16": "icons/fr16.png",
"32": "icons/fixr32.png",
"48": "icons/fixr48.png",
"64": "icons/fixr64.png",
"96": "icons/fixr96.png",
"128": "icons/fixr128.png",
"256": "icons/fixr256.png"
},
"applications": {
"gecko": {
"strict_min_version": "52.0"
}
},
"minimum_chrome_version": "67.0",
"minimum_opera_version": "56.0",
"minimum_edge_version": "79.0",
"background": {
"scripts": ["lib/mozilla/browser-polyfill.js", "background/flickr_fixr.js"],
"persistent": false
},
"content_scripts": [
{
"matches": ["https://*.flickr.com/*", "*://*.flickr.net/*"],
"exclude_matches": ["*://api.flickr.com/*", "*://identity.flickr.com/*", "*://*.flickr.com/signin/*", "*://*.flickr.com/signup/*", "*://*.flickr.com/account/*"],
"js": ["lib/mozilla/browser-polyfill.js", "options/options.js", "Stigs_Flickr_Fixr.user.js"],
"run_at": "document_start"
}
],
"web_accessible_resources": ["inject/timeout.js"],
"options_ui": {
"page": "options/options.html",
"browser_style": true,
"chrome_style": true,
"open_in_tab": true
}
}
New MV3 manifest.json:
{
"manifest_version": 3,
"name": "Flickr Fixr",
"short_name": "Flickr Fixr",
"description": "Makes Flickr almost awesome - while waiting for SmugMug to fully fix it ;-)",
"version": "1.12.0",
"author": "Stig Nygaard",
"homepage_url": "https://github.com/StigNygaard/Stigs_Flickr_Fixr",
"permissions": [
"storage"
],
"host_permissions": [
"https://*.flickr.com/*"
],
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'none'"
},
"icons": {
"16": "icons/fr16.png",
"32": "icons/fixr32.png",
"48": "icons/fixr48.png",
"64": "icons/fixr64.png",
"96": "icons/fixr96.png",
"128": "icons/fixr128.png",
"256": "icons/fixr256.png"
},
"applications": {
"gecko": {
"strict_min_version": "103.0"
}
},
"minimum_chrome_version": "103.0",
"minimum_opera_version": "89.0",
"background": {
"scripts": ["lib/mozilla/browser-polyfill.js", "background/flickr_fixr.js"],
"persistent": false
},
"content_scripts": [
{
"matches": ["https://*.flickr.com/*", "*://*.flickr.net/*"],
"exclude_matches": ["*://api.flickr.com/*", "*://identity.flickr.com/*", "*://*.flickr.com/signin/*", "*://*.flickr.com/signup/*", "*://*.flickr.com/account/*"],
"js": ["lib/mozilla/browser-polyfill.js", "options/options.js", "Stigs_Flickr_Fixr.user.js"],
"run_at": "document_start"
}
],
"web_accessible_resources": [
{
"resources": [ "inject/timeout.js" ],
"matches": [ "https://*.flickr.com/*" ]
}
],
"options_ui": {
"page": "options/options.html",
"browser_style": true,
"open_in_tab": true
}
}
Modifications to run in Chrome:
To make it run in Chrome, I removed the “options_ui”.“chrome_style” property (apparently doesn’t like that with MV3) and replaced the “background” property in above with
"background": {
"service_worker": "background/flickr_fixr.js",
"type": "module"
},
and included the browser-polyfill.js script in flickr_fixr.js with:
import * as Module from '/lib/mozilla/browser-polyfill.js';
(I don’t think polyfill adds anything to Module, but browser namespace API works in Chrome after this)