mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-14 15:37:12 +03:00
Compare commits
8 Commits
5.1.14
...
safari-bug
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
842564d56f | ||
|
|
f331e0cdf5 | ||
|
|
f3da71c12f | ||
|
|
41718ea5ae | ||
|
|
0cdfd68239 | ||
|
|
bbb234e498 | ||
|
|
3716c8aa80 | ||
|
|
92e156834b |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "__MSG_fullName__",
|
"name": "__MSG_fullName__",
|
||||||
"short_name": "SponsorBlock",
|
"short_name": "SponsorBlock",
|
||||||
"version": "5.1.14",
|
"version": "5.2.1",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"description": "__MSG_Description__",
|
"description": "__MSG_Description__",
|
||||||
"homepage_url": "https://sponsor.ajay.app",
|
"homepage_url": "https://sponsor.ajay.app",
|
||||||
@@ -84,7 +84,8 @@
|
|||||||
"https://sponsor.ajay.app/*"
|
"https://sponsor.ajay.app/*"
|
||||||
],
|
],
|
||||||
"optional_permissions": [
|
"optional_permissions": [
|
||||||
"*://*/*"
|
"*://*/*",
|
||||||
|
"webNavigation"
|
||||||
],
|
],
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"default_title": "SponsorBlock",
|
"default_title": "SponsorBlock",
|
||||||
|
|||||||
95
package-lock.json
generated
95
package-lock.json
generated
@@ -28,6 +28,7 @@
|
|||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ajayyy/maze-utils": "^1.0.3",
|
"@ajayyy/maze-utils": "^1.0.3",
|
||||||
|
"content-scripts-register-polyfill": "^4.0.2",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0"
|
"react-dom": "^18.2.0"
|
||||||
},
|
},
|
||||||
@@ -4286,6 +4287,19 @@
|
|||||||
"url": "https://github.com/yeoman/configstore?sponsor=1"
|
"url": "https://github.com/yeoman/configstore?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/content-scripts-register-polyfill": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/content-scripts-register-polyfill/-/content-scripts-register-polyfill-4.0.2.tgz",
|
||||||
|
"integrity": "sha512-8hDm+tu3BkxHZP7EUIIIo/495F6QNXF7cI9Lwr4PQaiohw2wWmi9k2SE4W4kNrAaLnFw6RZ2ev8EmrQb+sCoGQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"webext-content-scripts": "^2.5.2",
|
||||||
|
"webext-patterns": "^1.3.0",
|
||||||
|
"webext-polyfill-kinda": "^1.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/fregante"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/convert-source-map": {
|
"node_modules/convert-source-map": {
|
||||||
"version": "1.8.0",
|
"version": "1.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz",
|
||||||
@@ -12811,6 +12825,48 @@
|
|||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/webext-content-scripts": {
|
||||||
|
"version": "2.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/webext-content-scripts/-/webext-content-scripts-2.5.2.tgz",
|
||||||
|
"integrity": "sha512-N1Xq/E8dx0lVAOyPquuo+2Vj9Fx1GoqCFo79lWeJHbemaBJ53N3BHBmbJJYsQ8FOP1xiwN4bPRQY2dpSjHAD3Q==",
|
||||||
|
"dependencies": {
|
||||||
|
"webext-patterns": "^1.3.0",
|
||||||
|
"webext-polyfill-kinda": "^1.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/fregante"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/webext-patterns": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/webext-patterns/-/webext-patterns-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-X9HMnic9ZtvSFKi2cdh0l+sxyj7f9oLedaa2JfxjnyEqGBz8OJjaHQ40jmraX1DJLTHOpqr+rCz1r3MW2+doUg==",
|
||||||
|
"dependencies": {
|
||||||
|
"escape-string-regexp": "^5.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/fregante"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/webext-patterns/node_modules/escape-string-regexp": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/webext-polyfill-kinda": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/webext-polyfill-kinda/-/webext-polyfill-kinda-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-Py/d3w/bC0KntuO60ePSWHsdrebZ3uYBLeFUjyPkDV3yTEQib0MRFvPh57t8XjImu4ylBoEAsFjzh/r22UtxMw==",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/fregante"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/webidl-conversions": {
|
"node_modules/webidl-conversions": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
||||||
@@ -16550,6 +16606,16 @@
|
|||||||
"xdg-basedir": "^5.0.1"
|
"xdg-basedir": "^5.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"content-scripts-register-polyfill": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/content-scripts-register-polyfill/-/content-scripts-register-polyfill-4.0.2.tgz",
|
||||||
|
"integrity": "sha512-8hDm+tu3BkxHZP7EUIIIo/495F6QNXF7cI9Lwr4PQaiohw2wWmi9k2SE4W4kNrAaLnFw6RZ2ev8EmrQb+sCoGQ==",
|
||||||
|
"requires": {
|
||||||
|
"webext-content-scripts": "^2.5.2",
|
||||||
|
"webext-patterns": "^1.3.0",
|
||||||
|
"webext-polyfill-kinda": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"convert-source-map": {
|
"convert-source-map": {
|
||||||
"version": "1.8.0",
|
"version": "1.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz",
|
||||||
@@ -22820,6 +22886,35 @@
|
|||||||
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
|
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"webext-content-scripts": {
|
||||||
|
"version": "2.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/webext-content-scripts/-/webext-content-scripts-2.5.2.tgz",
|
||||||
|
"integrity": "sha512-N1Xq/E8dx0lVAOyPquuo+2Vj9Fx1GoqCFo79lWeJHbemaBJ53N3BHBmbJJYsQ8FOP1xiwN4bPRQY2dpSjHAD3Q==",
|
||||||
|
"requires": {
|
||||||
|
"webext-patterns": "^1.3.0",
|
||||||
|
"webext-polyfill-kinda": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webext-patterns": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/webext-patterns/-/webext-patterns-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-X9HMnic9ZtvSFKi2cdh0l+sxyj7f9oLedaa2JfxjnyEqGBz8OJjaHQ40jmraX1DJLTHOpqr+rCz1r3MW2+doUg==",
|
||||||
|
"requires": {
|
||||||
|
"escape-string-regexp": "^5.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"escape-string-regexp": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webext-polyfill-kinda": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/webext-polyfill-kinda/-/webext-polyfill-kinda-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-Py/d3w/bC0KntuO60ePSWHsdrebZ3uYBLeFUjyPkDV3yTEQib0MRFvPh57t8XjImu4ylBoEAsFjzh/r22UtxMw=="
|
||||||
|
},
|
||||||
"webidl-conversions": {
|
"webidl-conversions": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
||||||
|
|||||||
@@ -4,9 +4,10 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "background.js",
|
"main": "background.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@ajayyy/maze-utils": "^1.0.3",
|
||||||
|
"content-scripts-register-polyfill": "^4.0.2",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0"
|
||||||
"@ajayyy/maze-utils": "^1.0.3"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chrome": "^0.0.199",
|
"@types/chrome": "^0.0.199",
|
||||||
|
|||||||
@@ -442,7 +442,7 @@
|
|||||||
"message": "Support 3rd Party YouTube-Sites"
|
"message": "Support 3rd Party YouTube-Sites"
|
||||||
},
|
},
|
||||||
"supportOtherSitesDescription": {
|
"supportOtherSitesDescription": {
|
||||||
"message": "Support third party YouTube clients. To enable support, you must accept the extra permissions. This does NOT work in incognito on Chrome and other Chromium variants.",
|
"message": "Support third party YouTube clients. To enable support, you must accept the extra permissions.",
|
||||||
"description": "This replaces the 'supports Invidious' option because it now works on other YouTube sites such as Cloudtube"
|
"description": "This replaces the 'supports Invidious' option because it now works on other YouTube sites such as Cloudtube"
|
||||||
},
|
},
|
||||||
"supportedSites": {
|
"supportedSites": {
|
||||||
|
|||||||
@@ -442,7 +442,7 @@
|
|||||||
|
|
||||||
<div id="advanced" class="option-group hidden">
|
<div id="advanced" class="option-group hidden">
|
||||||
|
|
||||||
<div id="support-invidious" data-type="toggle" data-sync="supportInvidious" data-no-safari="true">
|
<div id="support-invidious" data-type="toggle" data-sync="supportInvidious">
|
||||||
<div class="switch-container">
|
<div class="switch-container">
|
||||||
<label class="switch">
|
<label class="switch">
|
||||||
<input id="supportInvidious" type="checkbox">
|
<input id="supportInvidious" type="checkbox">
|
||||||
@@ -457,7 +457,7 @@
|
|||||||
<div class="small-description">__MSG_supportOtherSitesDescription__ </div>
|
<div class="small-description">__MSG_supportOtherSitesDescription__ </div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-type="private-text-change" data-sync="invidiousInstances" data-no-safari="true" data-dependent-on="supportInvidious">
|
<div data-type="private-text-change" data-sync="invidiousInstances" data-dependent-on="supportInvidious">
|
||||||
<div class="option-button trigger-button">
|
<div class="option-button trigger-button">
|
||||||
__MSG_addInvidiousInstance__
|
__MSG_addInvidiousInstance__
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import * as CompileConfig from "../config.json";
|
|||||||
|
|
||||||
import Config from "./config";
|
import Config from "./config";
|
||||||
import { Registration } from "./types";
|
import { Registration } from "./types";
|
||||||
|
import registerContentScript from 'content-scripts-register-polyfill/ponyfill.js';
|
||||||
|
|
||||||
// Make the config public for debugging purposes
|
// Make the config public for debugging purposes
|
||||||
|
|
||||||
@@ -20,11 +21,9 @@ const popupPort: Record<string, chrome.runtime.Port> = {};
|
|||||||
const contentScriptRegistrations = {};
|
const contentScriptRegistrations = {};
|
||||||
|
|
||||||
// Register content script if needed
|
// Register content script if needed
|
||||||
if (utils.isFirefox()) {
|
utils.wait(() => Config.config !== null).then(function() {
|
||||||
utils.wait(() => Config.config !== null).then(function() {
|
if (Config.config.supportInvidious) utils.setupExtraSiteContentScripts();
|
||||||
if (Config.config.supportInvidious) utils.setupExtraSiteContentScripts();
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function onTabUpdatedListener(tabId: number) {
|
function onTabUpdatedListener(tabId: number) {
|
||||||
chrome.tabs.sendMessage(tabId, {
|
chrome.tabs.sendMessage(tabId, {
|
||||||
@@ -167,7 +166,7 @@ function registerFirefoxContentScript(options: Registration) {
|
|||||||
const oldRegistration = contentScriptRegistrations[options.id];
|
const oldRegistration = contentScriptRegistrations[options.id];
|
||||||
if (oldRegistration) oldRegistration.unregister();
|
if (oldRegistration) oldRegistration.unregister();
|
||||||
|
|
||||||
browser.contentScripts.register({
|
registerContentScript({
|
||||||
allFrames: options.allFrames,
|
allFrames: options.allFrames,
|
||||||
js: options.js,
|
js: options.js,
|
||||||
css: options.css,
|
css: options.css,
|
||||||
@@ -181,8 +180,10 @@ function registerFirefoxContentScript(options: Registration) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function unregisterFirefoxContentScript(id: string) {
|
function unregisterFirefoxContentScript(id: string) {
|
||||||
contentScriptRegistrations[id].unregister();
|
if (contentScriptRegistrations[id]) {
|
||||||
delete contentScriptRegistrations[id];
|
contentScriptRegistrations[id].unregister();
|
||||||
|
delete contentScriptRegistrations[id];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitVote(type: number, UUID: string, category: string) {
|
async function submitVote(type: number, UUID: string, category: string) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as CompileConfig from "../config.json";
|
import * as CompileConfig from "../config.json";
|
||||||
import * as invidiousList from "../ci/invidiouslist.json";
|
import * as invidiousList from "../ci/invidiouslist.json";
|
||||||
import { Category, CategorySelection, CategorySkipOption, NoticeVisbilityMode, PreviewBarOption, SponsorTime, StorageChangesObject, Keybind, HashedValue, VideoID, SponsorHideType } from "./types";
|
import { Category, CategorySelection, CategorySkipOption, NoticeVisbilityMode, PreviewBarOption, SponsorTime, StorageChangesObject, Keybind, HashedValue, VideoID, SponsorHideType } from "./types";
|
||||||
import { isSafari, keybindEquals } from "./utils/configUtils";
|
import { keybindEquals } from "./utils/configUtils";
|
||||||
|
|
||||||
export interface Permission {
|
export interface Permission {
|
||||||
canSubmit: boolean;
|
canSubmit: boolean;
|
||||||
@@ -180,7 +180,7 @@ const Config: SBObject = {
|
|||||||
hideDiscordLaunches: 0,
|
hideDiscordLaunches: 0,
|
||||||
hideDiscordLink: false,
|
hideDiscordLink: false,
|
||||||
invidiousInstances: ["invidious.snopyta.org"], // leave as default
|
invidiousInstances: ["invidious.snopyta.org"], // leave as default
|
||||||
supportInvidious: isSafari(),
|
supportInvidious: false,
|
||||||
serverAddress: CompileConfig.serverAddress,
|
serverAddress: CompileConfig.serverAddress,
|
||||||
minDuration: 0,
|
minDuration: 0,
|
||||||
skipNoticeDuration: 4,
|
skipNoticeDuration: 4,
|
||||||
@@ -550,9 +550,8 @@ function migrateOldSyncFormats(config: SBConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// populate invidiousInstances with new instances if 3p support is **DISABLED**
|
// populate invidiousInstances with new instances if 3p support is **DISABLED**
|
||||||
// for safari, update it immediately
|
if (!config["supportInvidious"] && config["invidiousInstances"].length < invidiousList.length) {
|
||||||
if ((isSafari() || !config["supportInvidious"]) && config["invidiousInstances"].length !== invidiousList.length) {
|
config["invidiousInstances"] = [...new Set([...invidiousList, ...config["invidiousInstances"]])];
|
||||||
config["invidiousInstances"] = invidiousList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config["lastIsVipUpdate"]) {
|
if (config["lastIsVipUpdate"]) {
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ function invidiousInstanceAddInit(element: HTMLElement, option: string) {
|
|||||||
let instanceList = Config.config[option];
|
let instanceList = Config.config[option];
|
||||||
if (!instanceList) instanceList = [];
|
if (!instanceList) instanceList = [];
|
||||||
|
|
||||||
instanceList.push(textBox.value);
|
instanceList.push(textBox.value.trim().toLowerCase());
|
||||||
|
|
||||||
Config.config[option] = instanceList;
|
Config.config[option] = instanceList;
|
||||||
|
|
||||||
|
|||||||
92
src/utils.ts
92
src/utils.ts
@@ -119,9 +119,9 @@ export default class Utils {
|
|||||||
* @param {CallableFunction} callback
|
* @param {CallableFunction} callback
|
||||||
*/
|
*/
|
||||||
setupExtraSitePermissions(callback: (granted: boolean) => void): void {
|
setupExtraSitePermissions(callback: (granted: boolean) => void): void {
|
||||||
// Request permission
|
let permissions = ["webNavigation"];
|
||||||
let permissions = ["declarativeContent"];
|
if (!isSafari()) permissions.push("declarativeContent");
|
||||||
if (this.isFirefox()) permissions = [];
|
if (this.isFirefox() && !isSafari()) permissions = [];
|
||||||
|
|
||||||
chrome.permissions.request({
|
chrome.permissions.request({
|
||||||
origins: this.getPermissionRegex(),
|
origins: this.getPermissionRegex(),
|
||||||
@@ -145,52 +145,28 @@ export default class Utils {
|
|||||||
* For now, it is just SB.config.invidiousInstances.
|
* For now, it is just SB.config.invidiousInstances.
|
||||||
*/
|
*/
|
||||||
setupExtraSiteContentScripts(): void {
|
setupExtraSiteContentScripts(): void {
|
||||||
if (this.isFirefox()) {
|
const firefoxJS = [];
|
||||||
const firefoxJS = [];
|
for (const file of this.js) {
|
||||||
for (const file of this.js) {
|
firefoxJS.push({file});
|
||||||
firefoxJS.push({file});
|
}
|
||||||
}
|
const firefoxCSS = [];
|
||||||
const firefoxCSS = [];
|
for (const file of this.css) {
|
||||||
for (const file of this.css) {
|
firefoxCSS.push({file});
|
||||||
firefoxCSS.push({file});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const registration: Registration = {
|
const registration: Registration = {
|
||||||
message: "registerContentScript",
|
message: "registerContentScript",
|
||||||
id: "invidious",
|
id: "invidious",
|
||||||
allFrames: true,
|
allFrames: true,
|
||||||
js: firefoxJS,
|
js: firefoxJS,
|
||||||
css: firefoxCSS,
|
css: firefoxCSS,
|
||||||
matches: this.getPermissionRegex()
|
matches: this.getPermissionRegex()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.backgroundScriptContainer) {
|
if (this.backgroundScriptContainer) {
|
||||||
this.backgroundScriptContainer.registerFirefoxContentScript(registration);
|
this.backgroundScriptContainer.registerFirefoxContentScript(registration);
|
||||||
} else {
|
|
||||||
chrome.runtime.sendMessage(registration);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
chrome.declarativeContent.onPageChanged.removeRules(["invidious"], () => {
|
chrome.runtime.sendMessage(registration);
|
||||||
const conditions = [];
|
|
||||||
for (const regex of this.getPermissionRegex()) {
|
|
||||||
conditions.push(new chrome.declarativeContent.PageStateMatcher({
|
|
||||||
pageUrl: { urlMatches: regex }
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add page rule
|
|
||||||
const rule = {
|
|
||||||
id: "invidious",
|
|
||||||
conditions,
|
|
||||||
actions: [new chrome.declarativeContent.RequestContentScript({
|
|
||||||
allFrames: true,
|
|
||||||
js: this.js,
|
|
||||||
css: this.css
|
|
||||||
})]
|
|
||||||
};
|
|
||||||
|
|
||||||
chrome.declarativeContent.onPageChanged.addRules([rule]);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,18 +174,18 @@ export default class Utils {
|
|||||||
* Removes the permission and content script registration.
|
* Removes the permission and content script registration.
|
||||||
*/
|
*/
|
||||||
removeExtraSiteRegistration(): void {
|
removeExtraSiteRegistration(): void {
|
||||||
if (this.isFirefox()) {
|
const id = "invidious";
|
||||||
const id = "invidious";
|
|
||||||
|
|
||||||
if (this.backgroundScriptContainer) {
|
if (this.backgroundScriptContainer) {
|
||||||
this.backgroundScriptContainer.unregisterFirefoxContentScript(id);
|
this.backgroundScriptContainer.unregisterFirefoxContentScript(id);
|
||||||
} else {
|
} else {
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
message: "unregisterContentScript",
|
message: "unregisterContentScript",
|
||||||
id: id
|
id: id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (chrome.declarativeContent) {
|
|
||||||
|
if (!this.isFirefox() && chrome.declarativeContent) {
|
||||||
// Only if we have permission
|
// Only if we have permission
|
||||||
chrome.declarativeContent.onPageChanged.removeRules(["invidious"]);
|
chrome.declarativeContent.onPageChanged.removeRules(["invidious"]);
|
||||||
}
|
}
|
||||||
@@ -237,8 +213,6 @@ export default class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
containsInvidiousPermission(): Promise<boolean> {
|
containsInvidiousPermission(): Promise<boolean> {
|
||||||
if (isSafari()) return Promise.resolve(true);
|
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
let permissions = ["declarativeContent"];
|
let permissions = ["declarativeContent"];
|
||||||
if (this.isFirefox()) permissions = [];
|
if (this.isFirefox()) permissions = [];
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { validate } = require('schema-utils');
|
const { validate } = require('schema-utils');
|
||||||
const invidiousList = require("../ci/invidiouslist.json");
|
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const manifest = require("../manifest/manifest.json");
|
const manifest = require("../manifest/manifest.json");
|
||||||
@@ -50,11 +48,6 @@ class BuildManifest {
|
|||||||
mergeObjects(manifest, chromeManifestExtra);
|
mergeObjects(manifest, chromeManifestExtra);
|
||||||
} else if (this.options.browser.toLowerCase() === "safari") {
|
} else if (this.options.browser.toLowerCase() === "safari") {
|
||||||
mergeObjects(manifest, safariManifestExtra);
|
mergeObjects(manifest, safariManifestExtra);
|
||||||
|
|
||||||
// Add all invidious instances as options for the content script
|
|
||||||
for (const instance of invidiousList) {
|
|
||||||
manifest.content_scripts[0].matches.push(`*://*.${instance}/*`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.options.stream === "beta") {
|
if (this.options.stream === "beta") {
|
||||||
|
|||||||
Reference in New Issue
Block a user