mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-18 21:48:33 +03:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
faa3259165 | ||
|
|
c96bafb6f7 | ||
|
|
9b7680f0e6 | ||
|
|
16e01b7494 | ||
|
|
6cd697dc32 | ||
|
|
9946bd1af2 | ||
|
|
3b06d72270 | ||
|
|
4bd0556464 | ||
|
|
7e12a914d5 | ||
|
|
25eaf4fa20 | ||
|
|
b3efa1f787 | ||
|
|
9a18e70e34 | ||
|
|
64ece9cb73 | ||
|
|
66c974b011 | ||
|
|
d8cc93c841 | ||
|
|
de22accfda | ||
|
|
e5b0b60dde | ||
|
|
32d98e6544 | ||
|
|
3dde05eda2 | ||
|
|
6aeefaae64 | ||
|
|
93d695e6c2 | ||
|
|
160924feee | ||
|
|
e3f3ed20e6 | ||
|
|
52149f4c0f | ||
|
|
cbc586f9ac | ||
|
|
fc8e20be0d |
@@ -1,5 +1,8 @@
|
||||
If you make any contributions to SponsorBlock after this file was created, you are agreeing that any code you have contributed will be licensed under LGPL-3.0 or later.
|
||||
|
||||
# Translations
|
||||
https://crowdin.com/project/sponsorblock
|
||||
|
||||
# Building
|
||||
## Building locally
|
||||
0. You must have [Node.js 16 or later](https://nodejs.org/) and npm installed. Works best on Linux
|
||||
@@ -24,5 +27,5 @@ Run `npm run dev` (for Chrome) or `npm run dev:firefox` (for Firefox) to run the
|
||||
|
||||
Known chromium bug: Extension is not loaded properly on first start. Visit `chrome://extensions/` and reload the extension.
|
||||
|
||||
For Firefox for Android, use `npm run dev:firefox-android -- --adb-device <ip-address of the device>`. See the [Firefox documentation](https://extensionworkshop.com/documentation/develop/developing-extensions-for-firefox-for-android/#debug-your-extension) for more information.
|
||||
For Firefox for Android, use `npm run dev:firefox-android -- --adb-device <ip-address of the device>`. See the [Firefox documentation](https://extensionworkshop.com/documentation/develop/developing-extensions-for-firefox-for-android/#debug-your-extension) for more information. You may need to edit package.json and add the parameters directly there.
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"optional_permissions": [
|
||||
"declarativeContent"
|
||||
"declarativeContent",
|
||||
"webNavigation"
|
||||
],
|
||||
"background": {
|
||||
"persistent": false
|
||||
|
||||
@@ -3,5 +3,11 @@
|
||||
"gecko": {
|
||||
"id": "sponsorBlocker@ajay.app"
|
||||
}
|
||||
}
|
||||
},
|
||||
"background": {
|
||||
"persistent": false
|
||||
},
|
||||
"permissions": [
|
||||
"scripting"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "__MSG_fullName__",
|
||||
"short_name": "SponsorBlock",
|
||||
"version": "5.4.14",
|
||||
"version": "5.4.18",
|
||||
"default_locale": "en",
|
||||
"description": "__MSG_Description__",
|
||||
"homepage_url": "https://sponsor.ajay.app",
|
||||
@@ -84,8 +84,7 @@
|
||||
"https://sponsor.ajay.app/*"
|
||||
],
|
||||
"optional_permissions": [
|
||||
"*://*/*",
|
||||
"webNavigation"
|
||||
"*://*/*"
|
||||
],
|
||||
"browser_action": {
|
||||
"default_title": "SponsorBlock",
|
||||
@@ -116,6 +115,21 @@
|
||||
"light": "icons/IconSponsorBlocker128px.png",
|
||||
"dark": "icons/IconSponsorBlocker128px.png",
|
||||
"size": 128
|
||||
},
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker256px.png",
|
||||
"dark": "icons/IconSponsorBlocker256px.png",
|
||||
"size": 256
|
||||
},
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker512px.png",
|
||||
"dark": "icons/IconSponsorBlocker512px.png",
|
||||
"size": 512
|
||||
},
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker1024px.png",
|
||||
"dark": "icons/IconSponsorBlocker1024px.png",
|
||||
"size": 1024
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
{
|
||||
"background": {
|
||||
"persistent": false
|
||||
}
|
||||
},
|
||||
"permissions": [
|
||||
"scripting"
|
||||
],
|
||||
"optional_permissions": [
|
||||
"webNavigation"
|
||||
]
|
||||
}
|
||||
|
||||
Submodule maze-utils updated: b3572eaeff...79bef97a3b
105
package-lock.json
generated
105
package-lock.json
generated
@@ -27,7 +27,7 @@
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"content-scripts-register-polyfill": "^4.0.2",
|
||||
"@ajayyy/content-scripts-register-polyfill": "^4.0.2-safari-fix",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
@@ -65,6 +65,34 @@
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"node_modules/@ajayyy/content-scripts-register-polyfill": {
|
||||
"version": "4.0.2-safari-fix",
|
||||
"resolved": "https://registry.npmjs.org/@ajayyy/content-scripts-register-polyfill/-/content-scripts-register-polyfill-4.0.2-safari-fix.tgz",
|
||||
"integrity": "sha512-okyqlFmLUmOZQrkZ6ChUbfcNXadamlaIGqzb6fi5MRnzvr+myoG4sK+whxhCY9hPmU///dqMGtV8FVom8sJpHA==",
|
||||
"dependencies": {
|
||||
"@ajayyy/webext-content-scripts": "^2.5.4-safari-fix",
|
||||
"webext-patterns": "^1.3.0",
|
||||
"webext-polyfill-kinda": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fregante"
|
||||
}
|
||||
},
|
||||
"node_modules/@ajayyy/webext-content-scripts": {
|
||||
"version": "2.5.4-safari-fix",
|
||||
"resolved": "https://registry.npmjs.org/@ajayyy/webext-content-scripts/-/webext-content-scripts-2.5.4-safari-fix.tgz",
|
||||
"integrity": "sha512-gn1PF4+dfld6whvmjjnYGvB26z9ja0SNIcgHVQl42Bh/lz89hviH8HWqi1p7XXN/p0BsOwJAx8jzqkmb2IAQvQ==",
|
||||
"dependencies": {
|
||||
"webext-patterns": "^1.3.0",
|
||||
"webext-polyfill-kinda": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fregante"
|
||||
}
|
||||
},
|
||||
"node_modules/@ampproject/remapping": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz",
|
||||
@@ -4254,19 +4282,6 @@
|
||||
"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": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz",
|
||||
@@ -12960,18 +12975,6 @@
|
||||
"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",
|
||||
@@ -12995,9 +12998,9 @@
|
||||
}
|
||||
},
|
||||
"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==",
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/webext-polyfill-kinda/-/webext-polyfill-kinda-1.0.2.tgz",
|
||||
"integrity": "sha512-rqQUKeBTOicej0tjDJWDQlOTnDcm9yYJTzgI+7rMdyYV4QHmYMRm+yjkcVgECkg/Wu9MboZ4lYeBPdp1Ep9WgQ==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/fregante"
|
||||
}
|
||||
@@ -13575,6 +13578,25 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@ajayyy/content-scripts-register-polyfill": {
|
||||
"version": "4.0.2-safari-fix",
|
||||
"resolved": "https://registry.npmjs.org/@ajayyy/content-scripts-register-polyfill/-/content-scripts-register-polyfill-4.0.2-safari-fix.tgz",
|
||||
"integrity": "sha512-okyqlFmLUmOZQrkZ6ChUbfcNXadamlaIGqzb6fi5MRnzvr+myoG4sK+whxhCY9hPmU///dqMGtV8FVom8sJpHA==",
|
||||
"requires": {
|
||||
"@ajayyy/webext-content-scripts": "^2.5.4-safari-fix",
|
||||
"webext-patterns": "^1.3.0",
|
||||
"webext-polyfill-kinda": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"@ajayyy/webext-content-scripts": {
|
||||
"version": "2.5.4-safari-fix",
|
||||
"resolved": "https://registry.npmjs.org/@ajayyy/webext-content-scripts/-/webext-content-scripts-2.5.4-safari-fix.tgz",
|
||||
"integrity": "sha512-gn1PF4+dfld6whvmjjnYGvB26z9ja0SNIcgHVQl42Bh/lz89hviH8HWqi1p7XXN/p0BsOwJAx8jzqkmb2IAQvQ==",
|
||||
"requires": {
|
||||
"webext-patterns": "^1.3.0",
|
||||
"webext-polyfill-kinda": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"@ampproject/remapping": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz",
|
||||
@@ -16734,16 +16756,6 @@
|
||||
"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": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz",
|
||||
@@ -23095,15 +23107,6 @@
|
||||
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
|
||||
"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",
|
||||
@@ -23120,9 +23123,9 @@
|
||||
}
|
||||
},
|
||||
"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=="
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/webext-polyfill-kinda/-/webext-polyfill-kinda-1.0.2.tgz",
|
||||
"integrity": "sha512-rqQUKeBTOicej0tjDJWDQlOTnDcm9yYJTzgI+7rMdyYV4QHmYMRm+yjkcVgECkg/Wu9MboZ4lYeBPdp1Ep9WgQ=="
|
||||
},
|
||||
"webidl-conversions": {
|
||||
"version": "7.0.0",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "background.js",
|
||||
"dependencies": {
|
||||
"content-scripts-register-polyfill": "^4.0.2",
|
||||
"@ajayyy/content-scripts-register-polyfill": "^4.0.2-safari-fix",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
|
||||
Submodule public/_locales updated: 9e1f32d7c6...5528978f2f
@@ -2,7 +2,7 @@ import * as CompileConfig from "../config.json";
|
||||
|
||||
import Config from "./config";
|
||||
import { Registration } from "./types";
|
||||
import "content-scripts-register-polyfill";
|
||||
import "@ajayyy/content-scripts-register-polyfill";
|
||||
import { sendRealRequestToCustomServer, setupBackgroundRequestProxy } from "../maze-utils/src/background-request-proxy";
|
||||
import { setupTabUpdates } from "../maze-utils/src/tab-updates";
|
||||
import { generateUserID } from "../maze-utils/src/setup";
|
||||
@@ -16,6 +16,7 @@ import { getExtensionIdsToImportFrom } from "./utils/crossExtension";
|
||||
import { isFirefoxOrSafari } from "../maze-utils/src";
|
||||
import { injectUpdatedScripts } from "../maze-utils/src/cleanup";
|
||||
import { logWarn } from "./utils/logger";
|
||||
import { chromeP } from "../maze-utils/src/browserApi";
|
||||
const utils = new Utils({
|
||||
registerFirefoxContentScript,
|
||||
unregisterFirefoxContentScript
|
||||
@@ -27,7 +28,7 @@ const popupPort: Record<string, chrome.runtime.Port> = {};
|
||||
const contentScriptRegistrations = {};
|
||||
|
||||
// Register content script if needed
|
||||
utils.wait(() => Config.config !== null).then(function() {
|
||||
utils.wait(() => Config.isReady()).then(function() {
|
||||
if (Config.config.supportInvidious) utils.setupExtraSiteContentScripts();
|
||||
});
|
||||
|
||||
@@ -75,7 +76,11 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
|
||||
case "infoUpdated":
|
||||
case "videoChanged":
|
||||
if (sender.tab) {
|
||||
popupPort[sender.tab.id]?.postMessage(request);
|
||||
try {
|
||||
popupPort[sender.tab.id]?.postMessage(request);
|
||||
} catch (e) {
|
||||
// This can happen if the popup is closed
|
||||
}
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
@@ -148,27 +153,60 @@ chrome.runtime.onInstalled.addListener(function () {
|
||||
*
|
||||
* @param {JSON} options
|
||||
*/
|
||||
function registerFirefoxContentScript(options: Registration) {
|
||||
const oldRegistration = contentScriptRegistrations[options.id];
|
||||
if (oldRegistration) oldRegistration.unregister();
|
||||
async function registerFirefoxContentScript(options: Registration) {
|
||||
if ("scripting" in chrome && "getRegisteredContentScripts" in chrome.scripting) {
|
||||
const existingRegistrations = await chromeP.scripting.getRegisteredContentScripts({
|
||||
ids: [options.id]
|
||||
}).catch(() => []);
|
||||
|
||||
if (existingRegistrations.length > 0
|
||||
&& existingRegistrations[0].matches.every((match) => options.matches.includes(match))) {
|
||||
// No need to register another script, already registered
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await unregisterFirefoxContentScript(options.id);
|
||||
|
||||
if ("scripting" in chrome && "getRegisteredContentScripts" in chrome.scripting) {
|
||||
await chromeP.scripting.registerContentScripts([{
|
||||
id: options.id,
|
||||
runAt: "document_start",
|
||||
matches: options.matches,
|
||||
allFrames: options.allFrames,
|
||||
js: options.js,
|
||||
css: options.css,
|
||||
persistAcrossSessions: true,
|
||||
}]);
|
||||
} else {
|
||||
chrome.contentScripts.register({
|
||||
allFrames: options.allFrames,
|
||||
js: options.js?.map?.(file => ({file})),
|
||||
css: options.css?.map?.(file => ({file})),
|
||||
matches: options.matches
|
||||
}).then((registration) => void (contentScriptRegistrations[options.id] = registration));
|
||||
}
|
||||
|
||||
chrome.contentScripts.register({
|
||||
allFrames: options.allFrames,
|
||||
js: options.js,
|
||||
css: options.css,
|
||||
matches: options.matches
|
||||
}).then((registration) => void (contentScriptRegistrations[options.id] = registration));
|
||||
}
|
||||
|
||||
/**
|
||||
* Only works on Firefox.
|
||||
* Firefox requires that this is handled by the background script
|
||||
*
|
||||
*/
|
||||
function unregisterFirefoxContentScript(id: string) {
|
||||
if (contentScriptRegistrations[id]) {
|
||||
contentScriptRegistrations[id].unregister();
|
||||
delete contentScriptRegistrations[id];
|
||||
async function unregisterFirefoxContentScript(id: string) {
|
||||
if ("scripting" in chrome && "getRegisteredContentScripts" in chrome.scripting) {
|
||||
try {
|
||||
await chromeP.scripting.unregisterContentScripts({
|
||||
ids: [id]
|
||||
});
|
||||
} catch (e) {
|
||||
// Not registered yet
|
||||
}
|
||||
} else {
|
||||
if (contentScriptRegistrations[id]) {
|
||||
contentScriptRegistrations[id].unregister();
|
||||
delete contentScriptRegistrations[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -803,11 +803,12 @@ function incorrectVideoCheck(videoID?: string, sponsorTime?: SponsorTime): boole
|
||||
const currentVideoID = getYouTubeVideoID();
|
||||
const recordedVideoID = videoID || getVideoID();
|
||||
if (currentVideoID !== recordedVideoID || (sponsorTime
|
||||
&& (!sponsorTimes || !sponsorTimes?.some((time) => time.segment === sponsorTime.segment))
|
||||
&& !sponsorTimesSubmitting.some((time) => time.segment === sponsorTime.segment))) {
|
||||
&& (!sponsorTimes || !sponsorTimes?.some((time) => time.segment[0] === sponsorTime.segment[0] && time.segment[1] === sponsorTime.segment[1]))
|
||||
&& !sponsorTimesSubmitting.some((time) => time.segment[0] === sponsorTime.segment[0] && time.segment[1] === sponsorTime.segment[1]))) {
|
||||
// Something has really gone wrong
|
||||
console.error("[SponsorBlock] The videoID recorded when trying to skip is different than what it should be.");
|
||||
console.error("[SponsorBlock] VideoID recorded: " + recordedVideoID + ". Actual VideoID: " + currentVideoID);
|
||||
console.error("[SponsorBlock] SponsorTime", sponsorTime, "sponsorTimes", sponsorTimes, "sponsorTimesSubmitting", sponsorTimesSubmitting);
|
||||
|
||||
// Video ID change occured
|
||||
checkVideoIDChange();
|
||||
@@ -818,6 +819,8 @@ function incorrectVideoCheck(videoID?: string, sponsorTime?: SponsorTime): boole
|
||||
}
|
||||
}
|
||||
|
||||
let playbackRateCheckInterval: NodeJS.Timeout | null = null;
|
||||
let lastPlaybackSpeed = 1;
|
||||
let setupVideoListenersFirstTime = true;
|
||||
function setupVideoListeners() {
|
||||
//wait until it is loaded
|
||||
@@ -837,6 +840,16 @@ function setupVideoListeners() {
|
||||
let startedWaiting = false;
|
||||
let lastPausedAtZero = true;
|
||||
|
||||
const rateChangeListener = () => {
|
||||
updateVirtualTime();
|
||||
clearWaitingTime();
|
||||
|
||||
startSponsorSchedule();
|
||||
};
|
||||
getVideo().addEventListener('ratechange', rateChangeListener);
|
||||
// Used by videospeed extension (https://github.com/igrigorik/videospeed/pull/740)
|
||||
getVideo().addEventListener('videoSpeed_ratechange', rateChangeListener);
|
||||
|
||||
const playListener = () => {
|
||||
// If it is not the first event, then the only way to get to 0 is if there is a seek event
|
||||
// This check makes sure that changing the video resolution doesn't cause the extension to think it
|
||||
@@ -867,7 +880,6 @@ function setupVideoListeners() {
|
||||
|
||||
startSponsorSchedule();
|
||||
}
|
||||
|
||||
};
|
||||
getVideo().addEventListener('play', playListener);
|
||||
|
||||
@@ -897,6 +909,27 @@ function setupVideoListeners() {
|
||||
|
||||
startSponsorSchedule();
|
||||
}
|
||||
|
||||
if (playbackRateCheckInterval) clearInterval(playbackRateCheckInterval);
|
||||
lastPlaybackSpeed = getVideo().playbackRate;
|
||||
|
||||
// Video speed controller compatibility
|
||||
// That extension makes rate change events not propagate
|
||||
if (document.body.classList.contains("vsc-initialized")) {
|
||||
playbackRateCheckInterval = setInterval(() => {
|
||||
if ((!getVideoID() || getVideo().paused) && playbackRateCheckInterval) {
|
||||
// Video is gone, stop checking
|
||||
clearInterval(playbackRateCheckInterval);
|
||||
return;
|
||||
}
|
||||
|
||||
if (getVideo().playbackRate !== lastPlaybackSpeed) {
|
||||
lastPlaybackSpeed = getVideo().playbackRate;
|
||||
|
||||
rateChangeListener();
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
};
|
||||
getVideo().addEventListener('playing', playingListener);
|
||||
|
||||
@@ -927,21 +960,13 @@ function setupVideoListeners() {
|
||||
};
|
||||
getVideo().addEventListener('seeking', seekingListener);
|
||||
|
||||
const rateChangeListener = () => {
|
||||
updateVirtualTime();
|
||||
clearWaitingTime();
|
||||
|
||||
startSponsorSchedule();
|
||||
};
|
||||
getVideo().addEventListener('ratechange', () => rateChangeListener);
|
||||
// Used by videospeed extension (https://github.com/igrigorik/videospeed/pull/740)
|
||||
getVideo().addEventListener('videoSpeed_ratechange', rateChangeListener);
|
||||
|
||||
const stoppedPlayback = () => {
|
||||
// Reset lastCheckVideoTime
|
||||
lastCheckVideoTime = -1;
|
||||
lastCheckTime = 0;
|
||||
|
||||
if (playbackRateCheckInterval) clearInterval(playbackRateCheckInterval);
|
||||
|
||||
lastKnownVideoTime.videoTime = null;
|
||||
lastKnownVideoTime.preciseTime = null;
|
||||
updateWaitingTime();
|
||||
@@ -973,6 +998,8 @@ function setupVideoListeners() {
|
||||
getVideo().removeEventListener('videoSpeed_ratechange', rateChangeListener);
|
||||
getVideo().removeEventListener('pause', pauseListener);
|
||||
getVideo().removeEventListener('waiting', waitingListener);
|
||||
|
||||
if (playbackRateCheckInterval) clearInterval(playbackRateCheckInterval);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -784,11 +784,13 @@ class PreviewBar {
|
||||
if (!Config.config.showSegmentNameInChapterBar
|
||||
|| ((!segments || segments.length <= 0) && submittingSegments?.length <= 0)) {
|
||||
const chaptersContainer = this.getChaptersContainer();
|
||||
chaptersContainer.querySelector(".sponsorChapterText")?.remove();
|
||||
const chapterTitle = chaptersContainer.querySelector(".ytp-chapter-title-content") as HTMLDivElement;
|
||||
if (chaptersContainer) {
|
||||
chaptersContainer.querySelector(".sponsorChapterText")?.remove();
|
||||
const chapterTitle = chaptersContainer.querySelector(".ytp-chapter-title-content") as HTMLDivElement;
|
||||
|
||||
chapterTitle.style.removeProperty("display");
|
||||
chaptersContainer.classList.remove("sponsorblock-chapter-visible");
|
||||
chapterTitle.style.removeProperty("display");
|
||||
chaptersContainer.classList.remove("sponsorblock-chapter-visible");
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ export interface Registration {
|
||||
message: string;
|
||||
id: string;
|
||||
allFrames: boolean;
|
||||
js: browser.extensionTypes.ExtensionFileOrCode[];
|
||||
css: browser.extensionTypes.ExtensionFileOrCode[];
|
||||
js: string[];
|
||||
css: string[];
|
||||
matches: string[];
|
||||
}
|
||||
|
||||
|
||||
23
src/utils.ts
23
src/utils.ts
@@ -47,9 +47,13 @@ export default class Utils {
|
||||
* @param {CallableFunction} callback
|
||||
*/
|
||||
setupExtraSitePermissions(callback: (granted: boolean) => void): void {
|
||||
let permissions = ["webNavigation"];
|
||||
if (!isSafari()) permissions.push("declarativeContent");
|
||||
if (isFirefoxOrSafari() && !isSafari()) permissions = [];
|
||||
const permissions = [];
|
||||
if (!isFirefoxOrSafari()) {
|
||||
permissions.push("declarativeContent");
|
||||
}
|
||||
if (!isFirefoxOrSafari() || isSafari()) {
|
||||
permissions.push("webNavigation");
|
||||
}
|
||||
|
||||
chrome.permissions.request({
|
||||
origins: this.getPermissionRegex(),
|
||||
@@ -73,21 +77,12 @@ export default class Utils {
|
||||
* For now, it is just SB.config.invidiousInstances.
|
||||
*/
|
||||
setupExtraSiteContentScripts(): void {
|
||||
const firefoxJS = [];
|
||||
for (const file of this.js) {
|
||||
firefoxJS.push({file});
|
||||
}
|
||||
const firefoxCSS = [];
|
||||
for (const file of this.css) {
|
||||
firefoxCSS.push({file});
|
||||
}
|
||||
|
||||
const registration: Registration = {
|
||||
message: "registerContentScript",
|
||||
id: "invidious",
|
||||
allFrames: true,
|
||||
js: firefoxJS,
|
||||
css: firefoxCSS,
|
||||
js: this.js,
|
||||
css: this.css,
|
||||
matches: this.getPermissionRegex()
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user