From 6f5bde2d0e69c754ca2ae5a0b5d3026d850efd85 Mon Sep 17 00:00:00 2001 From: Ajay Date: Mon, 28 Mar 2022 01:13:29 -0400 Subject: [PATCH] manifest v3 changes --- manifest/chrome-manifest-extra.json | 6 -- manifest/manifest.json | 85 ++++++++++----------- package.json | 17 +++-- src/background.ts | 3 +- src/components/CategoryPillComponent.tsx | 4 +- src/components/NoticeComponent.tsx | 4 +- src/components/SponsorTimeEditComponent.tsx | 2 +- src/content.ts | 28 +++---- src/js-components/chat.ts | 2 +- src/render/RectangleTooltip.tsx | 2 +- src/render/Tooltip.tsx | 2 +- webpack/webpack.common.js | 6 -- 12 files changed, 76 insertions(+), 85 deletions(-) diff --git a/manifest/chrome-manifest-extra.json b/manifest/chrome-manifest-extra.json index 8fe52df2..2c63c085 100644 --- a/manifest/chrome-manifest-extra.json +++ b/manifest/chrome-manifest-extra.json @@ -1,8 +1,2 @@ { - "optional_permissions": [ - "declarativeContent" - ], - "background": { - "persistent": false - } } diff --git a/manifest/manifest.json b/manifest/manifest.json index f49c66be..3c1411be 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -22,55 +22,54 @@ "popup.css" ] }], - "web_accessible_resources": [ - "icons/LogoSponsorBlocker256px.png", - "icons/IconSponsorBlocker256px.png", - "icons/PlayerStartIconSponsorBlocker.svg", - "icons/PlayerStopIconSponsorBlocker.svg", - "icons/PlayerUploadIconSponsorBlocker.svg", - "icons/PlayerUploadFailedIconSponsorBlocker.svg", - "icons/PlayerCancelSegmentIconSponsorBlocker.svg", - "icons/clipboard.svg", - "icons/settings.svg", - "icons/pencil.svg", - "icons/check.svg", - "icons/upvote.png", - "icons/downvote.png", - "icons/thumbs_down.svg", - "icons/thumbs_down_locked.svg", - "icons/thumbs_up.svg", - "icons/help.svg", - "icons/report.png", - "icons/close.png", - "icons/skipIcon.svg", - "icons/refresh.svg", - "icons/beep.ogg", - "icons/pause.svg", - "icons/stop.svg", - "icons/heart.svg", - "icons/visible.svg", - "icons/not_visible.svg", - "icons/PlayerInfoIconSponsorBlocker.svg", - "icons/PlayerDeleteIconSponsorBlocker.svg", - "popup.html", - "content.css" - ], + "web_accessible_resources": [{ + "resources": [ + "icons/LogoSponsorBlocker256px.png", + "icons/IconSponsorBlocker256px.png", + "icons/PlayerStartIconSponsorBlocker.svg", + "icons/PlayerStopIconSponsorBlocker.svg", + "icons/PlayerUploadIconSponsorBlocker.svg", + "icons/PlayerUploadFailedIconSponsorBlocker.svg", + "icons/PlayerCancelSegmentIconSponsorBlocker.svg", + "icons/clipboard.svg", + "icons/settings.svg", + "icons/pencil.svg", + "icons/check.svg", + "icons/upvote.png", + "icons/downvote.png", + "icons/thumbs_down.svg", + "icons/thumbs_down_locked.svg", + "icons/thumbs_up.svg", + "icons/help.svg", + "icons/report.png", + "icons/close.png", + "icons/skipIcon.svg", + "icons/refresh.svg", + "icons/beep.ogg", + "icons/pause.svg", + "icons/stop.svg", + "icons/heart.svg", + "icons/visible.svg", + "icons/not_visible.svg", + "icons/PlayerInfoIconSponsorBlocker.svg", + "icons/PlayerDeleteIconSponsorBlocker.svg", + "popup.html", + "content.css" + ], + "matches": [""] + }], "permissions": [ - "storage", + "storage" + ], + "host_permissions": [ "https://sponsor.ajay.app/*" ], - "optional_permissions": [ - "*://*/*" - ], - "browser_action": { + "action": { "default_title": "SponsorBlock", "default_popup": "popup.html" }, "background": { - "scripts":[ - "./js/vendor.js", - "./js/background.js" - ] + "service_worker": "./js/background.js" }, "icons": { "16": "icons/LogoSponsorBlocker64px.png", @@ -85,5 +84,5 @@ "page": "options/lock-options.html", "open_in_tab": true }, - "manifest_version": 2 + "manifest_version": 3 } diff --git a/package.json b/package.json index ceaa8f8f..4d7ddd4d 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,10 @@ "@types/chrome": "^0.0.178", "@types/firefox-webext-browser": "^94.0.1", "@types/jest": "^27.4.0", - "@types/wicg-mediasession": "^1.1.3", "@types/react": "^17.0.39", "@types/react-dom": "^17.0.11", "@types/selenium-webdriver": "^4.0.17", + "@types/wicg-mediasession": "^1.1.3", "@typescript-eslint/eslint-plugin": "^5.10.2", "@typescript-eslint/parser": "^5.10.2", "chromedriver": "^97.0.4", @@ -65,19 +65,24 @@ "engines": { "node": ">=12.20.0" }, - "funding": [{ + "funding": [ + { "type": "individual", "url": "hhttps://sponsor.ajay.app/donate" - }, { + }, + { "type": "github", "url": "https://github.com/sponsors/ajayyy-org" - }, { + }, + { "type": "patreon", "url": "https://www.patreon.com/ajayyy" - }, { + }, + { "type": "individual", "url": "https://paypal.me/ajayyy" - }], + } + ], "repository": { "type": "git", "url": "git+https://github.com/ajayyy/SponsorBlock.git" diff --git a/src/background.ts b/src/background.ts index 3b0aa097..9edf59ca 100644 --- a/src/background.ts +++ b/src/background.ts @@ -4,8 +4,7 @@ import Config from "./config"; import { Registration } from "./types"; // Make the config public for debugging purposes - -window.SB = Config; +// window.SB = Config; //no window for service workers import Utils from "./utils"; const utils = new Utils({ diff --git a/src/components/CategoryPillComponent.tsx b/src/components/CategoryPillComponent.tsx index 7d46d0aa..4fabefb3 100644 --- a/src/components/CategoryPillComponent.tsx +++ b/src/components/CategoryPillComponent.tsx @@ -50,7 +50,7 @@ class CategoryPillComponent extends React.Component this.closeTooltip()}> + src={chrome.runtime.getURL("icons/IconSponsorBlocker256px.png")}> {chrome.i18n.getMessage("category_" + this.state.segment?.category)} @@ -79,7 +79,7 @@ class CategoryPillComponent extends React.Component this.setState({ show: false })}> diff --git a/src/components/NoticeComponent.tsx b/src/components/NoticeComponent.tsx index c3128e72..f462a4ed 100644 --- a/src/components/NoticeComponent.tsx +++ b/src/components/NoticeComponent.tsx @@ -116,7 +116,7 @@ class NoticeComponent extends React.Component { {/* Logo */} + src={chrome.runtime.getURL("icons/IconSponsorBlocker256px.png")}> { {/* Close button */} - this.close()}> diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index 79922239..ce725083 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -194,7 +194,7 @@ class SponsorTimeEditComponent extends React.Component diff --git a/src/content.ts b/src/content.ts index 1cfd8669..8a5cae6b 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1430,7 +1430,7 @@ function createButton(baseID: string, title: string, callback: () => void, image newButton.draggable = isDraggable; newButtonImage.id = baseID + "Image"; newButtonImage.className = "playerButtonImage"; - newButtonImage.src = chrome.extension.getURL("icons/" + imageName); + newButtonImage.src = chrome.runtime.getURL("icons/" + imageName); // Append image to button newButton.appendChild(newButtonImage); @@ -1607,7 +1607,7 @@ function openInfoMenu() { //hide info button if (playerButtons.info) playerButtons.info.button.style.display = "none"; - sendRequestToCustomServer('GET', chrome.extension.getURL("popup.html"), function(xmlhttp) { + sendRequestToCustomServer('GET', chrome.runtime.getURL("popup.html"), function(xmlhttp) { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { const popup = document.createElement("div"); popup.id = "sponsorBlockPopupContainer"; @@ -1626,7 +1626,7 @@ function openInfoMenu() { //close button const closeButton = document.createElement("button"); const closeButtonIcon = document.createElement("img"); - closeButtonIcon.src = chrome.extension.getURL("icons/close.png"); + closeButtonIcon.src = chrome.runtime.getURL("icons/close.png"); closeButtonIcon.width = 15; closeButtonIcon.height = 15; closeButton.appendChild(closeButtonIcon); @@ -1659,14 +1659,14 @@ function openInfoMenu() { const refreshSegments = popup.querySelector("#refreshSegments"); const heart = popup.querySelector(".sbHeart"); const close = popup.querySelector("#sbCloseDonate"); - logo.src = chrome.extension.getURL("icons/IconSponsorBlocker256px.png"); - settings.src = chrome.extension.getURL("icons/settings.svg"); - edit.src = chrome.extension.getURL("icons/pencil.svg"); - copy.src = chrome.extension.getURL("icons/clipboard.svg"); - check.src = chrome.extension.getURL("icons/check.svg"); - heart.src = chrome.extension.getURL("icons/heart.svg"); - close.src = chrome.extension.getURL("icons/close.png"); - refreshSegments.src = chrome.extension.getURL("icons/refresh.svg"); + logo.src = chrome.runtime.getURL("icons/IconSponsorBlocker256px.png"); + settings.src = chrome.runtime.getURL("icons/settings.svg"); + edit.src = chrome.runtime.getURL("icons/pencil.svg"); + copy.src = chrome.runtime.getURL("icons/clipboard.svg"); + check.src = chrome.runtime.getURL("icons/check.svg"); + heart.src = chrome.runtime.getURL("icons/heart.svg"); + close.src = chrome.runtime.getURL("icons/close.png"); + refreshSegments.src = chrome.runtime.getURL("icons/refresh.svg"); parentNode.insertBefore(popup, parentNode.firstChild); @@ -1853,7 +1853,7 @@ async function sendSubmitMessage() { } // Add loading animation - playerButtons.submit.image.src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker.svg"); + playerButtons.submit.image.src = chrome.runtime.getURL("icons/PlayerUploadIconSponsorBlocker.svg"); const stopAnimation = AnimationUtils.applyLoadingAnimation(playerButtons.submit.button, 1, () => updateEditButtonsOnPlayer()); //check if a sponsor exceeds the duration of the video @@ -1928,7 +1928,7 @@ async function sendSubmitMessage() { } else { // Show that the upload failed playerButtons.submit.button.style.animation = "unset"; - playerButtons.submit.image.src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker.svg"); + playerButtons.submit.image.src = chrome.runtime.getURL("icons/PlayerUploadFailedIconSponsorBlocker.svg"); if (response.status === 403 && response.responseText.startsWith("Submission rejected due to a warning from a moderator.")) { Chat.openWarningChat(response.responseText); @@ -2026,7 +2026,7 @@ function addCSS() { fileref.rel = "stylesheet"; fileref.type = "text/css"; - fileref.href = chrome.extension.getURL(file); + fileref.href = chrome.runtime.getURL(file); head.appendChild(fileref); } diff --git a/src/js-components/chat.ts b/src/js-components/chat.ts index 9ff30af7..48ba10a1 100644 --- a/src/js-components/chat.ts +++ b/src/js-components/chat.ts @@ -19,7 +19,7 @@ export function openChat(config: ChatConfig): void { const closeButton = document.createElement("img"); closeButton.classList.add("sbChatClose"); - closeButton.src = chrome.extension.getURL("icons/close.png"); + closeButton.src = chrome.runtime.getURL("icons/close.png"); closeButton.addEventListener("click", () => { chat.remove(); closeButton.remove(); diff --git a/src/render/RectangleTooltip.tsx b/src/render/RectangleTooltip.tsx index 1887cbbc..49be6417 100644 --- a/src/render/RectangleTooltip.tsx +++ b/src/render/RectangleTooltip.tsx @@ -58,7 +58,7 @@ export class RectangleTooltip { className="sponsorBlockRectangleTooltip" >
+ src={chrome.runtime.getURL("icons/IconSponsorBlocker256px.png")}> {this.text + (props.link ? ". " : "")} diff --git a/src/render/Tooltip.tsx b/src/render/Tooltip.tsx index 66e581d5..887ab5c2 100644 --- a/src/render/Tooltip.tsx +++ b/src/render/Tooltip.tsx @@ -50,7 +50,7 @@ export class Tooltip {
{props.showLogo ? + src={chrome.runtime.getURL("icons/IconSponsorBlocker256px.png")}> : null} diff --git a/webpack/webpack.common.js b/webpack/webpack.common.js index ae32499a..5a8334c5 100644 --- a/webpack/webpack.common.js +++ b/webpack/webpack.common.js @@ -35,12 +35,6 @@ module.exports = env => ({ output: { path: path.join(__dirname, '../dist/js'), }, - optimization: { - splitChunks: { - name: 'vendor', - chunks: "initial" - } - }, module: { rules: [ {