Skip to content

Commit

Permalink
MV3 support work:
Browse files Browse the repository at this point in the history
rename chrome.browserAction -> chrome.action
include ext/bg.js in sw/main.js
(addresses #131)
  • Loading branch information
ikreymer committed Jan 19, 2023
1 parent 6da562c commit a0cbb4b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 26 deletions.
20 changes: 10 additions & 10 deletions dist/embed/replay/sw.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ext/bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const disabledCSPTabs = new Set();
// ===========================================================================

function main() {
chrome.browserAction.setBadgeBackgroundColor({color: "#64e986"});
chrome.action.setBadgeBackgroundColor({color: "#64e986"});

chrome.contextMenus.create({"id": "toggle-rec", "title": "Start Recording", "contexts": ["browser_action"]});
chrome.contextMenus.create({"id": "view-rec", "title": "View Web Archives", "contexts": ["all"]});
Expand Down
6 changes: 3 additions & 3 deletions src/ext/browser-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ class BrowserRecorder extends Recorder {
color = "#64e986";
}

chrome.browserAction.setTitle({title, tabId});
chrome.browserAction.setBadgeBackgroundColor({color, tabId});
chrome.browserAction.setBadgeText({text, tabId});
chrome.action.setTitle({title, tabId});
chrome.action.setBadgeBackgroundColor({color, tabId});
chrome.action.setBadgeText({text, tabId});

if (this.port) {
const status = this.getStatusMsg();
Expand Down
27 changes: 16 additions & 11 deletions src/ext/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,32 @@
"name": "Webrecorder ArchiveWeb.page",
"description": "Create high-fidelity web archives directly in your browser",
"version": "$VERSION",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"permissions": ["debugger", "contextMenus", "tabs", "activeTab", "storage", "unlimitedStorage", "webRequest", "webRequestBlocking", "ipfs", "<all_urls>"],
"permissions": ["debugger", "contextMenus", "tabs", "activeTab", "storage", "unlimitedStorage", "webRequest", "ipfs"],
"background": {
"scripts": ["bg.js"],
"persistent": true
"service_worker": "replay/sw.js"
},
"icons": {
"32": "$ICON",
"128": "$ICON"
},
"browser_action": {
"action": {
"default_icon": {
"32": "$ICON"
},
"default_title": "Webrecorder ArchiveWeb.page",
"default_popup": "popup.html"
},
"web_accessible_resources": [
"pdf/*",
"replay/*",
"ruffle/*"
],
"manifest_version": 2
"web_accessible_resources": [{
"resources": [
"pdf/*",
"replay/*",
"ruffle/*"
],
"matches": ["*://*/*"]
}],
"host_permissions": ["*://*/*"],
"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'"
},
"manifest_version": 3
}
2 changes: 1 addition & 1 deletion src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class RecPopup extends LitElement
if (tabs.length) {
this.tabId = tabs[0].id;
this.pageUrl = tabs[0].url;
chrome.browserAction.getTitle({tabId: this.tabId}, (result) => {
chrome.action.getTitle({tabId: this.tabId}, (result) => {
this.recording = (result.indexOf("Recording:") >= 0);
});

Expand Down
2 changes: 2 additions & 0 deletions src/sw/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import RWP_INDEX_HTML from "replaywebpage/index.html";

import { WorkerLoader } from "@webrecorder/wabac/src/loaders";

import "../ext/bg";

if (self.registration) {
const defaultConfig = {
injectScripts: ["/ruffle/ruffle.js"],
Expand Down

0 comments on commit a0cbb4b

Please sign in to comment.