From 06662d29e99cf769158c0e0c907959b556e7714d Mon Sep 17 00:00:00 2001 From: dauphine-dev Date: Sat, 11 Mar 2023 13:50:34 +0100 Subject: [PATCH 1/3] Keep background script alive with manifest V3 --- js/independent/background.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/independent/background.js b/js/independent/background.js index d8b2ba7..65f3b74 100644 --- a/js/independent/background.js +++ b/js/independent/background.js @@ -1,6 +1,5 @@ -/*global browser*/ +/*global browser chrome*/ 'use strict'; -//const SIDEBAR_URL = '/html/sidebar.html'; class BackgroundManager { static get instance() { return (this._instance = this._instance || new this()); } @@ -8,6 +7,7 @@ class BackgroundManager { constructor() { this._windowList = []; this._windowId = null; + this._portKeepAlive = null; } async init_async() { @@ -20,6 +20,7 @@ class BackgroundManager { } else { browser.browserAction.onClicked.addListener((e) => { this._toggleDropFeedsPanel_async(e); }); } + this.keepMeAlive(); } async _windowOnFocused_event(windowId) { @@ -55,5 +56,15 @@ class BackgroundManager { let self = BackgroundManager.instance; self._windowList.push(message.sidebarWindowId); } + + async keepMeAlive() { + setInterval(() => { + if (this._portKeepAlive == null) { + this._portKeepAlive = chrome.runtime.connect({ name: 'keep-background-script-alive' }); + this._portKeepAlive.onDisconnect.addListener(() => { this._portKeepAlive = null; }); + } + if (this._portKeepAlive) { this._portKeepAlive.postMessage({ content: 'keep-me-alive' }); } + }, 15000); + } } BackgroundManager.instance.init_async(); From 7dd8cb1a2740ce08440b5c5da27d7deaf0541eaf Mon Sep 17 00:00:00 2001 From: dauphine-dev Date: Sat, 11 Mar 2023 13:52:36 +0100 Subject: [PATCH 2/3] Update version number --- manifest.json | 2 +- manifestv2.json | 2 +- manifestv3.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 5cffb26..598e109 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "default_locale": "en", "name": "Drop feeds", "description": "__MSG_manExtensionDescription__", - "version": "1.0.16.200000003", + "version": "1.0.16.300000002", "browser_specific_settings": { "gecko": { "id": "{42d52ade-6923-4f20-92d1-8db031269cc6}", diff --git a/manifestv2.json b/manifestv2.json index 9e786ec..0490c4e 100644 --- a/manifestv2.json +++ b/manifestv2.json @@ -3,7 +3,7 @@ "default_locale": "en", "name": "Drop feeds", "description": "__MSG_manExtensionDescription__", - "version": "1.0.16.200000002", + "version": "1.0.16.300000002", "browser_specific_settings": { "gecko": { "id": "{42d52ade-6923-4f20-92d1-8db031269cc6}", diff --git a/manifestv3.json b/manifestv3.json index 5cffb26..c44a99b 100644 --- a/manifestv3.json +++ b/manifestv3.json @@ -3,7 +3,7 @@ "default_locale": "en", "name": "Drop feeds", "description": "__MSG_manExtensionDescription__", - "version": "1.0.16.200000003", + "version": "1.0.16.300000003", "browser_specific_settings": { "gecko": { "id": "{42d52ade-6923-4f20-92d1-8db031269cc6}", From 4af048aabc9a85c419bc92a9267ad24d35156ff6 Mon Sep 17 00:00:00 2001 From: dauphine-dev Date: Sat, 11 Mar 2023 13:58:14 +0100 Subject: [PATCH 3/3] manifest v2 as default --- manifest.json | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/manifest.json b/manifest.json index 598e109..0490c4e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "manifest_version": 3, + "manifest_version": 2, "default_locale": "en", "name": "Drop feeds", "description": "__MSG_manExtensionDescription__", @@ -7,9 +7,9 @@ "browser_specific_settings": { "gecko": { "id": "{42d52ade-6923-4f20-92d1-8db031269cc6}", - "strict_min_version": "109.0" + "strict_min_version": "73.0" } - }, + }, "icons": { "32": "themes/_templates/img/drop-feeds-32.png", "48": "themes/_templates/img/drop-feeds-48.png", @@ -28,11 +28,8 @@ } } }, - "action": { - "browser_style": true, - "default_icon": { - "64": "themes/_templates/img/drop-feeds-64.png" - } + "browser_action": { + "default_icon": "themes/_templates/img/drop-feeds-64.png" }, "page_action": { "browser_style": true, @@ -61,20 +58,11 @@ "browser_style": true }, "web_accessible_resources": [ - { - "resources": [ - "resources/highlighters/javascript.json" - ], - "matches": [ - "" - ] - } + "resources/highlighters/javascript.json" ], - "content_security_policy": { - "extension_pages": "script-src 'self'; object-src 'self';" - }, - "host_permissions": [""], + "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self';", "permissions": [ + "", "bookmarks", "contextMenus", "downloads",