mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 05:27:03 +03:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9a77355bb | ||
|
|
116190f2b3 | ||
|
|
4bbd59b988 | ||
|
|
5c279d80df | ||
|
|
f177b95a5a | ||
|
|
d86dd37ec0 | ||
|
|
fae7d921a7 | ||
|
|
60a2eff40a | ||
|
|
98a4a076bc | ||
|
|
a95020dda3 | ||
|
|
5e179cf9ff | ||
|
|
0b946d5ef7 | ||
|
|
f48c57b1c5 |
@@ -1,12 +1,156 @@
|
||||
{
|
||||
"optional_permissions": [
|
||||
"declarativeContent",
|
||||
"webNavigation"
|
||||
"host_permissions": [
|
||||
"https://*.youtube.com/*",
|
||||
"https://sponsor.ajay.app/*"
|
||||
],
|
||||
"background": {
|
||||
"persistent": false
|
||||
"optional_host_permissions": [
|
||||
"*://*/*"
|
||||
],
|
||||
"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/check-smaller.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/skip.svg",
|
||||
"icons/heart.svg",
|
||||
"icons/visible.svg",
|
||||
"icons/not_visible.svg",
|
||||
"icons/sort.svg",
|
||||
"icons/money.svg",
|
||||
"icons/segway.png",
|
||||
"icons/close-smaller.svg",
|
||||
"icons/right-arrow.svg",
|
||||
"icons/campaign.svg",
|
||||
"icons/star.svg",
|
||||
"icons/lightbulb.svg",
|
||||
"icons/bolt.svg",
|
||||
"icons/stopwatch.svg",
|
||||
"icons/music-note.svg",
|
||||
"icons/import.svg",
|
||||
"icons/export.svg",
|
||||
"icons/PlayerInfoIconSponsorBlocker.svg",
|
||||
"icons/PlayerDeleteIconSponsorBlocker.svg",
|
||||
"icons/dearrow.svg",
|
||||
"popup.html",
|
||||
"popup.css",
|
||||
"content.css",
|
||||
"shared.css",
|
||||
"js/document.js",
|
||||
"libs/Source+Sans+Pro.css",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwlxdu.woff2",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwmRduz8A.woff2",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwmBduz8A.woff2",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwlBduz8A.woff2"
|
||||
],
|
||||
"matches": ["<all_urls>"]
|
||||
}],
|
||||
"content_scripts": [
|
||||
{
|
||||
"world": "MAIN",
|
||||
"js": [
|
||||
"./js/document.js"
|
||||
],
|
||||
"matches": [
|
||||
"https://*.youtube.com/*",
|
||||
"https://www.youtube-nocookie.com/embed/*"
|
||||
],
|
||||
"exclude_matches": [
|
||||
"https://accounts.youtube.com/RotateCookiesPage*"
|
||||
],
|
||||
"all_frames": true,
|
||||
"run_at": "document_start"
|
||||
},
|
||||
{
|
||||
"world": "ISOLATED",
|
||||
"js": [
|
||||
"./js/content.js"
|
||||
],
|
||||
"css": [
|
||||
"content.css",
|
||||
"shared.css"
|
||||
],
|
||||
"matches": [
|
||||
"https://*.youtube.com/*",
|
||||
"https://www.youtube-nocookie.com/embed/*"
|
||||
],
|
||||
"exclude_matches": [
|
||||
"https://accounts.youtube.com/RotateCookiesPage*"
|
||||
],
|
||||
"all_frames": true,
|
||||
"run_at": "document_start"
|
||||
}
|
||||
],
|
||||
"action": {
|
||||
"default_title": "SponsorBlock",
|
||||
"default_popup": "popup.html",
|
||||
"default_icon": {
|
||||
"16": "icons/IconSponsorBlocker16px.png",
|
||||
"32": "icons/IconSponsorBlocker32px.png",
|
||||
"64": "icons/IconSponsorBlocker64px.png",
|
||||
"128": "icons/IconSponsorBlocker128px.png"
|
||||
},
|
||||
"theme_icons": [
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker16px.png",
|
||||
"dark": "icons/IconSponsorBlocker16px.png",
|
||||
"size": 16
|
||||
},
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker32px.png",
|
||||
"dark": "icons/IconSponsorBlocker32px.png",
|
||||
"size": 32
|
||||
},
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker64px.png",
|
||||
"dark": "icons/IconSponsorBlocker64px.png",
|
||||
"size": 64
|
||||
},
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
},
|
||||
"permissions": [
|
||||
"https://*.youtube.com/*"
|
||||
]
|
||||
"background": {
|
||||
"service_worker": "./js/background.js"
|
||||
},
|
||||
"manifest_version": 3
|
||||
}
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
"background": {
|
||||
"persistent": false
|
||||
},
|
||||
"permissions": [
|
||||
"scripting"
|
||||
],
|
||||
"browser_action": {
|
||||
"default_area": "navbar"
|
||||
}
|
||||
|
||||
136
manifest/manifest-v2-extra.json
Normal file
136
manifest/manifest-v2-extra.json
Normal file
@@ -0,0 +1,136 @@
|
||||
{
|
||||
"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/check-smaller.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/skip.svg",
|
||||
"icons/heart.svg",
|
||||
"icons/visible.svg",
|
||||
"icons/not_visible.svg",
|
||||
"icons/sort.svg",
|
||||
"icons/money.svg",
|
||||
"icons/segway.png",
|
||||
"icons/close-smaller.svg",
|
||||
"icons/right-arrow.svg",
|
||||
"icons/campaign.svg",
|
||||
"icons/star.svg",
|
||||
"icons/lightbulb.svg",
|
||||
"icons/bolt.svg",
|
||||
"icons/stopwatch.svg",
|
||||
"icons/music-note.svg",
|
||||
"icons/import.svg",
|
||||
"icons/export.svg",
|
||||
"icons/PlayerInfoIconSponsorBlocker.svg",
|
||||
"icons/PlayerDeleteIconSponsorBlocker.svg",
|
||||
"icons/dearrow.svg",
|
||||
"popup.html",
|
||||
"popup.css",
|
||||
"content.css",
|
||||
"shared.css",
|
||||
"js/document.js",
|
||||
"libs/Source+Sans+Pro.css",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwlxdu.woff2",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwmRduz8A.woff2",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwmBduz8A.woff2",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwlBduz8A.woff2"
|
||||
],
|
||||
"permissions": [
|
||||
"https://sponsor.ajay.app/*"
|
||||
],
|
||||
"optional_permissions": [
|
||||
"*://*/*"
|
||||
],
|
||||
"browser_action": {
|
||||
"default_title": "SponsorBlock",
|
||||
"default_popup": "popup.html",
|
||||
"default_icon": {
|
||||
"16": "icons/IconSponsorBlocker16px.png",
|
||||
"32": "icons/IconSponsorBlocker32px.png",
|
||||
"64": "icons/IconSponsorBlocker64px.png",
|
||||
"128": "icons/IconSponsorBlocker128px.png"
|
||||
},
|
||||
"theme_icons": [
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker16px.png",
|
||||
"dark": "icons/IconSponsorBlocker16px.png",
|
||||
"size": 16
|
||||
},
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker32px.png",
|
||||
"dark": "icons/IconSponsorBlocker32px.png",
|
||||
"size": 32
|
||||
},
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker64px.png",
|
||||
"dark": "icons/IconSponsorBlocker64px.png",
|
||||
"size": 64
|
||||
},
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
},
|
||||
"background": {
|
||||
"scripts":[
|
||||
"./js/background.js"
|
||||
]
|
||||
},
|
||||
"content_scripts": [{
|
||||
"run_at": "document_start",
|
||||
"matches": [
|
||||
"https://*.youtube.com/*",
|
||||
"https://www.youtube-nocookie.com/embed/*"
|
||||
],
|
||||
"exclude_matches": [
|
||||
"https://accounts.youtube.com/RotateCookiesPage*"
|
||||
],
|
||||
"all_frames": true,
|
||||
"js": [
|
||||
"./js/content.js"
|
||||
],
|
||||
"css": [
|
||||
"content.css",
|
||||
"shared.css"
|
||||
]
|
||||
}],
|
||||
"manifest_version": 2
|
||||
}
|
||||
@@ -1,141 +1,10 @@
|
||||
{
|
||||
"name": "__MSG_fullName__",
|
||||
"short_name": "SponsorBlock",
|
||||
"version": "5.6.1",
|
||||
"version": "5.7",
|
||||
"default_locale": "en",
|
||||
"description": "__MSG_Description__",
|
||||
"homepage_url": "https://sponsor.ajay.app",
|
||||
"content_scripts": [{
|
||||
"run_at": "document_start",
|
||||
"matches": [
|
||||
"https://*.youtube.com/*",
|
||||
"https://www.youtube-nocookie.com/embed/*"
|
||||
],
|
||||
"all_frames": true,
|
||||
"js": [
|
||||
"./js/content.js"
|
||||
],
|
||||
"css": [
|
||||
"content.css",
|
||||
"shared.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/check-smaller.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/skip.svg",
|
||||
"icons/heart.svg",
|
||||
"icons/visible.svg",
|
||||
"icons/not_visible.svg",
|
||||
"icons/sort.svg",
|
||||
"icons/money.svg",
|
||||
"icons/segway.png",
|
||||
"icons/close-smaller.svg",
|
||||
"icons/right-arrow.svg",
|
||||
"icons/campaign.svg",
|
||||
"icons/star.svg",
|
||||
"icons/lightbulb.svg",
|
||||
"icons/bolt.svg",
|
||||
"icons/stopwatch.svg",
|
||||
"icons/music-note.svg",
|
||||
"icons/import.svg",
|
||||
"icons/export.svg",
|
||||
"icons/PlayerInfoIconSponsorBlocker.svg",
|
||||
"icons/PlayerDeleteIconSponsorBlocker.svg",
|
||||
"icons/dearrow.svg",
|
||||
"popup.html",
|
||||
"popup.css",
|
||||
"content.css",
|
||||
"shared.css",
|
||||
"js/document.js",
|
||||
"libs/Source+Sans+Pro.css",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwlxdu.woff2",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwmRduz8A.woff2",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwmBduz8A.woff2",
|
||||
"libs/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwlBduz8A.woff2"
|
||||
],
|
||||
"permissions": [
|
||||
"storage",
|
||||
"https://sponsor.ajay.app/*"
|
||||
],
|
||||
"optional_permissions": [
|
||||
"*://*/*"
|
||||
],
|
||||
"browser_action": {
|
||||
"default_title": "SponsorBlock",
|
||||
"default_popup": "popup.html",
|
||||
"default_icon": {
|
||||
"16": "icons/IconSponsorBlocker16px.png",
|
||||
"32": "icons/IconSponsorBlocker32px.png",
|
||||
"64": "icons/IconSponsorBlocker64px.png",
|
||||
"128": "icons/IconSponsorBlocker128px.png"
|
||||
},
|
||||
"theme_icons": [
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker16px.png",
|
||||
"dark": "icons/IconSponsorBlocker16px.png",
|
||||
"size": 16
|
||||
},
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker32px.png",
|
||||
"dark": "icons/IconSponsorBlocker32px.png",
|
||||
"size": 32
|
||||
},
|
||||
{
|
||||
"light": "icons/IconSponsorBlocker64px.png",
|
||||
"dark": "icons/IconSponsorBlocker64px.png",
|
||||
"size": 64
|
||||
},
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
},
|
||||
"background": {
|
||||
"scripts":[
|
||||
"./js/background.js"
|
||||
]
|
||||
},
|
||||
"icons": {
|
||||
"16": "icons/IconSponsorBlocker16px.png",
|
||||
"32": "icons/IconSponsorBlocker32px.png",
|
||||
@@ -145,9 +14,12 @@
|
||||
"512": "icons/IconSponsorBlocker512px.png",
|
||||
"1024": "icons/IconSponsorBlocker1024px.png"
|
||||
},
|
||||
"permissions": [
|
||||
"storage",
|
||||
"scripting"
|
||||
],
|
||||
"options_ui": {
|
||||
"page": "options/options.html",
|
||||
"open_in_tab": true
|
||||
},
|
||||
"manifest_version": 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
"background": {
|
||||
"persistent": false
|
||||
},
|
||||
"permissions": [
|
||||
"scripting"
|
||||
],
|
||||
"optional_permissions": [
|
||||
"webNavigation"
|
||||
]
|
||||
|
||||
Submodule maze-utils updated: 6212c29b9e...3c7787897e
Submodule public/_locales updated: becf2e3f14...7cedce2158
@@ -7,13 +7,9 @@ import { sendRealRequestToCustomServer, setupBackgroundRequestProxy } from "../m
|
||||
import { setupTabUpdates } from "../maze-utils/src/tab-updates";
|
||||
import { generateUserID } from "../maze-utils/src/setup";
|
||||
|
||||
// Make the config public for debugging purposes
|
||||
|
||||
window.SB = Config;
|
||||
|
||||
import Utils from "./utils";
|
||||
import { getExtensionIdsToImportFrom } from "./utils/crossExtension";
|
||||
import { isFirefoxOrSafari } from "../maze-utils/src";
|
||||
import { isFirefoxOrSafari, waitFor } from "../maze-utils/src";
|
||||
import { injectUpdatedScripts } from "../maze-utils/src/cleanup";
|
||||
import { logWarn } from "./utils/logger";
|
||||
import { chromeP } from "../maze-utils/src/browserApi";
|
||||
@@ -142,9 +138,16 @@ chrome.runtime.onInstalled.addListener(function () {
|
||||
}
|
||||
}, 1500);
|
||||
|
||||
// Only do this once the old version understands how to clean itself up
|
||||
if (!isFirefoxOrSafari() && chrome.runtime.getManifest().version !== "5.4.13") {
|
||||
if (!isFirefoxOrSafari()) {
|
||||
injectUpdatedScripts().catch(logWarn);
|
||||
|
||||
waitFor(() => Config.isReady()).then(() => {
|
||||
if (Config.config.supportInvidious) {
|
||||
injectUpdatedScripts([
|
||||
utils.getExtraSiteRegistration()
|
||||
])
|
||||
}
|
||||
}).catch(logWarn);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import { downvoteButtonColor, SkipNoticeAction } from "../utils/noticeUtils";
|
||||
import { generateUserID } from "../../maze-utils/src/setup";
|
||||
import { keybindToString } from "../../maze-utils/src/config";
|
||||
import { getFormattedTime } from "../../maze-utils/src/formating";
|
||||
import { getCurrentTime, getVideo } from "../../maze-utils/src/video";
|
||||
|
||||
enum SkipButtonState {
|
||||
Undo, // Unskip
|
||||
@@ -685,7 +686,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
||||
getFullDurationCountdown(index: number): () => number {
|
||||
return () => {
|
||||
const sponsorTime = this.segments[index];
|
||||
const duration = Math.round((sponsorTime.segment[1] - this.contentContainer().v.currentTime) * (1 / this.contentContainer().v.playbackRate));
|
||||
const duration = Math.round((sponsorTime.segment[1] - getCurrentTime()) * (1 / getVideo().playbackRate));
|
||||
|
||||
return Math.max(duration, Config.config.skipNoticeDuration);
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ import { DEFAULT_CATEGORY } from "../utils/categoryUtils";
|
||||
import { getFormattedTime, getFormattedTimeToSeconds } from "../../maze-utils/src/formating";
|
||||
import { asyncRequestToServer } from "../utils/requests";
|
||||
import { defaultPreviewTime } from "../utils/constants";
|
||||
import { getVideo, getVideoDuration } from "../../maze-utils/src/video";
|
||||
|
||||
export interface SponsorTimeEditProps {
|
||||
index: number;
|
||||
@@ -401,7 +402,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
||||
checkToShowFullVideoWarning(): void {
|
||||
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
|
||||
const segmentDuration = sponsorTime.segment[1] - sponsorTime.segment[0];
|
||||
const videoPercentage = segmentDuration / this.props.contentContainer().v.duration;
|
||||
const videoPercentage = segmentDuration / getVideoDuration();
|
||||
|
||||
if (videoPercentage > 0.6 && !this.fullVideoWarningShown
|
||||
&& (sponsorTime.category === "sponsor" || sponsorTime.category === "selfpromo" || sponsorTime.category === "chooseACategory")) {
|
||||
@@ -553,7 +554,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
||||
}
|
||||
|
||||
setTimeToEnd(): void {
|
||||
this.setTimeTo(1, this.props.contentContainer().v.duration);
|
||||
this.setTimeTo(1, getVideoDuration());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -640,7 +641,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
||||
sponsorTimesSubmitting[this.props.index].segment[0] = startTime;
|
||||
}
|
||||
} else if (this.state.sponsorTimeEdits[1] === null && category === "outro" && !sponsorTimesSubmitting[this.props.index].segment[1]) {
|
||||
sponsorTimesSubmitting[this.props.index].segment[1] = this.props.contentContainer().v.duration;
|
||||
sponsorTimesSubmitting[this.props.index].segment[1] = getVideoDuration();
|
||||
this.props.contentContainer().updateEditButtonsOnPlayer();
|
||||
}
|
||||
|
||||
@@ -683,7 +684,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
||||
const endTime = sponsorTimes[index].segment[1];
|
||||
|
||||
// If segment starts at 0:00, start playback at the end of the segment
|
||||
const skipTime = (startTime === 0 || skipToEndTime) ? endTime : (startTime - (seekTime * this.props.contentContainer().v.playbackRate));
|
||||
const skipTime = (startTime === 0 || skipToEndTime) ? endTime : (startTime - (seekTime * getVideo().playbackRate));
|
||||
|
||||
this.props.contentContainer().previewTime(skipTime, !skipToEndTime);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import NoticeTextSelectionComponent from "./NoticeTextSectionComponent";
|
||||
import SponsorTimeEditComponent from "./SponsorTimeEditComponent";
|
||||
import { getGuidelineInfo } from "../utils/constants";
|
||||
import { exportTimes } from "../utils/exporter";
|
||||
import { getVideo, isCurrentTimeWrong } from "../../maze-utils/src/video";
|
||||
|
||||
export interface SubmissionNoticeProps {
|
||||
// Contains functions and variables from the content script needed by the skip notice
|
||||
@@ -66,7 +67,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
||||
this.forceUpdate();
|
||||
});
|
||||
|
||||
this.videoObserver.observe(this.contentContainer().v, {
|
||||
this.videoObserver.observe(getVideo(), {
|
||||
attributes: true
|
||||
});
|
||||
|
||||
@@ -131,7 +132,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
||||
{/* Sponsor Time List */}
|
||||
<tr id={"sponsorSkipNoticeMiddleRow" + this.state.idSuffix}
|
||||
className="sponsorTimeMessagesRow"
|
||||
style={{maxHeight: (this.contentContainer().v?.offsetHeight - 200) + "px"}}
|
||||
style={{maxHeight: (getVideo()?.offsetHeight - 200) + "px"}}
|
||||
onMouseDown={(e) => e.stopPropagation()}>
|
||||
<td style={{width: "100%"}}>
|
||||
{this.getSponsorTimeMessages()}
|
||||
@@ -215,6 +216,11 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
||||
}
|
||||
|
||||
submit(): void {
|
||||
if (isCurrentTimeWrong()) {
|
||||
alert(chrome.i18n.getMessage("submissionFailedServerSideAds"));
|
||||
return;
|
||||
}
|
||||
|
||||
// save all items
|
||||
for (const ref of this.timeEditRefs) {
|
||||
ref.current.saveEditTimes();
|
||||
@@ -283,7 +289,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
||||
categoryChangeListener(index: number, category: Category): void {
|
||||
const dialogWidth = this.noticeRef?.current?.getElement()?.current?.offsetWidth;
|
||||
if (category !== "chooseACategory" && Config.config.showCategoryGuidelines
|
||||
&& this.contentContainer().v.offsetWidth > dialogWidth * 2) {
|
||||
&& getVideo().offsetWidth > dialogWidth * 2) {
|
||||
const options = {
|
||||
title: chrome.i18n.getMessage(`category_${category}`),
|
||||
textBoxes: getGuidelineInfo(category),
|
||||
|
||||
141
src/content.ts
141
src/content.ts
@@ -34,7 +34,7 @@ import { ChapterVote } from "./render/ChapterVote";
|
||||
import { openWarningDialog } from "./utils/warnings";
|
||||
import { isFirefoxOrSafari, waitFor } from "../maze-utils/src";
|
||||
import { getErrorMessage, getFormattedTime } from "../maze-utils/src/formating";
|
||||
import { getChannelIDInfo, getVideo, getIsAdPlaying, getIsLivePremiere, setIsAdPlaying, checkVideoIDChange, getVideoID, getYouTubeVideoID, setupVideoModule, checkIfNewVideoID, isOnInvidious, isOnMobileYouTube, getLastNonInlineVideoID, triggerVideoIDChange, triggerVideoElementChange, getIsInline } from "../maze-utils/src/video";
|
||||
import { getChannelIDInfo, getVideo, getIsAdPlaying, getIsLivePremiere, setIsAdPlaying, checkVideoIDChange, getVideoID, getYouTubeVideoID, setupVideoModule, checkIfNewVideoID, isOnInvidious, isOnMobileYouTube, getLastNonInlineVideoID, triggerVideoIDChange, triggerVideoElementChange, getIsInline, getCurrentTime, setCurrentTime, getVideoDuration, verifyCurrentTime } from "../maze-utils/src/video";
|
||||
import { Keybind, StorageChangesObject, isSafari, keybindEquals, keybindToString } from "../maze-utils/src/config";
|
||||
import { findValidElement } from "../maze-utils/src/dom"
|
||||
import { getHash, HashedValue } from "../maze-utils/src/hash";
|
||||
@@ -127,7 +127,7 @@ setupVideoModule({
|
||||
updateVisibilityOfPlayerControlsButton();
|
||||
},
|
||||
resetValues,
|
||||
documentScript
|
||||
documentScript: chrome.runtime.getManifest().manifest_version === 2 ? documentScript : undefined
|
||||
}, () => Config);
|
||||
setupThumbnailListener();
|
||||
|
||||
@@ -177,7 +177,6 @@ const skipNoticeContentContainer: ContentContainer = () => ({
|
||||
sponsorTimes,
|
||||
sponsorTimesSubmitting,
|
||||
skipNotices,
|
||||
v: getVideo(),
|
||||
sponsorVideoID: getVideoID(),
|
||||
reskipSponsorTime,
|
||||
updatePreviewBar,
|
||||
@@ -218,7 +217,7 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
|
||||
found: sponsorDataFound,
|
||||
status: lastResponseStatus,
|
||||
sponsorTimes: sponsorTimes,
|
||||
time: getVideo()?.currentTime ?? 0,
|
||||
time: getCurrentTime() ?? 0,
|
||||
onMobileYouTube: isOnMobileYouTube()
|
||||
});
|
||||
|
||||
@@ -264,7 +263,9 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
|
||||
// it will assume the page is not a video page and stop the refresh animation
|
||||
sendResponse({ hasVideo: getVideoID() != null });
|
||||
// fetch segments
|
||||
sponsorsLookup(false);
|
||||
if (getVideoID()) {
|
||||
sponsorsLookup(false);
|
||||
}
|
||||
|
||||
break;
|
||||
case "unskip":
|
||||
@@ -296,7 +297,7 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
|
||||
navigator.clipboard.writeText(request.text);
|
||||
break;
|
||||
case "importSegments": {
|
||||
const importedSegments = importTimes(request.data, getVideo().duration);
|
||||
const importedSegments = importTimes(request.data, getVideoDuration());
|
||||
let addedSegments = false;
|
||||
for (const segment of importedSegments) {
|
||||
if (!sponsorTimesSubmitting.some(
|
||||
@@ -633,7 +634,7 @@ async function startSponsorSchedule(includeIntersectingSegments = false, current
|
||||
updateActiveSegment(currentTime);
|
||||
|
||||
if (getVideo().paused
|
||||
|| (getVideo().currentTime >= getVideo().duration - 0.01 && getVideo().duration > 1)) return;
|
||||
|| (getCurrentTime() >= getVideoDuration() - 0.01 && getVideoDuration() > 1)) return;
|
||||
const skipInfo = getNextSkipIndex(currentTime, includeIntersectingSegments, includeNonIntersectingSegments);
|
||||
|
||||
const currentSkip = skipInfo.array[skipInfo.index];
|
||||
@@ -683,7 +684,7 @@ async function startSponsorSchedule(includeIntersectingSegments = false, current
|
||||
let forcedIncludeNonIntersectingSegments = true;
|
||||
|
||||
if (incorrectVideoCheck(videoID, currentSkip)) return;
|
||||
forceVideoTime ||= Math.max(getVideo().currentTime, getVirtualTime());
|
||||
forceVideoTime ||= Math.max(getCurrentTime(), getVirtualTime());
|
||||
|
||||
if ((shouldSkip(currentSkip) || sponsorTimesSubmitting?.some((segment) => segment.segment === currentSkip.segment))) {
|
||||
if (forceVideoTime >= skipTime[0] - skipBuffer && forceVideoTime < skipTime[1]) {
|
||||
@@ -715,7 +716,7 @@ async function startSponsorSchedule(includeIntersectingSegments = false, current
|
||||
forcedIncludeNonIntersectingSegments = false;
|
||||
|
||||
// Only if not at the end of the video
|
||||
if (Math.abs(skipTime[1] - getVideo().duration) > endTimeSkipBuffer) {
|
||||
if (Math.abs(skipTime[1] - getVideoDuration()) > endTimeSkipBuffer) {
|
||||
forcedIncludeIntersectingSegments = true;
|
||||
}
|
||||
}
|
||||
@@ -746,38 +747,38 @@ async function startSponsorSchedule(includeIntersectingSegments = false, current
|
||||
|
||||
// Use interval instead of timeout near the end to combat imprecise video time
|
||||
const startIntervalTime = forceStartIntervalTime || performance.now();
|
||||
const startVideoTime = Math.max(currentTime, getVideo().currentTime);
|
||||
const startVideoTime = Math.max(currentTime, getCurrentTime());
|
||||
delayTime = (skipTime?.[0] - startVideoTime) * 1000 * (1 / getVideo().playbackRate);
|
||||
|
||||
let startWaitingForReportedTimeToChange = true;
|
||||
const reportedVideoTimeAtStart = getVideo().currentTime;
|
||||
logDebug(`Starting setInterval skipping ${getVideo().currentTime} to skip at ${skipTime[0]}`);
|
||||
const reportedVideoTimeAtStart = getCurrentTime();
|
||||
logDebug(`Starting setInterval skipping ${getCurrentTime()} to skip at ${skipTime[0]}`);
|
||||
|
||||
if (currentSkipInterval !== null) clearInterval(currentSkipInterval);
|
||||
currentSkipInterval = setInterval(() => {
|
||||
// Estimate delay, but only take the current time right after a change
|
||||
// Current time remains the same for many "frames" on Firefox
|
||||
if (isFirefoxOrSafari() && !lastKnownVideoTime.fromPause && startWaitingForReportedTimeToChange
|
||||
&& reportedVideoTimeAtStart !== getVideo().currentTime) {
|
||||
&& reportedVideoTimeAtStart !== getCurrentTime()) {
|
||||
startWaitingForReportedTimeToChange = false;
|
||||
const delay = getVirtualTime() - getVideo().currentTime;
|
||||
const delay = getVirtualTime() - getCurrentTime();
|
||||
if (delay > 0) lastKnownVideoTime.approximateDelay = delay;
|
||||
}
|
||||
|
||||
const intervalDuration = performance.now() - startIntervalTime;
|
||||
if (intervalDuration + skipBuffer * 1000 >= delayTime || getVideo().currentTime >= skipTime[0]) {
|
||||
if (intervalDuration + skipBuffer * 1000 >= delayTime || getCurrentTime() >= skipTime[0]) {
|
||||
clearInterval(currentSkipInterval);
|
||||
if (!isFirefoxOrSafari() && !getVideo().muted && !inMuteSegment(getVideo().currentTime, true)) {
|
||||
if (!isFirefoxOrSafari() && !getVideo().muted && !inMuteSegment(getCurrentTime(), true)) {
|
||||
// Workaround for more accurate skipping on Chromium
|
||||
getVideo().muted = true;
|
||||
getVideo().muted = false;
|
||||
}
|
||||
|
||||
skippingFunction(Math.max(getVideo().currentTime, startVideoTime + getVideo().playbackRate * Math.max(delayTime, intervalDuration) / 1000));
|
||||
skippingFunction(Math.max(getCurrentTime(), startVideoTime + getVideo().playbackRate * Math.max(delayTime, intervalDuration) / 1000));
|
||||
}
|
||||
}, 0);
|
||||
} else {
|
||||
logDebug(`Starting timeout to skip ${getVideo().currentTime} to skip at ${skipTime[0]}`);
|
||||
logDebug(`Starting timeout to skip ${getCurrentTime()} to skip at ${skipTime[0]}`);
|
||||
|
||||
const offset = (isFirefoxOrSafari() && !isSafari() ? 600 : 150);
|
||||
// Schedule for right before to be more precise than normal timeout
|
||||
@@ -801,10 +802,10 @@ function getVirtualTime(): number {
|
||||
(performance.now() - lastKnownVideoTime.preciseTime) * getVideo().playbackRate / 1000 + lastKnownVideoTime.videoTime : null);
|
||||
|
||||
if (Config.config.useVirtualTime && !isSafari() && virtualTime
|
||||
&& Math.abs(virtualTime - getVideo().currentTime) < 0.2 && getVideo().currentTime !== 0) {
|
||||
return Math.max(virtualTime, getVideo().currentTime);
|
||||
&& Math.abs(virtualTime - getCurrentTime()) < 0.2 && getCurrentTime() !== 0) {
|
||||
return Math.max(virtualTime, getCurrentTime());
|
||||
} else {
|
||||
return getVideo().currentTime;
|
||||
return getCurrentTime();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -971,15 +972,15 @@ function setupVideoListeners() {
|
||||
clearWaitingTime();
|
||||
|
||||
// Sometimes looped videos loop back to almost zero, but not quite
|
||||
if (video.loop && video.currentTime < 0.2) {
|
||||
if (video.loop && video.currentTime < 0.2 && getCurrentTime() < 0.2) {
|
||||
startSponsorSchedule(false, 0);
|
||||
} else {
|
||||
startSponsorSchedule();
|
||||
}
|
||||
} else {
|
||||
updateActiveSegment(video.currentTime);
|
||||
updateActiveSegment(getCurrentTime());
|
||||
|
||||
if (video.currentTime === 0) {
|
||||
if (getCurrentTime() === 0) {
|
||||
lastPausedAtZero = true;
|
||||
}
|
||||
}
|
||||
@@ -1036,7 +1037,7 @@ function setupVideoListeners() {
|
||||
function updateVirtualTime() {
|
||||
if (currentVirtualTimeInterval) clearInterval(currentVirtualTimeInterval);
|
||||
|
||||
lastKnownVideoTime.videoTime = getVideo().currentTime;
|
||||
lastKnownVideoTime.videoTime = getCurrentTime();
|
||||
lastKnownVideoTime.preciseTime = performance.now();
|
||||
|
||||
// If on Firefox, wait for the second time change (time remains fixed for many "frames" for privacy reasons)
|
||||
@@ -1048,21 +1049,21 @@ function updateVirtualTime() {
|
||||
|
||||
currentVirtualTimeInterval = setInterval(() => {
|
||||
const frameTime = performance.now() - lastPerformanceTime;
|
||||
if (lastTime !== getVideo().currentTime) {
|
||||
if (lastTime !== getCurrentTime()) {
|
||||
rawCount++;
|
||||
|
||||
// If there is lag, give it another shot at finding a good change time
|
||||
if (frameTime < 20 || rawCount > 30) {
|
||||
count++;
|
||||
}
|
||||
lastTime = getVideo().currentTime;
|
||||
lastTime = getCurrentTime();
|
||||
}
|
||||
|
||||
if (count > 1) {
|
||||
const delay = lastKnownVideoTime.fromPause && lastKnownVideoTime.approximateDelay ?
|
||||
lastKnownVideoTime.approximateDelay : 0;
|
||||
|
||||
lastKnownVideoTime.videoTime = getVideo().currentTime + delay;
|
||||
lastKnownVideoTime.videoTime = getCurrentTime() + delay;
|
||||
lastKnownVideoTime.preciseTime = performance.now();
|
||||
|
||||
clearInterval(currentVirtualTimeInterval);
|
||||
@@ -1115,7 +1116,12 @@ async function sponsorsLookup(keepOldSubmissions = true) {
|
||||
const hashParams = getHashParams();
|
||||
if (hashParams.requiredSegment) extraRequestData.requiredSegment = hashParams.requiredSegment;
|
||||
|
||||
const hashPrefix = (await getHash(getVideoID(), 1)).slice(0, 4) as VideoID & HashedValue;
|
||||
const videoID = getVideoID()
|
||||
if (!videoID) {
|
||||
console.error("[SponsorBlock] Attempted to fetch segments with a null/undefined videoID.");
|
||||
return;
|
||||
}
|
||||
const hashPrefix = (await getHash(videoID, 1)).slice(0, 4) as VideoID & HashedValue;
|
||||
const response = await asyncRequestToServer('GET', "/api/skipSegments/" + hashPrefix, {
|
||||
categories,
|
||||
actionTypes: getEnabledActionTypes(),
|
||||
@@ -1192,7 +1198,7 @@ async function sponsorsLookup(keepOldSubmissions = true) {
|
||||
|
||||
startSkipScheduleCheckingForStartSponsors();
|
||||
|
||||
if (!isNaN(getVideo().duration)) {
|
||||
if (!isNaN(getVideoDuration())) {
|
||||
updatePreviewBar();
|
||||
}
|
||||
} else {
|
||||
@@ -1210,7 +1216,7 @@ async function sponsorsLookup(keepOldSubmissions = true) {
|
||||
found: sponsorDataFound,
|
||||
status: lastResponseStatus,
|
||||
sponsorTimes: sponsorTimes,
|
||||
time: getVideo()?.currentTime ?? 0,
|
||||
time: getCurrentTime() ?? 0,
|
||||
onMobileYouTube: isOnMobileYouTube()
|
||||
});
|
||||
|
||||
@@ -1221,7 +1227,7 @@ async function sponsorsLookup(keepOldSubmissions = true) {
|
||||
|
||||
function importExistingChapters(wait: boolean) {
|
||||
if (!existingChaptersImported && !importingChaptersWaiting && !triedImportingChapters && onVideoPage() && !isOnMobileYouTube()) {
|
||||
const waitCondition = () => getVideo()?.duration && getExistingChapters(getVideoID(), getVideo().duration);
|
||||
const waitCondition = () => getVideoDuration() && getExistingChapters(getVideoID(), getVideoDuration());
|
||||
|
||||
if (wait && !document.hasFocus() && !importingChaptersWaitingForFocus && !waitCondition()) {
|
||||
importingChaptersWaitingForFocus = true;
|
||||
@@ -1305,7 +1311,7 @@ function startSkipScheduleCheckingForStartSponsors() {
|
||||
let startingSegmentTime = getStartTimeFromUrl(document.URL) || -1;
|
||||
let found = false;
|
||||
for (const time of sponsorTimes) {
|
||||
if (time.segment[0] <= getVideo().currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > getVideo().currentTime
|
||||
if (time.segment[0] <= getCurrentTime() && time.segment[0] > startingSegmentTime && time.segment[1] > getCurrentTime()
|
||||
&& time.actionType !== ActionType.Poi) {
|
||||
startingSegmentTime = time.segment[0];
|
||||
found = true;
|
||||
@@ -1314,7 +1320,7 @@ function startSkipScheduleCheckingForStartSponsors() {
|
||||
}
|
||||
if (!found) {
|
||||
for (const time of sponsorTimesSubmitting) {
|
||||
if (time.segment[0] <= getVideo().currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > getVideo().currentTime
|
||||
if (time.segment[0] <= getCurrentTime() && time.segment[0] > startingSegmentTime && time.segment[1] > getCurrentTime()
|
||||
&& time.actionType !== ActionType.Poi) {
|
||||
startingSegmentTime = time.segment[0];
|
||||
found = true;
|
||||
@@ -1325,7 +1331,7 @@ function startSkipScheduleCheckingForStartSponsors() {
|
||||
|
||||
// For highlight category
|
||||
const poiSegments = sponsorTimes
|
||||
.filter((time) => time.segment[1] > getVideo().currentTime
|
||||
.filter((time) => time.segment[1] > getCurrentTime()
|
||||
&& time.actionType === ActionType.Poi && time.hidden === SponsorHideType.Visible)
|
||||
.sort((a, b) => b.segment[0] - a.segment[0]);
|
||||
for (const time of poiSegments) {
|
||||
@@ -1336,7 +1342,7 @@ function startSkipScheduleCheckingForStartSponsors() {
|
||||
skipTime: time.segment,
|
||||
skippingSegments: [time],
|
||||
openNotice: true,
|
||||
unskipTime: getVideo().currentTime
|
||||
unskipTime: getCurrentTime()
|
||||
});
|
||||
if (skipOption === CategorySkipOption.AutoSkip) break;
|
||||
}
|
||||
@@ -1403,8 +1409,8 @@ function updatePreviewBar(): void {
|
||||
});
|
||||
});
|
||||
|
||||
previewBar.set(previewBarSegments.filter((segment) => segment.actionType !== ActionType.Full), getVideo()?.duration)
|
||||
if (getVideo()) updateActiveSegment(getVideo().currentTime);
|
||||
previewBar.set(previewBarSegments.filter((segment) => segment.actionType !== ActionType.Full), getVideoDuration())
|
||||
if (getVideo()) updateActiveSegment(getCurrentTime());
|
||||
|
||||
if (Config.config.showTimeWithSkips) {
|
||||
const skippedDuration = utils.getTimestampsDuration(previewBarSegments
|
||||
@@ -1631,7 +1637,7 @@ function getStartTimes(sponsorTimes: SponsorTime[], includeIntersectingSegments:
|
||||
*/
|
||||
function previewTime(time: number, unpause = true) {
|
||||
previewedSegment = true;
|
||||
getVideo().currentTime = time;
|
||||
setCurrentTime(time);
|
||||
|
||||
// Unpause the video if needed
|
||||
if (unpause && getVideo().paused){
|
||||
@@ -1677,22 +1683,22 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u
|
||||
const isSubmittingSegment = sponsorTimesSubmitting.some((time) => time.segment === skippingSegments[0].segment);
|
||||
|
||||
if ((autoSkip || isSubmittingSegment)
|
||||
&& v.currentTime !== skipTime[1]) {
|
||||
&& getCurrentTime() !== skipTime[1]) {
|
||||
switch(skippingSegments[0].actionType) {
|
||||
case ActionType.Poi:
|
||||
case ActionType.Skip: {
|
||||
// Fix for looped videos not working when skipping to the end #426
|
||||
// for some reason you also can't skip to 1 second before the end
|
||||
if (v.loop && v.duration > 1 && skipTime[1] >= v.duration - 1) {
|
||||
v.currentTime = 0;
|
||||
} else if (v.duration > 1 && skipTime[1] >= v.duration
|
||||
if (v.loop && getVideoDuration() > 1 && skipTime[1] >= getVideoDuration() - 1) {
|
||||
setCurrentTime(0);
|
||||
} else if (getVideoDuration() > 1 && skipTime[1] >= getVideoDuration()
|
||||
&& (navigator.vendor === "Apple Computer, Inc." || isPlayingPlaylist())) {
|
||||
// MacOS will loop otherwise #1027
|
||||
// Sometimes playlists loop too #1804
|
||||
v.currentTime = v.duration - 0.001;
|
||||
} else if (v.duration > 1 && Math.abs(skipTime[1] - v.duration) < endTimeSkipBuffer
|
||||
setCurrentTime(getVideoDuration() - 0.001);
|
||||
} else if (getVideoDuration() > 1 && Math.abs(skipTime[1] - getVideoDuration()) < endTimeSkipBuffer
|
||||
&& isFirefoxOrSafari() && !isSafari()) {
|
||||
v.currentTime = v.duration;
|
||||
setCurrentTime(getVideoDuration());
|
||||
} else {
|
||||
if (inMuteSegment(skipTime[1], true)) {
|
||||
// Make sure not to mute if skipping into a mute segment
|
||||
@@ -1700,7 +1706,7 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u
|
||||
videoMuted = true;
|
||||
}
|
||||
|
||||
v.currentTime = skipTime[1];
|
||||
setCurrentTime(skipTime[1]);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1785,7 +1791,7 @@ function unskipSponsorTime(segment: SponsorTime, unskipTime: number = null, forc
|
||||
|
||||
if (forceSeek || segment.actionType === ActionType.Skip) {
|
||||
//add a tiny bit of time to make sure it is not skipped again
|
||||
getVideo().currentTime = unskipTime ?? segment.segment[0] + 0.001;
|
||||
setCurrentTime(unskipTime ?? segment.segment[0] + 0.001);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1795,11 +1801,11 @@ function reskipSponsorTime(segment: SponsorTime, forceSeek = false) {
|
||||
getVideo().muted = true;
|
||||
videoMuted = true;
|
||||
} else {
|
||||
const skippedTime = Math.max(segment.segment[1] - getVideo().currentTime, 0);
|
||||
const skippedTime = Math.max(segment.segment[1] - getCurrentTime(), 0);
|
||||
const segmentDuration = segment.segment[1] - segment.segment[0];
|
||||
const fullSkip = skippedTime / segmentDuration > manualSkipPercentCount;
|
||||
|
||||
getVideo().currentTime = segment.segment[1];
|
||||
setCurrentTime(segment.segment[1]);
|
||||
sendTelemetryAndCount([segment], segment.actionType !== ActionType.Chapter ? skippedTime : 0, fullSkip);
|
||||
startSponsorSchedule(true, segment.segment[1], false);
|
||||
}
|
||||
@@ -1949,13 +1955,14 @@ function getRealCurrentTime(): number {
|
||||
|
||||
if (playButtonSVGData === replaceSVGData) {
|
||||
// At the end of the video
|
||||
return getVideo()?.duration;
|
||||
return getVideoDuration();
|
||||
} else {
|
||||
return getVideo().currentTime;
|
||||
return getCurrentTime();
|
||||
}
|
||||
}
|
||||
|
||||
function startOrEndTimingNewSegment() {
|
||||
verifyCurrentTime();
|
||||
const roundedTime = Math.round((getRealCurrentTime() + Number.EPSILON) * 1000) / 1000;
|
||||
if (!isSegmentCreationInProgress()) {
|
||||
sponsorTimesSubmitting.push({
|
||||
@@ -2330,7 +2337,7 @@ async function sendSubmitMessage(): Promise<boolean> {
|
||||
if (!previewedSegment
|
||||
&& !sponsorTimesSubmitting.every((segment) =>
|
||||
[ActionType.Full, ActionType.Chapter, ActionType.Poi].includes(segment.actionType)
|
||||
|| segment.segment[1] >= getVideo()?.duration
|
||||
|| segment.segment[1] >= getVideoDuration()
|
||||
|| segment.segment[0] === 0)) {
|
||||
alert(`${chrome.i18n.getMessage("previewSegmentRequired")} ${keybindToString(Config.config.previewKeybind)}`);
|
||||
return false;
|
||||
@@ -2342,8 +2349,8 @@ async function sendSubmitMessage(): Promise<boolean> {
|
||||
|
||||
//check if a sponsor exceeds the duration of the video
|
||||
for (let i = 0; i < sponsorTimesSubmitting.length; i++) {
|
||||
if (sponsorTimesSubmitting[i].segment[1] > getVideo().duration) {
|
||||
sponsorTimesSubmitting[i].segment[1] = getVideo().duration;
|
||||
if (sponsorTimesSubmitting[i].segment[1] > getVideoDuration()) {
|
||||
sponsorTimesSubmitting[i].segment[1] = getVideoDuration();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2368,7 +2375,7 @@ async function sendSubmitMessage(): Promise<boolean> {
|
||||
videoID: getVideoID(),
|
||||
userID: Config.config.userID,
|
||||
segments: sponsorTimesSubmitting,
|
||||
videoDuration: getVideo()?.duration,
|
||||
videoDuration: getVideoDuration(),
|
||||
userAgent: `${chrome.runtime.id}/v${chrome.runtime.getManifest().version}`
|
||||
});
|
||||
|
||||
@@ -2461,38 +2468,38 @@ function nextChapter(): void {
|
||||
const chapters = previewBar.unfilteredChapterGroups?.filter((time) => [ActionType.Chapter, null].includes(time.actionType));
|
||||
if (!chapters || chapters.length <= 0) return;
|
||||
|
||||
lastNextChapterKeybind.time = getVideo().currentTime;
|
||||
lastNextChapterKeybind.time = getCurrentTime();
|
||||
lastNextChapterKeybind.date = Date.now();
|
||||
|
||||
const nextChapter = chapters.findIndex((time) => time.segment[0] > getVideo().currentTime);
|
||||
const nextChapter = chapters.findIndex((time) => time.segment[0] > getCurrentTime());
|
||||
if (nextChapter !== -1) {
|
||||
getVideo().currentTime = chapters[nextChapter].segment[0];
|
||||
setCurrentTime(chapters[nextChapter].segment[0]);
|
||||
} else {
|
||||
getVideo().currentTime = getVideo().duration;
|
||||
setCurrentTime(getVideoDuration());
|
||||
}
|
||||
}
|
||||
|
||||
function previousChapter(): void {
|
||||
if (Date.now() - lastNextChapterKeybind.date < 3000) {
|
||||
getVideo().currentTime = lastNextChapterKeybind.time;
|
||||
setCurrentTime(lastNextChapterKeybind.time);
|
||||
lastNextChapterKeybind.date = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const chapters = previewBar.unfilteredChapterGroups?.filter((time) => [ActionType.Chapter, null].includes(time.actionType));
|
||||
if (!chapters || chapters.length <= 0) {
|
||||
getVideo().currentTime = 0;
|
||||
setCurrentTime(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// subtract 5 seconds to allow skipping back to the previous chapter if close to start of
|
||||
// the current one
|
||||
const nextChapter = chapters.findIndex((time) => time.segment[0] > getVideo().currentTime - Math.min(5, time.segment[1] - time.segment[0]));
|
||||
const nextChapter = chapters.findIndex((time) => time.segment[0] > getCurrentTime() - Math.min(5, time.segment[1] - time.segment[0]));
|
||||
const previousChapter = nextChapter !== -1 ? (nextChapter - 1) : (chapters.length - 1);
|
||||
if (previousChapter !== -1) {
|
||||
getVideo().currentTime = chapters[previousChapter].segment[0];
|
||||
setCurrentTime(chapters[previousChapter].segment[0]);
|
||||
} else {
|
||||
getVideo().currentTime = 0;
|
||||
setCurrentTime(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2653,7 +2660,7 @@ function showTimeWithoutSkips(skippedDuration: number): void {
|
||||
display.appendChild(duration);
|
||||
}
|
||||
|
||||
const durationAfterSkips = getFormattedTime(getVideo()?.duration - skippedDuration);
|
||||
const durationAfterSkips = getFormattedTime(getVideoDuration() - skippedDuration);
|
||||
|
||||
duration.innerText = (durationAfterSkips == null || skippedDuration <= 0) ? "" : " (" + durationAfterSkips + ")";
|
||||
}
|
||||
@@ -2733,4 +2740,4 @@ function checkForMiniplayerPlaying() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
src/globals.d.ts
vendored
15
src/globals.d.ts
vendored
@@ -1,19 +1,4 @@
|
||||
import { SBObject } from "./config";
|
||||
declare global {
|
||||
interface Window { SB: SBObject }
|
||||
// Remove this once the API becomes stable and types are shipped in @types/chrome
|
||||
namespace chrome {
|
||||
namespace declarativeContent {
|
||||
export interface RequestContentScriptOptions {
|
||||
allFrames?: boolean;
|
||||
css?: string[];
|
||||
instanceType?: "declarativeContent.RequestContentScript";
|
||||
js?: string[];
|
||||
matchAboutBlanck?: boolean;
|
||||
}
|
||||
export class RequestContentScript {
|
||||
constructor(options: RequestContentScriptOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
14
src/popup.ts
14
src/popup.ts
@@ -303,7 +303,7 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
||||
PageElements.showNoticeAgain.style.display = "unset";
|
||||
}
|
||||
|
||||
const values = ["userName", "viewCount", "minutesSaved", "vip", "permissions"];
|
||||
const values = ["userName", "viewCount", "minutesSaved", "vip", "permissions", "segmentCount"];
|
||||
|
||||
asyncRequestToServer("GET", "/api/userInfo", {
|
||||
publicUserID: await getHash(Config.config.userID),
|
||||
@@ -336,16 +336,18 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
||||
PageElements.sponsorTimesOthersTimeSavedDisplay.innerText = getFormattedHours(minutesSaved);
|
||||
}
|
||||
|
||||
//get the amount of times this user has contributed and display it to thank them
|
||||
PageElements.sponsorTimesContributionsDisplay.innerText = Math.max(Config.config.sponsorTimesContributed ?? 0, userInfo.segmentCount).toLocaleString();
|
||||
PageElements.sponsorTimesContributionsContainer.classList.remove("hidden");
|
||||
|
||||
PageElements.sponsorTimesOthersTimeSavedEndWord.innerText = chrome.i18n.getMessage("minsLower");
|
||||
|
||||
Config.config.isVip = userInfo.vip;
|
||||
Config.config.permissions = userInfo.permissions;
|
||||
}
|
||||
});
|
||||
|
||||
//get the amount of times this user has contributed and display it to thank them
|
||||
if (Config.config.sponsorTimesContributed != undefined) {
|
||||
PageElements.sponsorTimesContributionsDisplay.innerText = Config.config.sponsorTimesContributed.toLocaleString();
|
||||
PageElements.sponsorTimesContributionsContainer.classList.remove("hidden");
|
||||
}
|
||||
|
||||
|
||||
//get the amount of times this user has skipped a sponsor
|
||||
if (Config.config.skipCount != undefined) {
|
||||
|
||||
@@ -8,6 +8,7 @@ const utils = new Utils();
|
||||
import { ContentContainer } from "../types";
|
||||
import NoticeTextSelectionComponent from "../components/NoticeTextSectionComponent";
|
||||
import { ButtonListener } from "../../maze-utils/src/components/component-types";
|
||||
import { getVideo } from "../../maze-utils/src/video";
|
||||
|
||||
export interface TextBox {
|
||||
icon: string;
|
||||
@@ -75,7 +76,7 @@ export default class GenericNotice {
|
||||
{options.textBoxes?.length > 0 ?
|
||||
<tr id={"sponsorSkipNoticeMiddleRow" + this.idSuffix}
|
||||
className="sponsorTimeMessagesRow"
|
||||
style={{maxHeight: this.contentContainer ? (this.contentContainer().v.offsetHeight - 200) + "px" : null}}>
|
||||
style={{maxHeight: getVideo() ? (getVideo().offsetHeight - 200) + "px" : null}}>
|
||||
<td style={{width: "100%"}}>
|
||||
{this.getMessageBoxes(this.idSuffix, options.textBoxes)}
|
||||
</td>
|
||||
|
||||
@@ -10,7 +10,6 @@ export interface ContentContainer {
|
||||
sponsorTimes: SponsorTime[];
|
||||
sponsorTimesSubmitting: SponsorTime[];
|
||||
skipNotices: SkipNotice[];
|
||||
v: HTMLVideoElement;
|
||||
sponsorVideoID;
|
||||
reskipSponsorTime: (segment: SponsorTime, forceSeek?: boolean) => void;
|
||||
updatePreviewBar: () => void;
|
||||
|
||||
38
src/utils.ts
38
src/utils.ts
@@ -2,7 +2,7 @@ import Config, { VideoDownvotes } from "./config";
|
||||
import { CategorySelection, SponsorTime, BackgroundScriptContainer, Registration, VideoID, SponsorHideType, CategorySkipOption } from "./types";
|
||||
|
||||
import { getHash, HashedValue } from "../maze-utils/src/hash";
|
||||
import { isFirefoxOrSafari, waitFor } from "../maze-utils/src";
|
||||
import { waitFor } from "../maze-utils/src";
|
||||
import { findValidElementFromSelector } from "../maze-utils/src/dom";
|
||||
import { isSafari } from "../maze-utils/src/config";
|
||||
|
||||
@@ -46,10 +46,7 @@ export default class Utils {
|
||||
*/
|
||||
setupExtraSitePermissions(callback: (granted: boolean) => void): void {
|
||||
const permissions = [];
|
||||
if (!isFirefoxOrSafari()) {
|
||||
permissions.push("declarativeContent");
|
||||
}
|
||||
if (!isFirefoxOrSafari() || isSafari()) {
|
||||
if (isSafari()) {
|
||||
permissions.push("webNavigation");
|
||||
}
|
||||
|
||||
@@ -67,6 +64,17 @@ export default class Utils {
|
||||
});
|
||||
}
|
||||
|
||||
getExtraSiteRegistration(): Registration {
|
||||
return {
|
||||
message: "registerContentScript",
|
||||
id: "invidious",
|
||||
allFrames: true,
|
||||
js: this.js,
|
||||
css: this.css,
|
||||
matches: this.getPermissionRegex()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the content scripts for the extra sites.
|
||||
* Will use a different method depending on the browser.
|
||||
@@ -75,14 +83,7 @@ export default class Utils {
|
||||
* For now, it is just SB.config.invidiousInstances.
|
||||
*/
|
||||
setupExtraSiteContentScripts(): void {
|
||||
const registration: Registration = {
|
||||
message: "registerContentScript",
|
||||
id: "invidious",
|
||||
allFrames: true,
|
||||
js: this.js,
|
||||
css: this.css,
|
||||
matches: this.getPermissionRegex()
|
||||
};
|
||||
const registration = this.getExtraSiteRegistration();
|
||||
|
||||
if (this.backgroundScriptContainer) {
|
||||
this.backgroundScriptContainer.registerFirefoxContentScript(registration);
|
||||
@@ -106,11 +107,6 @@ export default class Utils {
|
||||
});
|
||||
}
|
||||
|
||||
if (!isFirefoxOrSafari() && chrome.declarativeContent) {
|
||||
// Only if we have permission
|
||||
chrome.declarativeContent.onPageChanged.removeRules(["invidious"]);
|
||||
}
|
||||
|
||||
chrome.permissions.remove({
|
||||
origins: this.getPermissionRegex()
|
||||
});
|
||||
@@ -135,8 +131,10 @@ export default class Utils {
|
||||
|
||||
containsInvidiousPermission(): Promise<boolean> {
|
||||
return new Promise((resolve) => {
|
||||
let permissions = ["declarativeContent"];
|
||||
if (isFirefoxOrSafari()) permissions = [];
|
||||
const permissions = [];
|
||||
if (isSafari()) {
|
||||
permissions.push("webNavigation");
|
||||
}
|
||||
|
||||
chrome.permissions.contains({
|
||||
origins: this.getPermissionRegex(),
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
window["SBLogs"] = {
|
||||
debug: [],
|
||||
warn: []
|
||||
};
|
||||
if (typeof (window) !== "undefined") {
|
||||
window["SBLogs"] = {
|
||||
debug: [],
|
||||
warn: []
|
||||
};
|
||||
}
|
||||
|
||||
export function logDebug(message: string) {
|
||||
window["SBLogs"].debug.push(`[${new Date().toISOString()}] ${message}`);
|
||||
if (typeof (window) !== "undefined") {
|
||||
window["SBLogs"].debug.push(`[${new Date().toISOString()}] ${message}`);
|
||||
} else {
|
||||
console.log(`[${new Date().toISOString()}] ${message}`)
|
||||
}
|
||||
}
|
||||
|
||||
export function logWarn(message: string) {
|
||||
window["SBLogs"].warn.push(`[${new Date().toISOString()}] ${message}`);
|
||||
if (typeof (window) !== "undefined") {
|
||||
window["SBLogs"].warn.push(`[${new Date().toISOString()}] ${message}`);
|
||||
} else {
|
||||
console.warn(`[${new Date().toISOString()}] ${message}`)
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,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 = {
|
||||
@@ -41,12 +42,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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user