mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-18 21:48:33 +03:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d04482d19 | ||
|
|
7c661f8e67 | ||
|
|
0b7a2fd197 | ||
|
|
3382d8a500 | ||
|
|
5d871d5fe7 | ||
|
|
b7c5737a95 | ||
|
|
0cca1c3566 | ||
|
|
e0fe0fad67 | ||
|
|
c0bc068a18 | ||
|
|
7cb413db15 |
@@ -75,4 +75,4 @@ Icons made by:
|
|||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
This project is licensed under GNU LGPL v3 or any later version
|
This project is licensed under GNU GPL v3 or any later version
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "__MSG_fullName__",
|
"name": "__MSG_fullName__",
|
||||||
"short_name": "SponsorBlock",
|
"short_name": "SponsorBlock",
|
||||||
"version": "5.5.4",
|
"version": "5.5.5",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"description": "__MSG_Description__",
|
"description": "__MSG_Description__",
|
||||||
"homepage_url": "https://sponsor.ajay.app",
|
"homepage_url": "https://sponsor.ajay.app",
|
||||||
|
|||||||
Submodule public/_locales updated: a922227851...96f860dc1d
@@ -160,8 +160,8 @@ async function registerFirefoxContentScript(options: Registration) {
|
|||||||
ids: [options.id]
|
ids: [options.id]
|
||||||
}).catch(() => []);
|
}).catch(() => []);
|
||||||
|
|
||||||
if (existingRegistrations.length > 0
|
if (existingRegistrations && existingRegistrations.length > 0
|
||||||
&& existingRegistrations[0].matches.every((match) => options.matches.includes(match))) {
|
&& options.matches.every((match) => existingRegistrations[0].matches.includes(match))) {
|
||||||
// No need to register another script, already registered
|
// No need to register another script, already registered
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -222,27 +222,35 @@ async function submitVote(type: number, UUID: string, category: string) {
|
|||||||
|
|
||||||
const typeSection = (type !== undefined) ? "&type=" + type : "&category=" + category;
|
const typeSection = (type !== undefined) ? "&type=" + type : "&category=" + category;
|
||||||
|
|
||||||
//publish this vote
|
try {
|
||||||
const response = await asyncRequestToServer("POST", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + typeSection);
|
const response = await asyncRequestToServer("POST", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + typeSection);
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return {
|
return {
|
||||||
successType: 1,
|
successType: 1,
|
||||||
responseText: await response.text()
|
responseText: await response.text()
|
||||||
};
|
};
|
||||||
} else if (response.status == 405) {
|
} else if (response.status == 405) {
|
||||||
//duplicate vote
|
//duplicate vote
|
||||||
return {
|
return {
|
||||||
successType: 0,
|
successType: 0,
|
||||||
statusCode: response.status,
|
statusCode: response.status,
|
||||||
responseText: await response.text()
|
responseText: await response.text()
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
//error while connect
|
//error while connect
|
||||||
|
return {
|
||||||
|
successType: -1,
|
||||||
|
statusCode: response.status,
|
||||||
|
responseText: await response.text()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
return {
|
return {
|
||||||
successType: -1,
|
successType: -1,
|
||||||
statusCode: response.status,
|
statusCode: -1,
|
||||||
responseText: await response.text()
|
responseText: ""
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export interface SubmissionNoticeProps {
|
|||||||
// Contains functions and variables from the content script needed by the skip notice
|
// Contains functions and variables from the content script needed by the skip notice
|
||||||
contentContainer: ContentContainer;
|
contentContainer: ContentContainer;
|
||||||
|
|
||||||
callback: () => unknown;
|
callback: () => Promise<boolean>;
|
||||||
|
|
||||||
closeListener: () => void;
|
closeListener: () => void;
|
||||||
}
|
}
|
||||||
@@ -239,9 +239,11 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.callback();
|
this.props.callback().then((success) => {
|
||||||
|
if (success) {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sortSegments(): void {
|
sortSegments(): void {
|
||||||
|
|||||||
@@ -454,7 +454,9 @@ function videoIDChange(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleMobileControlsMutations(): void {
|
function handleMobileControlsMutations(): void {
|
||||||
if (!chrome.runtime?.id) return;
|
// Don't update while scrubbing
|
||||||
|
if (!chrome.runtime?.id
|
||||||
|
|| document.querySelector(".YtProgressBarProgressBarPlayheadDotInDragging")) return;
|
||||||
|
|
||||||
updateVisibilityOfPlayerControlsButton();
|
updateVisibilityOfPlayerControlsButton();
|
||||||
|
|
||||||
@@ -770,6 +772,7 @@ function getVirtualTime(): number {
|
|||||||
|
|
||||||
function inMuteSegment(currentTime: number, includeOverlap: boolean): boolean {
|
function inMuteSegment(currentTime: number, includeOverlap: boolean): boolean {
|
||||||
const checkFunction = (segment) => segment.actionType === ActionType.Mute
|
const checkFunction = (segment) => segment.actionType === ActionType.Mute
|
||||||
|
&& segment.hidden === SponsorHideType.Visible
|
||||||
&& segment.segment[0] <= currentTime
|
&& segment.segment[0] <= currentTime
|
||||||
&& (segment.segment[1] > currentTime || (includeOverlap && segment.segment[1] + 0.02 > currentTime));
|
&& (segment.segment[1] > currentTime || (includeOverlap && segment.segment[1] + 0.02 > currentTime));
|
||||||
return sponsorTimes?.some(checkFunction) || sponsorTimesSubmitting.some(checkFunction);
|
return sponsorTimes?.some(checkFunction) || sponsorTimesSubmitting.some(checkFunction);
|
||||||
@@ -2263,13 +2266,13 @@ function submitSegments() {
|
|||||||
|
|
||||||
//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(): Promise<boolean> {
|
||||||
// check if all segments are full video
|
// check if all segments are full video
|
||||||
const onlyFullVideo = sponsorTimesSubmitting.every((segment) => segment.actionType === ActionType.Full);
|
const onlyFullVideo = sponsorTimesSubmitting.every((segment) => segment.actionType === ActionType.Full);
|
||||||
// Block if submitting on a running livestream or premiere
|
// Block if submitting on a running livestream or premiere
|
||||||
if (!onlyFullVideo && (getIsLivePremiere() || isVisible(document.querySelector(".ytp-live-badge")))) {
|
if (!onlyFullVideo && (getIsLivePremiere() || isVisible(document.querySelector(".ytp-live-badge")))) {
|
||||||
alert(chrome.i18n.getMessage("liveOrPremiere"));
|
alert(chrome.i18n.getMessage("liveOrPremiere"));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!previewedSegment
|
if (!previewedSegment
|
||||||
@@ -2277,7 +2280,7 @@ async function sendSubmitMessage() {
|
|||||||
[ActionType.Full, ActionType.Chapter, ActionType.Poi].includes(segment.actionType)
|
[ActionType.Full, ActionType.Chapter, ActionType.Poi].includes(segment.actionType)
|
||||||
|| segment.segment[1] >= getVideo()?.duration)) {
|
|| segment.segment[1] >= getVideo()?.duration)) {
|
||||||
alert(`${chrome.i18n.getMessage("previewSegmentRequired")} ${keybindToString(Config.config.previewKeybind)}`);
|
alert(`${chrome.i18n.getMessage("previewSegmentRequired")} ${keybindToString(Config.config.previewKeybind)}`);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add loading animation
|
// Add loading animation
|
||||||
@@ -2303,7 +2306,7 @@ async function sendSubmitMessage() {
|
|||||||
const confirmShort = chrome.i18n.getMessage("shortCheck") + "\n\n" +
|
const confirmShort = chrome.i18n.getMessage("shortCheck") + "\n\n" +
|
||||||
getSegmentsMessage(sponsorTimesSubmitting);
|
getSegmentsMessage(sponsorTimesSubmitting);
|
||||||
|
|
||||||
if(!confirm(confirmShort)) return;
|
if(!confirm(confirmShort)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2353,6 +2356,8 @@ async function sendSubmitMessage() {
|
|||||||
if (fullVideoSegment) {
|
if (fullVideoSegment) {
|
||||||
categoryPill?.setSegment(fullVideoSegment);
|
categoryPill?.setSegment(fullVideoSegment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Show that the upload failed
|
// Show that the upload failed
|
||||||
playerButtons.submit.button.style.animation = "unset";
|
playerButtons.submit.button.style.animation = "unset";
|
||||||
@@ -2364,6 +2369,8 @@ async function sendSubmitMessage() {
|
|||||||
alert(getErrorMessage(response.status, response.responseText));
|
alert(getErrorMessage(response.status, response.responseText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the message that visually displays the video times
|
//get the message that visually displays the video times
|
||||||
@@ -2389,6 +2396,8 @@ function getSegmentsMessage(sponsorTimes: SponsorTime[]): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateActiveSegment(currentTime: number): void {
|
function updateActiveSegment(currentTime: number): void {
|
||||||
|
previewBar?.updateChapterText(sponsorTimes, sponsorTimesSubmitting, currentTime);
|
||||||
|
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
message: "time",
|
message: "time",
|
||||||
time: currentTime
|
time: currentTime
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class SubmissionNotice {
|
|||||||
// Contains functions and variables from the content script needed by the skip notice
|
// Contains functions and variables from the content script needed by the skip notice
|
||||||
contentContainer: () => unknown;
|
contentContainer: () => unknown;
|
||||||
|
|
||||||
callback: () => unknown;
|
callback: () => Promise<boolean>;
|
||||||
|
|
||||||
noticeRef: React.MutableRefObject<SubmissionNoticeComponent>;
|
noticeRef: React.MutableRefObject<SubmissionNoticeComponent>;
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ class SubmissionNotice {
|
|||||||
|
|
||||||
root: Root;
|
root: Root;
|
||||||
|
|
||||||
constructor(contentContainer: ContentContainer, callback: () => unknown) {
|
constructor(contentContainer: ContentContainer, callback: () => Promise<boolean>) {
|
||||||
this.noticeRef = React.createRef();
|
this.noticeRef = React.createRef();
|
||||||
|
|
||||||
this.contentContainer = contentContainer;
|
this.contentContainer = contentContainer;
|
||||||
|
|||||||
Reference in New Issue
Block a user