mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-15 07:57:09 +03:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8653059b13 | ||
|
|
b3afd0403e | ||
|
|
6db498ccb1 | ||
|
|
ef8c5f58c5 | ||
|
|
71998831ee | ||
|
|
8f19d3e83c | ||
|
|
d68c3659be | ||
|
|
715bcb6bd3 | ||
|
|
fea8a9a37e | ||
|
|
aec5845bce | ||
|
|
5209c0ea04 | ||
|
|
b52132e311 | ||
|
|
c2e731ef89 | ||
|
|
a48269f254 | ||
|
|
562adb9d55 | ||
|
|
851ceb553d | ||
|
|
4bd7e9ab34 | ||
|
|
97fc8174b9 | ||
|
|
9849c34ed3 | ||
|
|
56be762686 |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "__MSG_fullName__",
|
"name": "__MSG_fullName__",
|
||||||
"short_name": "SponsorBlock",
|
"short_name": "SponsorBlock",
|
||||||
"version": "5.1.0",
|
"version": "5.1.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",
|
||||||
|
|||||||
@@ -116,6 +116,9 @@
|
|||||||
"connectionError": {
|
"connectionError": {
|
||||||
"message": "A connection error has occurred. Error code: "
|
"message": "A connection error has occurred. Error code: "
|
||||||
},
|
},
|
||||||
|
"segmentsStillLoading": {
|
||||||
|
"message": "Segments still loading..."
|
||||||
|
},
|
||||||
"clearTimes": {
|
"clearTimes": {
|
||||||
"message": "Clear Segments"
|
"message": "Clear Segments"
|
||||||
},
|
},
|
||||||
@@ -1243,5 +1246,8 @@
|
|||||||
},
|
},
|
||||||
"exportSegmentsAsURL": {
|
"exportSegmentsAsURL": {
|
||||||
"message": "Share as URL"
|
"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."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,7 +392,7 @@
|
|||||||
"message": "건너뛰기로 제외된 시간 표시"
|
"message": "건너뛰기로 제외된 시간 표시"
|
||||||
},
|
},
|
||||||
"showTimeWithSkipsDescription": {
|
"showTimeWithSkipsDescription": {
|
||||||
"message": "탐색 바 아래에 있는 동영상 시간 옆 괄호에 시간이 표시돼요. 건너뛸 구간을 제외할 실제로 재생하게 될 동영상의 길이를 보여줘요. \"탐색 바에 표시\"로만 지정된 구간도 포함해요."
|
"message": "이 시간은 탐색 바 아래에 있고 현재 시간 옆에 있는 대괄호로 표시돼요. 건너뛸 구간을 제외할 실제로 재생하게 될 동영상의 길이를 보여줘요. \"탐색 바에 표시\"로만 지정된 구간도 포함해요."
|
||||||
},
|
},
|
||||||
"youHaveSkipped": {
|
"youHaveSkipped": {
|
||||||
"message": "건너뛴 구간: "
|
"message": "건너뛴 구간: "
|
||||||
@@ -424,7 +424,7 @@
|
|||||||
"message": "비공개 사용자 ID 가져오기/내보내기"
|
"message": "비공개 사용자 ID 가져오기/내보내기"
|
||||||
},
|
},
|
||||||
"whatChangeUserID": {
|
"whatChangeUserID": {
|
||||||
"message": "이 정보를 다른 분께 공개하지 마세요. 비밀번호처럼 알려주면 위험한 정보랍니다. 다른 분이 이 정보를 가지고 나를 사칭할 수도 있어요. 공개 사용자 ID를 찾고 있다면, 팝업 내 클립보드 아이콘을 눌러주세요."
|
"message": "이 정보를 다른 분께 공개하지 마세요. 이건 비밀번호와 같으며 누구와도 공유해서는 안 되는 정보랍니다. 다른 분이 이 정보를 습득한다면, 나를 사칭할 수도 있어요. 공개 사용자 ID를 찾고 있다면, 팝업 내 클립보드 아이콘을 눌러주세요."
|
||||||
},
|
},
|
||||||
"setUserID": {
|
"setUserID": {
|
||||||
"message": "비공개 사용자 ID 설정"
|
"message": "비공개 사용자 ID 설정"
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ interface SBConfig {
|
|||||||
showCategoryGuidelines: boolean;
|
showCategoryGuidelines: boolean;
|
||||||
showCategoryWithoutPermission: boolean;
|
showCategoryWithoutPermission: boolean;
|
||||||
showSegmentNameInChapterBar: boolean;
|
showSegmentNameInChapterBar: boolean;
|
||||||
|
useVirtualTime: boolean;
|
||||||
|
showSegmentFailedToFetchWarning: boolean;
|
||||||
|
|
||||||
// Used to cache calculated text color info
|
// Used to cache calculated text color info
|
||||||
categoryPillColors: {
|
categoryPillColors: {
|
||||||
@@ -200,6 +202,8 @@ const Config: SBObject = {
|
|||||||
showCategoryGuidelines: true,
|
showCategoryGuidelines: true,
|
||||||
showCategoryWithoutPermission: false,
|
showCategoryWithoutPermission: false,
|
||||||
showSegmentNameInChapterBar: true,
|
showSegmentNameInChapterBar: true,
|
||||||
|
useVirtualTime: true,
|
||||||
|
showSegmentFailedToFetchWarning: true,
|
||||||
|
|
||||||
categoryPillColors: {},
|
categoryPillColors: {},
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ let sponsorVideoID: VideoID = null;
|
|||||||
const skipNotices: SkipNotice[] = [];
|
const skipNotices: SkipNotice[] = [];
|
||||||
let activeSkipKeybindElement: ToggleSkippable = null;
|
let activeSkipKeybindElement: ToggleSkippable = null;
|
||||||
let retryFetchTimeout: NodeJS.Timeout = null;
|
let retryFetchTimeout: NodeJS.Timeout = null;
|
||||||
|
let shownSegmentFailedToFetchWarning = false;
|
||||||
|
|
||||||
// JSON video info
|
// JSON video info
|
||||||
let videoInfo: VideoInfo = null;
|
let videoInfo: VideoInfo = null;
|
||||||
@@ -271,8 +272,13 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
|
|||||||
for (const segment of importedSegments) {
|
for (const segment of importedSegments) {
|
||||||
if (!sponsorTimesSubmitting.some(
|
if (!sponsorTimesSubmitting.some(
|
||||||
(s) => Math.abs(s.segment[0] - segment.segment[0]) < 1
|
(s) => Math.abs(s.segment[0] - segment.segment[0]) < 1
|
||||||
&& Math.abs(s.segment[1] - segment.segment[1]) < 1)
|
&& Math.abs(s.segment[1] - segment.segment[1]) < 1)) {
|
||||||
&& (segment.category !== "chapter" || utils.getCategorySelection("chapter"))) {
|
if (segment.category === "chapter" && !utils.getCategorySelection("chapter")) {
|
||||||
|
segment.category = "chooseACategory" as Category;
|
||||||
|
segment.actionType = ActionType.Skip;
|
||||||
|
segment.description = "";
|
||||||
|
}
|
||||||
|
|
||||||
sponsorTimesSubmitting.push(segment);
|
sponsorTimesSubmitting.push(segment);
|
||||||
addedSegments = true;
|
addedSegments = true;
|
||||||
}
|
}
|
||||||
@@ -284,6 +290,7 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
|
|||||||
|
|
||||||
updateEditButtonsOnPlayer();
|
updateEditButtonsOnPlayer();
|
||||||
updateSponsorTimesSubmitting(false);
|
updateSponsorTimesSubmitting(false);
|
||||||
|
submitSponsorTimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendResponse({
|
sendResponse({
|
||||||
@@ -338,6 +345,8 @@ function resetValues() {
|
|||||||
sponsorTimes = [];
|
sponsorTimes = [];
|
||||||
existingChaptersImported = false;
|
existingChaptersImported = false;
|
||||||
sponsorSkipped = [];
|
sponsorSkipped = [];
|
||||||
|
lastResponseStatus = 0;
|
||||||
|
shownSegmentFailedToFetchWarning = false;
|
||||||
|
|
||||||
sponsorVideoID = null;
|
sponsorVideoID = null;
|
||||||
videoInfo = null;
|
videoInfo = null;
|
||||||
@@ -709,10 +718,10 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
|
|||||||
|
|
||||||
function getVirtualTime(): number {
|
function getVirtualTime(): number {
|
||||||
const virtualTime = lastTimeFromWaitingEvent ?? (lastKnownVideoTime.videoTime ?
|
const virtualTime = lastTimeFromWaitingEvent ?? (lastKnownVideoTime.videoTime ?
|
||||||
(performance.now() - lastKnownVideoTime.preciseTime) / 1000 + lastKnownVideoTime.videoTime : null);
|
(performance.now() - lastKnownVideoTime.preciseTime) * video.playbackRate / 1000 + lastKnownVideoTime.videoTime : null);
|
||||||
|
|
||||||
if ((lastTimeFromWaitingEvent || !utils.isFirefox())
|
if (Config.config.useVirtualTime && !utils.isFirefox() && !isSafari() && virtualTime
|
||||||
&& !isSafari() && virtualTime && Math.abs(virtualTime - video.currentTime) < 0.6 && video.currentTime !== 0) {
|
&& Math.abs(virtualTime - video.currentTime) < 0.6 && video.currentTime !== 0) {
|
||||||
return virtualTime;
|
return virtualTime;
|
||||||
} else {
|
} else {
|
||||||
return video.currentTime;
|
return video.currentTime;
|
||||||
@@ -874,9 +883,19 @@ function setupVideoListeners() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
video.addEventListener('ratechange', () => startSponsorSchedule());
|
video.addEventListener('ratechange', () => {
|
||||||
|
updateVirtualTime();
|
||||||
|
lastTimeFromWaitingEvent = null;
|
||||||
|
|
||||||
|
startSponsorSchedule();
|
||||||
|
});
|
||||||
// Used by videospeed extension (https://github.com/igrigorik/videospeed/pull/740)
|
// Used by videospeed extension (https://github.com/igrigorik/videospeed/pull/740)
|
||||||
video.addEventListener('videoSpeed_ratechange', () => startSponsorSchedule());
|
video.addEventListener('videoSpeed_ratechange', () => {
|
||||||
|
updateVirtualTime();
|
||||||
|
lastTimeFromWaitingEvent = null;
|
||||||
|
|
||||||
|
startSponsorSchedule();
|
||||||
|
});
|
||||||
const paused = () => {
|
const paused = () => {
|
||||||
// Reset lastCheckVideoTime
|
// Reset lastCheckVideoTime
|
||||||
lastCheckVideoTime = -1;
|
lastCheckVideoTime = -1;
|
||||||
@@ -1906,6 +1925,13 @@ function startOrEndTimingNewSegment() {
|
|||||||
updateSponsorTimesSubmitting(false);
|
updateSponsorTimesSubmitting(false);
|
||||||
|
|
||||||
importExistingChapters(false);
|
importExistingChapters(false);
|
||||||
|
|
||||||
|
if (lastResponseStatus !== 200 && lastResponseStatus !== 404
|
||||||
|
&& !shownSegmentFailedToFetchWarning && Config.config.showSegmentFailedToFetchWarning) {
|
||||||
|
alert(chrome.i18n.getMessage("segmentFetchFailureWarning"));
|
||||||
|
|
||||||
|
shownSegmentFailedToFetchWarning = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIncompleteSegment(): SponsorTime {
|
function getIncompleteSegment(): SponsorTime {
|
||||||
|
|||||||
@@ -676,7 +676,7 @@ class PreviewBar {
|
|||||||
for (let i = 0; i < sections.length; i++) {
|
for (let i = 0; i < sections.length; i++) {
|
||||||
const section = sections[i] as HTMLElement;
|
const section = sections[i] as HTMLElement;
|
||||||
const checkElement = section.querySelector(selector) as HTMLElement;
|
const checkElement = section.querySelector(selector) as HTMLElement;
|
||||||
const currentSectionWidthNoMargin = this.getPartialChapterSectionStyle(section, "width") || progressBar.clientWidth;
|
const currentSectionWidthNoMargin = this.getPartialChapterSectionStyle(section, "width") ?? progressBar.clientWidth;
|
||||||
const currentSectionWidth = currentSectionWidthNoMargin
|
const currentSectionWidth = currentSectionWidthNoMargin
|
||||||
+ this.getPartialChapterSectionStyle(section, "marginRight");
|
+ this.getPartialChapterSectionStyle(section, "marginRight");
|
||||||
|
|
||||||
@@ -728,8 +728,8 @@ class PreviewBar {
|
|||||||
|
|
||||||
private getPartialChapterSectionStyle(element: HTMLElement, param: string): number {
|
private getPartialChapterSectionStyle(element: HTMLElement, param: string): number {
|
||||||
const data = element.style[param];
|
const data = element.style[param];
|
||||||
if (data?.includes("100%")) {
|
if (data?.includes("%")) {
|
||||||
return 0;
|
return this.customChaptersBar.clientWidth * (parseFloat(data.replace("%", "")) / 100);
|
||||||
} else {
|
} else {
|
||||||
return parseInt(element.style[param].match(/\d+/g)?.[0]) || 0;
|
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.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404");
|
||||||
PageElements.issueReporterImportExport.classList.remove("hidden");
|
PageElements.issueReporterImportExport.classList.remove("hidden");
|
||||||
} else {
|
} else {
|
||||||
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("connectionError") + request.status;
|
if (request.status) {
|
||||||
PageElements.issueReporterImportExport.classList.add("hidden");
|
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")
|
const chapterNames = CompileConfig.categoryList.filter((code) => code !== "chapter")
|
||||||
.map((code) => ({
|
.map((code) => ({
|
||||||
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 {
|
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;
|
const title = titleLeft?.length > titleRight?.length ? titleLeft : titleRight;
|
||||||
if (title) {
|
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 = {
|
const segment: SponsorTime = {
|
||||||
segment: [startTime, GenericUtils.getFormattedTimeToSeconds(match[1])],
|
segment: [startTime, GenericUtils.getFormattedTimeToSeconds(match[1])],
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ export function getExistingChapters(currentVideoID: VideoID, duration: number):
|
|||||||
|
|
||||||
const chapters: SponsorTime[] = [];
|
const chapters: SponsorTime[] = [];
|
||||||
// .ytp-timed-markers-container indicates that key-moments are present, which should not be divided
|
// .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;
|
let lastSegment: SponsorTime = null;
|
||||||
const links = chaptersBox.querySelectorAll("ytd-macro-markers-list-item-renderer > a");
|
const links = chaptersBox.querySelectorAll("ytd-macro-markers-list-item-renderer > a");
|
||||||
for (const link of links) {
|
for (const link of links) {
|
||||||
|
|||||||
Reference in New Issue
Block a user