mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 12:07:11 +03:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8653059b13 | ||
|
|
b3afd0403e | ||
|
|
6db498ccb1 | ||
|
|
ef8c5f58c5 | ||
|
|
71998831ee | ||
|
|
8f19d3e83c | ||
|
|
d68c3659be | ||
|
|
715bcb6bd3 | ||
|
|
fea8a9a37e | ||
|
|
aec5845bce | ||
|
|
5209c0ea04 | ||
|
|
b52132e311 | ||
|
|
c2e731ef89 | ||
|
|
a48269f254 |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "__MSG_fullName__",
|
||||
"short_name": "SponsorBlock",
|
||||
"version": "5.1.1",
|
||||
"version": "5.1.4",
|
||||
"default_locale": "en",
|
||||
"description": "__MSG_Description__",
|
||||
"homepage_url": "https://sponsor.ajay.app",
|
||||
|
||||
@@ -116,6 +116,9 @@
|
||||
"connectionError": {
|
||||
"message": "A connection error has occurred. Error code: "
|
||||
},
|
||||
"segmentsStillLoading": {
|
||||
"message": "Segments still loading..."
|
||||
},
|
||||
"clearTimes": {
|
||||
"message": "Clear Segments"
|
||||
},
|
||||
@@ -1243,5 +1246,8 @@
|
||||
},
|
||||
"exportSegmentsAsURL": {
|
||||
"message": "Share as URL"
|
||||
},
|
||||
"segmentFetchFailureWarning": {
|
||||
"message": "Warning: The server hasn't responded with segments yet. There might actually be segments on this video already submitted but you just haven't recieved them due to issues with the server."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ interface SBConfig {
|
||||
showCategoryWithoutPermission: boolean;
|
||||
showSegmentNameInChapterBar: boolean;
|
||||
useVirtualTime: boolean;
|
||||
showSegmentFailedToFetchWarning: boolean;
|
||||
|
||||
// Used to cache calculated text color info
|
||||
categoryPillColors: {
|
||||
@@ -202,6 +203,7 @@ const Config: SBObject = {
|
||||
showCategoryWithoutPermission: false,
|
||||
showSegmentNameInChapterBar: true,
|
||||
useVirtualTime: true,
|
||||
showSegmentFailedToFetchWarning: true,
|
||||
|
||||
categoryPillColors: {},
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ let sponsorVideoID: VideoID = null;
|
||||
const skipNotices: SkipNotice[] = [];
|
||||
let activeSkipKeybindElement: ToggleSkippable = null;
|
||||
let retryFetchTimeout: NodeJS.Timeout = null;
|
||||
let shownSegmentFailedToFetchWarning = false;
|
||||
|
||||
// JSON video info
|
||||
let videoInfo: VideoInfo = null;
|
||||
@@ -271,8 +272,13 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
|
||||
for (const segment of importedSegments) {
|
||||
if (!sponsorTimesSubmitting.some(
|
||||
(s) => Math.abs(s.segment[0] - segment.segment[0]) < 1
|
||||
&& Math.abs(s.segment[1] - segment.segment[1]) < 1)
|
||||
&& (segment.category !== "chapter" || utils.getCategorySelection("chapter"))) {
|
||||
&& Math.abs(s.segment[1] - segment.segment[1]) < 1)) {
|
||||
if (segment.category === "chapter" && !utils.getCategorySelection("chapter")) {
|
||||
segment.category = "chooseACategory" as Category;
|
||||
segment.actionType = ActionType.Skip;
|
||||
segment.description = "";
|
||||
}
|
||||
|
||||
sponsorTimesSubmitting.push(segment);
|
||||
addedSegments = true;
|
||||
}
|
||||
@@ -284,6 +290,7 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
|
||||
|
||||
updateEditButtonsOnPlayer();
|
||||
updateSponsorTimesSubmitting(false);
|
||||
submitSponsorTimes();
|
||||
}
|
||||
|
||||
sendResponse({
|
||||
@@ -338,6 +345,8 @@ function resetValues() {
|
||||
sponsorTimes = [];
|
||||
existingChaptersImported = false;
|
||||
sponsorSkipped = [];
|
||||
lastResponseStatus = 0;
|
||||
shownSegmentFailedToFetchWarning = false;
|
||||
|
||||
sponsorVideoID = null;
|
||||
videoInfo = null;
|
||||
@@ -711,7 +720,7 @@ function getVirtualTime(): number {
|
||||
const virtualTime = lastTimeFromWaitingEvent ?? (lastKnownVideoTime.videoTime ?
|
||||
(performance.now() - lastKnownVideoTime.preciseTime) * video.playbackRate / 1000 + lastKnownVideoTime.videoTime : null);
|
||||
|
||||
if (Config.config.useVirtualTime && !isSafari() && virtualTime
|
||||
if (Config.config.useVirtualTime && !utils.isFirefox() && !isSafari() && virtualTime
|
||||
&& Math.abs(virtualTime - video.currentTime) < 0.6 && video.currentTime !== 0) {
|
||||
return virtualTime;
|
||||
} else {
|
||||
@@ -1916,6 +1925,13 @@ function startOrEndTimingNewSegment() {
|
||||
updateSponsorTimesSubmitting(false);
|
||||
|
||||
importExistingChapters(false);
|
||||
|
||||
if (lastResponseStatus !== 200 && lastResponseStatus !== 404
|
||||
&& !shownSegmentFailedToFetchWarning && Config.config.showSegmentFailedToFetchWarning) {
|
||||
alert(chrome.i18n.getMessage("segmentFetchFailureWarning"));
|
||||
|
||||
shownSegmentFailedToFetchWarning = true;
|
||||
}
|
||||
}
|
||||
|
||||
function getIncompleteSegment(): SponsorTime {
|
||||
|
||||
@@ -728,8 +728,8 @@ class PreviewBar {
|
||||
|
||||
private getPartialChapterSectionStyle(element: HTMLElement, param: string): number {
|
||||
const data = element.style[param];
|
||||
if (data?.includes("100%")) {
|
||||
return 0;
|
||||
if (data?.includes("%")) {
|
||||
return this.customChaptersBar.clientWidth * (parseFloat(data.replace("%", "")) / 100);
|
||||
} else {
|
||||
return parseInt(element.style[param].match(/\d+/g)?.[0]) || 0;
|
||||
}
|
||||
|
||||
@@ -456,8 +456,13 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
||||
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404");
|
||||
PageElements.issueReporterImportExport.classList.remove("hidden");
|
||||
} else {
|
||||
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("connectionError") + request.status;
|
||||
PageElements.issueReporterImportExport.classList.add("hidden");
|
||||
if (request.status) {
|
||||
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("connectionError") + request.status;
|
||||
} else {
|
||||
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("segmentsStillLoading");
|
||||
}
|
||||
|
||||
PageElements.issueReporterImportExport.classList.remove("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ const inTest = typeof chrome === "undefined";
|
||||
const chapterNames = CompileConfig.categoryList.filter((code) => code !== "chapter")
|
||||
.map((code) => ({
|
||||
code,
|
||||
name: !inTest ? chrome.i18n.getMessage("category_" + code) : code
|
||||
names: !inTest ? [chrome.i18n.getMessage("category_" + code), shortCategoryName(code)] : [code]
|
||||
}));
|
||||
|
||||
export function exportTimes(segments: SponsorTime[]): string {
|
||||
@@ -47,7 +47,7 @@ export function importTimes(data: string, videoDuration: number): SponsorTime[]
|
||||
|
||||
const title = titleLeft?.length > titleRight?.length ? titleLeft : titleRight;
|
||||
if (title) {
|
||||
const determinedCategory = chapterNames.find(c => c.name === title)?.code as Category;
|
||||
const determinedCategory = chapterNames.find(c => c.names.includes(title))?.code as Category;
|
||||
|
||||
const segment: SponsorTime = {
|
||||
segment: [startTime, GenericUtils.getFormattedTimeToSeconds(match[1])],
|
||||
|
||||
@@ -71,7 +71,8 @@ export function getExistingChapters(currentVideoID: VideoID, duration: number):
|
||||
|
||||
const chapters: SponsorTime[] = [];
|
||||
// .ytp-timed-markers-container indicates that key-moments are present, which should not be divided
|
||||
if (chaptersBox && !(document.querySelector(".ytp-timed-markers-container")?.childElementCount > 0)) {
|
||||
if (chaptersBox && !(getControls()?.parentElement?.parentElement
|
||||
?.querySelector(".ytp-timed-markers-container")?.childElementCount > 0)) {
|
||||
let lastSegment: SponsorTime = null;
|
||||
const links = chaptersBox.querySelectorAll("ytd-macro-markers-list-item-renderer > a");
|
||||
for (const link of links) {
|
||||
|
||||
Reference in New Issue
Block a user