Skip to content

Commit

Permalink
fix(background sync): Move back to manifest v2 for firefox
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Dec 31, 2023
1 parent 0af1869 commit 355cae7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
11 changes: 11 additions & 0 deletions html/background.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Floccus</title>
</head>
<body>
<script src="../../lib/chrome-promise.js"></script>
<script src="../js/background-script.js"></script>
</body>
</html>
25 changes: 11 additions & 14 deletions manifest.firefox.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
{
"manifest_version": 3,
"manifest_version": 2,
"name": "floccus bookmarks sync",
"short_name": "floccus",
"version": "5.0.5",
"version": "5.0.6",
"description": "__MSG_DescriptionExtension__",
"icons": {
"48": "icons/logo.png",
"64": "icons/logo_64.png",
"128": "icons/logo_128.png"
},

"browser_specific_settings": {
"applications": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "109.0"
"strict_min_version": "57.0"
}
},

"default_locale": "en",

"permissions": ["alarms", "bookmarks", "storage", "unlimitedStorage", "tabs", "identity"],
"host_permissions": [
"*://*/*"
],
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self';"
},
"permissions": ["https://*/", "http://*/", "alarms", "bookmarks", "storage", "unlimitedStorage", "tabs", "identity"],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self';",

"options_ui": {
"page": "dist/html/options.html",
"browser_style": false
"browser_style": false,
"chrome_style": false
},

"action": {
"browser_action": {
"browser_style": false,
"chrome_style": false,
"default_icon": {
"48": "icons/logo.png"
},
Expand All @@ -42,6 +39,6 @@
},

"background": {
"scripts": ["dist/js/background-script.js"]
"page": "dist/html/background.html"
}
}
2 changes: 1 addition & 1 deletion src/lib/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class Controller implements IController {
if (this.worker) {
return Promise.resolve(this.worker)
}
if (navigator.serviceWorker?.controller) {
if (!navigator.userAgent.includes('Firefox') && navigator.serviceWorker?.controller) {
return navigator.serviceWorker.ready.then((registration) => ({
postMessage: (...args) => registration.active.postMessage(...args),
addEventListener: (fn) => {
Expand Down
8 changes: 6 additions & 2 deletions src/lib/browser/BrowserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default class BrowserController {
// Setup service worker messaging

// eslint-disable-next-line no-undef
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
if (!navigator.userAgent.includes('Firefox') && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
addEventListener('message', (event) => this._receiveEvent(event.data, (data) => event.source.postMessage(data)))
} else {
browser.runtime.onMessage.addListener((data) => void (this._receiveEvent(data, (data) => browser.runtime.sendMessage(data))))
Expand Down Expand Up @@ -363,7 +363,11 @@ export default class BrowserController {
}

if (icon[status]) {
await browser.action.setIcon(icon[status])
if (navigator.userAgent.includes('Firefox')) {
await browser.browserAction.setIcon(icon[status])
} else {
await browser.action.setIcon(icon[status])
}
}
}

Expand Down

0 comments on commit 355cae7

Please sign in to comment.