mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 04:57:09 +03:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
154e12f201 | ||
|
|
b6c1ee1743 | ||
|
|
6b6ca6198f | ||
|
|
6788394be1 | ||
|
|
a45bd4c5c7 | ||
|
|
bb47863080 | ||
|
|
d50a69f1fd | ||
|
|
31014b78ac | ||
|
|
cf9e016581 | ||
|
|
dee836c783 |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -59,7 +59,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: SafariExtension
|
name: SafariExtension
|
||||||
path: dist
|
path: dist
|
||||||
- run: mkdir ./builds
|
|
||||||
- name: Zip Artifacts
|
- name: Zip Artifacts
|
||||||
run: cd ./dist ; zip -r ../builds/SafariExtension.zip *
|
run: cd ./dist ; zip -r ../builds/SafariExtension.zip *
|
||||||
# Create Edge artifacts
|
# Create Edge artifacts
|
||||||
@@ -71,7 +70,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: EdgeExtension
|
name: EdgeExtension
|
||||||
path: dist
|
path: dist
|
||||||
- run: mkdir ./builds
|
|
||||||
- name: Zip Artifacts
|
- name: Zip Artifacts
|
||||||
run: cd ./dist ; zip -r ../builds/EdgeExtension.zip *
|
run: cd ./dist ; zip -r ../builds/EdgeExtension.zip *
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "__MSG_fullName__",
|
"name": "__MSG_fullName__",
|
||||||
"short_name": "SponsorBlock",
|
"short_name": "SponsorBlock",
|
||||||
"version": "4.0.3",
|
"version": "4.0.4",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"description": "__MSG_Description__",
|
"description": "__MSG_Description__",
|
||||||
"homepage_url": "https://sponsor.ajay.app",
|
"homepage_url": "https://sponsor.ajay.app",
|
||||||
|
|||||||
5
manifest/safari-manifest-extra.json
Normal file
5
manifest/safari-manifest-extra.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"background": {
|
||||||
|
"persistent": false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -440,6 +440,9 @@
|
|||||||
"shortCheck": {
|
"shortCheck": {
|
||||||
"message": "The following submission is shorter than your minimum duration option. This could mean that this is already submitted, and just being ignored due to this option. Are you sure you would like to submit?"
|
"message": "The following submission is shorter than your minimum duration option. This could mean that this is already submitted, and just being ignored due to this option. Are you sure you would like to submit?"
|
||||||
},
|
},
|
||||||
|
"liveOrPremiere": {
|
||||||
|
"message": "Submitting on an active livesteam or premiere is not allowed. Please wait until it finishes, then refresh the page and verify that the segments are still valid."
|
||||||
|
},
|
||||||
"showUploadButton": {
|
"showUploadButton": {
|
||||||
"message": "Show Upload Button"
|
"message": "Show Upload Button"
|
||||||
},
|
},
|
||||||
@@ -541,10 +544,10 @@
|
|||||||
"message": "Exclusive Access"
|
"message": "Exclusive Access"
|
||||||
},
|
},
|
||||||
"category_exclusive_access_description": {
|
"category_exclusive_access_description": {
|
||||||
"message": "Only for labeling entire videos. Used when a video showcases a product, service or location that they've recieved free or subsidized access to."
|
"message": "Only for labeling entire videos. Used when a video showcases a product, service or location that they've received free or subsidized access to."
|
||||||
},
|
},
|
||||||
"category_exclusive_access_pill": {
|
"category_exclusive_access_pill": {
|
||||||
"message": "This video showcases a product, service or location that they've recieved free or subsidized access to",
|
"message": "This video showcases a product, service or location that they've received free or subsidized access to",
|
||||||
"description": "Short description for this category"
|
"description": "Short description for this category"
|
||||||
},
|
},
|
||||||
"category_interaction": {
|
"category_interaction": {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { getCategoryActionType } from "./utils/categoryUtils";
|
|||||||
import { SkipButtonControlBar } from "./js-components/skipButtonControlBar";
|
import { SkipButtonControlBar } from "./js-components/skipButtonControlBar";
|
||||||
import { Tooltip } from "./render/Tooltip";
|
import { Tooltip } from "./render/Tooltip";
|
||||||
import { getStartTimeFromUrl } from "./utils/urlParser";
|
import { getStartTimeFromUrl } from "./utils/urlParser";
|
||||||
import { findValidElement, getControls, isVisible } from "./utils/pageUtils";
|
import { findValidElement, getControls, getHashParams, isVisible } from "./utils/pageUtils";
|
||||||
import { CategoryPill } from "./render/CategoryPill";
|
import { CategoryPill } from "./render/CategoryPill";
|
||||||
import { AnimationUtils } from "./utils/animationUtils";
|
import { AnimationUtils } from "./utils/animationUtils";
|
||||||
import { GenericUtils } from "./utils/genericUtils";
|
import { GenericUtils } from "./utils/genericUtils";
|
||||||
@@ -692,16 +692,8 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const extraRequestData: Record<string, unknown> = {};
|
const extraRequestData: Record<string, unknown> = {};
|
||||||
const windowHash = window.location.hash.substr(1);
|
const hashParams = getHashParams();
|
||||||
if (windowHash) {
|
if (hashParams.requiredSegment) extraRequestData.requiredSegment = hashParams.requiredSegment;
|
||||||
const params: Record<string, unknown> = windowHash.split('&').reduce((acc, param) => {
|
|
||||||
const [key, value] = param.split('=');
|
|
||||||
acc[key] = value;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
if (params.requiredSegment) extraRequestData.requiredSegment = params.requiredSegment;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for hashPrefix setting
|
// Check for hashPrefix setting
|
||||||
const hashPrefix = (await utils.getHash(id, 1)).substr(0, 4);
|
const hashPrefix = (await utils.getHash(id, 1)).substr(0, 4);
|
||||||
@@ -1403,8 +1395,9 @@ function shouldAutoSkip(segment: SponsorTime): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shouldSkip(segment: SponsorTime): boolean {
|
function shouldSkip(segment: SponsorTime): boolean {
|
||||||
return utils.getCategorySelection(segment.category)?.option !== CategorySkipOption.ShowOverlay ||
|
return (segment.actionType !== ActionType.Full
|
||||||
(Config.config.autoSkipOnMusicVideos && sponsorTimes?.some((s) => s.category === "music_offtopic"));
|
&& utils.getCategorySelection(segment.category)?.option !== CategorySkipOption.ShowOverlay)
|
||||||
|
|| (Config.config.autoSkipOnMusicVideos && sponsorTimes?.some((s) => s.category === "music_offtopic"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates any missing buttons on the YouTube player if possible. */
|
/** Creates any missing buttons on the YouTube player if possible. */
|
||||||
@@ -1582,6 +1575,8 @@ function updateSponsorTimesSubmitting(getFromConfig = true) {
|
|||||||
if (submissionNotice !== null) {
|
if (submissionNotice !== null) {
|
||||||
submissionNotice.update();
|
submissionNotice.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkForPreloadedSegment();
|
||||||
}
|
}
|
||||||
|
|
||||||
function openInfoMenu() {
|
function openInfoMenu() {
|
||||||
@@ -1803,6 +1798,12 @@ function submitSponsorTimes() {
|
|||||||
//send the message to the background js
|
//send the message to the background js
|
||||||
//called after all the checks have been made that it's okay to do so
|
//called after all the checks have been made that it's okay to do so
|
||||||
async function sendSubmitMessage() {
|
async function sendSubmitMessage() {
|
||||||
|
// Block if submitting on a running livestream or premiere
|
||||||
|
if (isVisible(document.querySelector(".ytp-live-badge"))) {
|
||||||
|
alert(chrome.i18n.getMessage("liveOrPremiere"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Add loading animation
|
// Add loading animation
|
||||||
playerButtons.submit.image.src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker.svg");
|
playerButtons.submit.image.src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker.svg");
|
||||||
const stopAnimation = AnimationUtils.applyLoadingAnimation(playerButtons.submit.button, 1, () => updateEditButtonsOnPlayer());
|
const stopAnimation = AnimationUtils.applyLoadingAnimation(playerButtons.submit.button, 1, () => updateEditButtonsOnPlayer());
|
||||||
@@ -2023,3 +2024,24 @@ function showTimeWithoutSkips(skippedDuration: number): void {
|
|||||||
|
|
||||||
duration.innerText = (durationAfterSkips == null || skippedDuration <= 0) ? "" : " (" + durationAfterSkips + ")";
|
duration.innerText = (durationAfterSkips == null || skippedDuration <= 0) ? "" : " (" + durationAfterSkips + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkForPreloadedSegment() {
|
||||||
|
const hashParams = getHashParams();
|
||||||
|
|
||||||
|
const segments = hashParams.segments;
|
||||||
|
if (Array.isArray(segments)) {
|
||||||
|
for (const segment of segments) {
|
||||||
|
if (Array.isArray(segment.segment)) {
|
||||||
|
if (!sponsorTimesSubmitting.some((s) => s.segment[0] === segment.segment[0] && s.segment[1] === s.segment[1])) {
|
||||||
|
sponsorTimesSubmitting.push({
|
||||||
|
segment: segment.segment,
|
||||||
|
UUID: utils.generateUserID() as SegmentUUID,
|
||||||
|
category: segment.category ? segment.category : Config.config.defaultCategory,
|
||||||
|
actionType: segment.actionType ? segment.actionType : ActionType.Skip,
|
||||||
|
source: SponsorSourceType.Local
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -343,6 +343,7 @@ export default class Utils {
|
|||||||
//for embeds
|
//for embeds
|
||||||
const player = document.getElementById("player");
|
const player = document.getElementById("player");
|
||||||
referenceNode = player.firstChild as HTMLElement;
|
referenceNode = player.firstChild as HTMLElement;
|
||||||
|
if (referenceNode) {
|
||||||
let index = 1;
|
let index = 1;
|
||||||
|
|
||||||
//find the child that is the video player (sometimes it is not the first)
|
//find the child that is the video player (sometimes it is not the first)
|
||||||
@@ -352,6 +353,7 @@ export default class Utils {
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return referenceNode;
|
return referenceNode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,3 +41,24 @@ function findValidElementFromGenerator<T>(objects: T[] | NodeListOf<HTMLElement>
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getHashParams(): Record<string, unknown> {
|
||||||
|
const windowHash = window.location.hash.substr(1);
|
||||||
|
if (windowHash) {
|
||||||
|
const params: Record<string, unknown> = windowHash.split('&').reduce((acc, param) => {
|
||||||
|
const [key, value] = param.split('=');
|
||||||
|
const decoded = decodeURIComponent(value);
|
||||||
|
try {
|
||||||
|
acc[key] = decoded?.match(/{|\[/) ? JSON.parse(decoded) : value;
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`Failed to parse hash parameter ${key}: ${value}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ const fs = require('fs');
|
|||||||
const manifest = require("../manifest/manifest.json");
|
const manifest = require("../manifest/manifest.json");
|
||||||
const firefoxManifestExtra = require("../manifest/firefox-manifest-extra.json");
|
const firefoxManifestExtra = require("../manifest/firefox-manifest-extra.json");
|
||||||
const chromeManifestExtra = require("../manifest/chrome-manifest-extra.json");
|
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 betaManifestExtra = require("../manifest/beta-manifest-extra.json");
|
||||||
const firefoxBetaManifestExtra = require("../manifest/firefox-beta-manifest-extra.json");
|
const firefoxBetaManifestExtra = require("../manifest/firefox-beta-manifest-extra.json");
|
||||||
|
|
||||||
@@ -41,8 +42,12 @@ class BuildManifest {
|
|||||||
// Add missing manifest elements
|
// Add missing manifest elements
|
||||||
if (this.options.browser.toLowerCase() === "firefox") {
|
if (this.options.browser.toLowerCase() === "firefox") {
|
||||||
mergeObjects(manifest, firefoxManifestExtra);
|
mergeObjects(manifest, firefoxManifestExtra);
|
||||||
} else if (this.options.browser.toLowerCase() === "chrome" || this.options.browser.toLowerCase() === "chromium") {
|
} else if (this.options.browser.toLowerCase() === "chrome"
|
||||||
|
|| this.options.browser.toLowerCase() === "chromium"
|
||||||
|
|| this.options.browser.toLowerCase() === "edge") {
|
||||||
mergeObjects(manifest, chromeManifestExtra);
|
mergeObjects(manifest, chromeManifestExtra);
|
||||||
|
} else if (this.options.browser.toLowerCase() === "safari") {
|
||||||
|
mergeObjects(manifest, safariManifestExtra);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.options.stream === "beta") {
|
if (this.options.stream === "beta") {
|
||||||
|
|||||||
Reference in New Issue
Block a user