Add support for Manifest V3
Manifest V3 (MV3) is a new version of the manifest.json file, which also
comes with several API changes:
https://developer.chrome.com/docs/extensions/mv3/intro/
Therefore, this change does the following:
- Add a new target to the Makefile and release.bash scripts called
"chromium-mv3-beta"/"CHROMIUM_MV3" which target Chromium using
Manifest V3.
- Adapt the manifest.gjson template so it is compatible with Manifest
V3 when the target is "CHROMIUM_MV3".
- Adapt the source code (change the background page to a service
worker and change chrome.browserAction.* to chrome.action.*).
Also, the following change has been done:
- The "gecko-beta" target in the Makefile has been removed because in
the end we never released beta versions for Firefox, due to the small
user base there.
Change-Id: Ibedcd6651cd23aa3db359a1ef7c7b96a232f39a7
diff --git a/src/sw.js b/src/sw.js
new file mode 100644
index 0000000..c90c5a6
--- /dev/null
+++ b/src/sw.js
@@ -0,0 +1,14 @@
+importScripts('common/common.js')
+
+// When the extension gets updated, set new options to their default value.
+chrome.runtime.onInstalled.addListener(details => {
+ if (details.reason == 'install' || details.reason == 'update') {
+ chrome.storage.sync.get(null, options => {
+ cleanUpOptions(options);
+ });
+ }
+});
+
+chrome.action.onClicked.addListener(_ => {
+ chrome.runtime.openOptionsPage();
+});