Skip to content

Commit

Permalink
Support manifest v3
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayyy committed Jun 10, 2023
1 parent 50ed809 commit 6e5e790
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 94 deletions.
104 changes: 97 additions & 7 deletions manifest/chrome-manifest-extra.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,98 @@
{
"optional_permissions": [
"declarativeContent"
],
"background": {
"persistent": false
}
}
"optional_permissions": [
"declarativeContent"
],
"content_scripts": [
{
"world": "MAIN",
"js": [
"./js/document.js"
],
"matches": [
"https://*.youtube.com/*",
"https://www.youtube-nocookie.com/embed/*"
],
"all_frames": true,
"run_at": "document_start"
}
],
"web_accessible_resources": [{
"resources": [
"icons/refresh.svg",
"icons/logo.svg",
"js/document.js",
"js/options.js",
"js/popup.js",
"popup.css",
"shared.css",
"help.html",
"help.css",
"icons/logo-16.png",
"icons/logo-32.png",
"icons/logo-64.png",
"icons/logo-128.png",
"icons/logo-256.png"
],
"matches": ["<all_urls>"]
}],
"permissions": [
"scripting"
],
"host_permissions": [
"https://sponsor.ajay.app/*",
"https://dearrow-thumb.ajay.app/*",
"https://*.youtube.com/*",
"https://www.youtube-nocookie.com/embed/*"
],
"action": {
"default_title": "DeArrow",
"default_popup": "popup.html",
"default_icon": {
"16": "icons/logo-16.png",
"32": "icons/logo-32.png",
"64": "icons/logo-64.png",
"128": "icons/logo-128.png"
},
"theme_icons": [
{
"light": "icons/logo-16.png",
"dark": "icons/logo-16.png",
"size": 16
},
{
"light": "icons/logo-32.png",
"dark": "icons/logo-32.png",
"size": 32
},
{
"light": "icons/logo-64.png",
"dark": "icons/logo-64.png",
"size": 64
},
{
"light": "icons/logo-128.png",
"dark": "icons/logo-128.png",
"size": 128
},
{
"light": "icons/logo-256.png",
"dark": "icons/logo-256.png",
"size": 256
},
{
"light": "icons/logo-512.png",
"dark": "icons/logo-512.png",
"size": 512
},
{
"light": "icons/logo-1024.png",
"dark": "icons/logo-1024.png",
"size": 1024
}
]
},
"background": {
"service_worker": "./js/background.js"
},
"manifest_version": 3
}
78 changes: 78 additions & 0 deletions manifest/manifest-v2-extra.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"web_accessible_resources": [
"icons/refresh.svg",
"icons/logo.svg",
"js/document.js",
"js/options.js",
"js/popup.js",
"popup.css",
"shared.css",
"help.html",
"help.css",
"icons/logo-16.png",
"icons/logo-32.png",
"icons/logo-64.png",
"icons/logo-128.png",
"icons/logo-256.png"
],
"permissions": [
"https://sponsor.ajay.app/*",
"https://dearrow-thumb.ajay.app/*"
],
"optional_permissions": [
"*://*/*"
],
"browser_action": {
"default_title": "DeArrow",
"default_popup": "popup.html",
"default_icon": {
"16": "icons/logo-16.png",
"32": "icons/logo-32.png",
"64": "icons/logo-64.png",
"128": "icons/logo-128.png"
},
"theme_icons": [
{
"light": "icons/logo-16.png",
"dark": "icons/logo-16.png",
"size": 16
},
{
"light": "icons/logo-32.png",
"dark": "icons/logo-32.png",
"size": 32
},
{
"light": "icons/logo-64.png",
"dark": "icons/logo-64.png",
"size": 64
},
{
"light": "icons/logo-128.png",
"dark": "icons/logo-128.png",
"size": 128
},
{
"light": "icons/logo-256.png",
"dark": "icons/logo-256.png",
"size": 256
},
{
"light": "icons/logo-512.png",
"dark": "icons/logo-512.png",
"size": 512
},
{
"light": "icons/logo-1024.png",
"dark": "icons/logo-1024.png",
"size": 1024
}
]
},
"background": {
"scripts":[
"./js/background.js"
]
},
"manifest_version": 2
}
78 changes: 2 additions & 76 deletions manifest/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_deArrowFullName__",
"short_name": "DeArrow",
"version": "1.0.3",
"version": "1.0.4",
"default_locale": "en",
"description": "__MSG_deArrowDescription__",
"homepage_url": "https://sponsor.ajay.app",
Expand All @@ -20,83 +20,10 @@
"shared.css"
]
}],
"web_accessible_resources": [
"icons/refresh.svg",
"icons/logo.svg",
"js/document.js",
"js/options.js",
"js/popup.js",
"popup.css",
"shared.css",
"help.html",
"help.css",
"icons/logo-16.png",
"icons/logo-32.png",
"icons/logo-64.png",
"icons/logo-128.png",
"icons/logo-256.png"
],
"permissions": [
"storage",
"https://sponsor.ajay.app/*",
"https://dearrow-thumb.ajay.app/*",
"unlimitedStorage"
],
"optional_permissions": [
"*://*/*"
],
"browser_action": {
"default_title": "DeArrow",
"default_popup": "popup.html",
"default_icon": {
"16": "icons/logo-16.png",
"32": "icons/logo-32.png",
"64": "icons/logo-64.png",
"128": "icons/logo-128.png"
},
"theme_icons": [
{
"light": "icons/logo-16.png",
"dark": "icons/logo-16.png",
"size": 16
},
{
"light": "icons/logo-32.png",
"dark": "icons/logo-32.png",
"size": 32
},
{
"light": "icons/logo-64.png",
"dark": "icons/logo-64.png",
"size": 64
},
{
"light": "icons/logo-128.png",
"dark": "icons/logo-128.png",
"size": 128
},
{
"light": "icons/logo-256.png",
"dark": "icons/logo-256.png",
"size": 256
},
{
"light": "icons/logo-512.png",
"dark": "icons/logo-512.png",
"size": 512
},
{
"light": "icons/logo-1024.png",
"dark": "icons/logo-1024.png",
"size": 1024
}
]
},
"background": {
"scripts":[
"./js/background.js"
]
},
"icons": {
"16": "icons/logo-16.png",
"32": "icons/logo-32.png",
Expand All @@ -109,6 +36,5 @@
"options_ui": {
"page": "options/options.html",
"open_in_tab": true
},
"manifest_version": 2
}
}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "background.js",
"dependencies": {
"@ajayyy/maze-utils": "1.1.33",
"@ajayyy/maze-utils": "1.1.34",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"seedrandom": "^3.0.5"
Expand Down
2 changes: 1 addition & 1 deletion src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ chrome.runtime.onInstalled.addListener(() => {
}

// Open up the install page
setTimeout(() => void chrome.tabs.create({url: chrome.extension.getURL("/help.html")}), 100);
setTimeout(() => void chrome.tabs.create({url: chrome.runtime.getURL("/help.html")}), 100);
}
}, 1500);
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils/cssInjector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function addCssToPage() {
const fileref = document.createElement("link");
fileref.rel = "stylesheet";
fileref.type = "text/css";
fileref.href = chrome.extension.getURL(file);
fileref.href = chrome.runtime.getURL(file);

head.appendChild(fileref);
}
Expand Down
2 changes: 1 addition & 1 deletion src/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ export function setupCBVideoModule(): void {
resetValues,
windowListenerHandler,
newVideosLoaded,
documentScript
documentScript: chrome.runtime.getManifest().manifest_version === 2 ? documentScript : undefined
}, () => Config);
}
3 changes: 3 additions & 0 deletions webpack/webpack.manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const chromeManifestExtra = require("../manifest/chrome-manifest-extra.json");
const safariManifestExtra = require("../manifest/safari-manifest-extra.json");
const betaManifestExtra = require("../manifest/beta-manifest-extra.json");
const firefoxBetaManifestExtra = require("../manifest/firefox-beta-manifest-extra.json");
const manifestV2ManifestExtra = require("../manifest/manifest-v2-extra.json");

// schema for options object
const schema = {
Expand Down Expand Up @@ -42,12 +43,14 @@ class BuildManifest {

// Add missing manifest elements
if (this.options.browser.toLowerCase() === "firefox") {
mergeObjects(manifest, manifestV2ManifestExtra);
mergeObjects(manifest, firefoxManifestExtra);
} else if (this.options.browser.toLowerCase() === "chrome"
|| this.options.browser.toLowerCase() === "chromium"
|| this.options.browser.toLowerCase() === "edge") {
mergeObjects(manifest, chromeManifestExtra);
} else if (this.options.browser.toLowerCase() === "safari") {
mergeObjects(manifest, manifestV2ManifestExtra);
mergeObjects(manifest, safariManifestExtra);
}

Expand Down

0 comments on commit 6e5e790

Please # to comment.