diff options
author | Ajay <[email protected]> | 2023-02-01 19:48:24 -0500 |
---|---|---|
committer | Ajay <[email protected]> | 2023-02-01 19:48:24 -0500 |
commit | c3213eb040dd6dd0e891145ec6a2364bd19d4345 (patch) | |
tree | a97e14f65e6e1dd031f69e9c64faed3a5acda39e | |
parent | 78a006544a91a6d49f44a3d8cfa751531c456a50 (diff) | |
download | SponsorBlock-c3213eb040dd6dd0e891145ec6a2364bd19d4345.tar.gz SponsorBlock-c3213eb040dd6dd0e891145ec6a2364bd19d4345.zip |
Add invidious instances by default for safari
https://github.com/ajayyy/SponsorBlock/issues/798
-rw-r--r-- | src/config.ts | 7 | ||||
-rw-r--r-- | src/utils.ts | 3 | ||||
-rw-r--r-- | webpack/webpack.manifest.js | 6 |
3 files changed, 13 insertions, 3 deletions
diff --git a/src/config.ts b/src/config.ts index 3ddf05a1..f8759f05 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,7 +1,7 @@ import * as CompileConfig from "../config.json"; import * as invidiousList from "../ci/invidiouslist.json"; import { Category, CategorySelection, CategorySkipOption, NoticeVisbilityMode, PreviewBarOption, SponsorTime, StorageChangesObject, Keybind, HashedValue, VideoID, SponsorHideType } from "./types"; -import { keybindEquals } from "./utils/configUtils"; +import { isSafari, keybindEquals } from "./utils/configUtils"; export interface Permission { canSubmit: boolean; @@ -180,7 +180,7 @@ const Config: SBObject = { hideDiscordLaunches: 0, hideDiscordLink: false, invidiousInstances: ["invidious.snopyta.org"], // leave as default - supportInvidious: false, + supportInvidious: isSafari(), serverAddress: CompileConfig.serverAddress, minDuration: 0, skipNoticeDuration: 4, @@ -550,7 +550,8 @@ function migrateOldSyncFormats(config: SBConfig) { } // populate invidiousInstances with new instances if 3p support is **DISABLED** - if (!config["supportInvidious"] && config["invidiousInstances"].length !== invidiousList.length) { + // for safari, update it immediately + if ((isSafari() || !config["supportInvidious"]) && config["invidiousInstances"].length !== invidiousList.length) { config["invidiousInstances"] = invidiousList; } diff --git a/src/utils.ts b/src/utils.ts index 55bb2fc6..a9f98829 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -4,6 +4,7 @@ import { CategorySelection, SponsorTime, FetchResponse, BackgroundScriptContaine import * as CompileConfig from "../config.json"; import { findValidElement, findValidElementFromSelector } from "./utils/pageUtils"; import { waitFor } from "@ajayyy/maze-utils"; +import { isSafari } from "./utils/configUtils"; export default class Utils { @@ -236,6 +237,8 @@ export default class Utils { } containsInvidiousPermission(): Promise<boolean> { + if (isSafari()) return Promise.resolve(true); + return new Promise((resolve) => { let permissions = ["declarativeContent"]; if (this.isFirefox()) permissions = []; diff --git a/webpack/webpack.manifest.js b/webpack/webpack.manifest.js index 3e30ffc6..ebd4d967 100644 --- a/webpack/webpack.manifest.js +++ b/webpack/webpack.manifest.js @@ -3,6 +3,7 @@ const webpack = require("webpack"); const path = require('path'); const { validate } = require('schema-utils'); +const invidiousList = require("../ci/invidiouslist.json"); const fs = require('fs'); @@ -49,6 +50,11 @@ class BuildManifest { mergeObjects(manifest, chromeManifestExtra); } else if (this.options.browser.toLowerCase() === "safari") { 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") { |