From 8896c5707a2e430fb331c1823d8d05f5da76120f Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Tue, 4 Feb 2020 22:16:40 +0000 Subject: [PATCH 01/44] Made decodeStoredItem detect item type Not tested because SB.config cant be used anymore :( --- src/config.ts | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/config.ts b/src/config.ts index a77a3807..ddf13fff 100644 --- a/src/config.ts +++ b/src/config.ts @@ -128,7 +128,7 @@ var Config: SBObject = { function encodeStoredItem(data) { // if data is SBMap convert to json for storing if(!(data instanceof SBMap)) return data; - return JSON.stringify(data); + return Array.from(data.entries()); } /** @@ -138,18 +138,19 @@ function encodeStoredItem(data) { * @param {*} data */ function decodeStoredItem(id: string, data) { - if(typeof data !== "string") return data; - - try { - let str = JSON.parse(data); - - if(!Array.isArray(str)) return data; - return new SBMap(id, str); - } catch(e) { + if(!Config.localConfig[id]) return data; - // If all else fails, return the data - return data; + if(Config.localConfig[id] instanceof SBMap) { + try { + if(!Array.isArray(data)) return data; + return new SBMap(id, data); + } catch(e) { + console.error("Failed to parse SBMap: "+ id); + } } + + // If all else fails, return the data + return data; } function configProxy(): any { @@ -240,4 +241,4 @@ function addDefaults() { // Sync config setupConfig(); -export default Config; \ No newline at end of file +export default Config; From 1c17464c94265e9a4f9fa0f43c5890c650c43169 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Tue, 4 Feb 2020 23:29:11 +0000 Subject: [PATCH 02/44] config => defaults --- src/config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config.ts b/src/config.ts index ddf13fff..411c9732 100644 --- a/src/config.ts +++ b/src/config.ts @@ -138,9 +138,9 @@ function encodeStoredItem(data) { * @param {*} data */ function decodeStoredItem(id: string, data) { - if(!Config.localConfig[id]) return data; + if(!Config.defaults[id]) return data; - if(Config.localConfig[id] instanceof SBMap) { + if(Config.defaults[id] instanceof SBMap) { try { if(!Array.isArray(data)) return data; return new SBMap(id, data); From be3a4a4e918cbaef44891c6c1ffb3f5582df8dce Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 8 Feb 2020 20:08:34 -0500 Subject: [PATCH 03/44] Added support for old format. --- src/config.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/config.ts b/src/config.ts index 411c9732..b2eda3be 100644 --- a/src/config.ts +++ b/src/config.ts @@ -148,6 +148,15 @@ function decodeStoredItem(id: string, data) { console.error("Failed to parse SBMap: "+ id); } } + + // This is the old format for SBMap (a JSON string) + if (typeof data === "string") { + let str = JSON.parse(data); + + if(Array.isArray(data)) { + return new SBMap(id, str) + } + } // If all else fails, return the data return data; From 94af8ab301fb81ee7a9c15b8b54affd3488695ee Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 8 Feb 2020 20:15:49 -0500 Subject: [PATCH 04/44] Prevent all strings from being parsed as JSON. --- src/config.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/config.ts b/src/config.ts index b2eda3be..8fb2802d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -84,7 +84,6 @@ class SBMap extends Map { } } - var Config: SBObject = { /** * Callback function when an option is updated @@ -138,11 +137,11 @@ function encodeStoredItem(data) { * @param {*} data */ function decodeStoredItem(id: string, data) { - if(!Config.defaults[id]) return data; + if (!Config.defaults[id]) return data; - if(Config.defaults[id] instanceof SBMap) { + if (Config.defaults[id] instanceof SBMap) { try { - if(!Array.isArray(data)) return data; + if (!Array.isArray(data)) return data; return new SBMap(id, data); } catch(e) { console.error("Failed to parse SBMap: "+ id); @@ -151,10 +150,14 @@ function decodeStoredItem(id: string, data) { // This is the old format for SBMap (a JSON string) if (typeof data === "string") { - let str = JSON.parse(data); + try { + let str = JSON.parse(data); - if(Array.isArray(data)) { - return new SBMap(id, str) + if (Array.isArray(data)) { + return new SBMap(id, str); + } + } catch(e) { + // Continue normally (out of this if statement) } } From 8cdbebd6de1db74b7ac0b08b183201ce72ddb032 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 8 Feb 2020 20:16:26 -0500 Subject: [PATCH 05/44] Added the config as a global variable. --- src/config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/config.ts b/src/config.ts index 8fb2802d..7ad42afd 100644 --- a/src/config.ts +++ b/src/config.ts @@ -254,3 +254,6 @@ function addDefaults() { setupConfig(); export default Config; + +// Make the config public for debugging purposes +( window).SB = Config; \ No newline at end of file From 88a8fda566da1e5bd7c8c83e9ac50b0519274c61 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 14 Feb 2020 23:16:01 -0500 Subject: [PATCH 06/44] Moved window.SB creation for security reasons. --- src/background.ts | 3 +++ src/config.ts | 5 +---- src/options.ts | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/background.ts b/src/background.ts index 89516287..304902ad 100644 --- a/src/background.ts +++ b/src/background.ts @@ -1,5 +1,8 @@ import * as Types from "./types"; + import Config from "./config"; +// Make the config public for debugging purposes +( window).SB = Config; import Utils from "./utils"; var utils = new Utils({ diff --git a/src/config.ts b/src/config.ts index 555aadcd..7fa11084 100644 --- a/src/config.ts +++ b/src/config.ts @@ -263,7 +263,4 @@ function addDefaults() { // Sync config setupConfig(); -export default Config; - -// Make the config public for debugging purposes -( window).SB = Config; \ No newline at end of file +export default Config; \ No newline at end of file diff --git a/src/options.ts b/src/options.ts index 1836c6c3..0836090c 100644 --- a/src/options.ts +++ b/src/options.ts @@ -1,4 +1,6 @@ import Config from "./config"; +// Make the config public for debugging purposes +( window).SB = Config; import Utils from "./utils"; var utils = new Utils(); From 8d82a6a3e662c46e1004120d441455ed211ba25b Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 14 Feb 2020 23:20:11 -0500 Subject: [PATCH 07/44] Fixed data old format migration. --- src/config.ts | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/config.ts b/src/config.ts index 7fa11084..abbd202a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -84,10 +84,6 @@ class SBMap extends Map { return result; } - - toJSON() { - return Array.from(this.entries()); - } } var Config: SBObject = { @@ -130,7 +126,7 @@ var Config: SBObject = { /** * A SBMap cannot be stored in the chrome storage. - * This data will be encoded into an array instead as specified by the toJSON function. + * This data will be encoded into an array instead * * @param data */ @@ -151,26 +147,24 @@ function decodeStoredItem(id: string, data) { if (Config.defaults[id] instanceof SBMap) { try { - if (!Array.isArray(data)) return data; - return new SBMap(id, data); - } catch(e) { - console.error("Failed to parse SBMap: "+ id); - } - } + let jsonData: any = data; - // This is the old format for SBMap (a JSON string) - if (typeof data === "string") { - try { - let str = JSON.parse(data); - - if (Array.isArray(data)) { - return new SBMap(id, str); + // Check if data is stored in the old format for SBMap (a JSON string) + if (typeof data === "string") { + try { + jsonData = JSON.parse(data); + } catch(e) { + // Continue normally (out of this if statement) + } } + + if (!Array.isArray(jsonData)) return data; + return new SBMap(id, jsonData); } catch(e) { - // Continue normally (out of this if statement) + console.error("Failed to parse SBMap: " + id); } } - + // If all else fails, return the data return data; } From d0a34d423cb7b8db20d3db32c2252083a24914c2 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 23 Feb 2020 20:42:12 -0500 Subject: [PATCH 08/44] Fix release CI --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1bb05345..3714e6b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: steps: # Build Artifacts - name: Build Artifacts - uses: ./.github/workflows/ci + uses: ./.github/workflows/ci.yml # Upload each release asset - name: Upload to release From 7fbd89159e7e5a47e02f5f854a76afd43a81c6b8 Mon Sep 17 00:00:00 2001 From: Joe Dowd Date: Tue, 25 Feb 2020 18:25:28 +0000 Subject: [PATCH 09/44] Typo in en messages locale skipped --- public/_locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index 6a337fb8..0e655c82 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -385,7 +385,7 @@ "message": "Minimum duration (seconds):" }, "minDurationDescription": { - "message": "Sponsor segments shorter than the set value will not be skipeed or show in the player." + "message": "Sponsor segments shorter than the set value will not be skipped or show in the player." }, "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?" From 51580202934c40337ef9c1b2e1fadab6661a4fea Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 27 Feb 2020 22:20:30 -0500 Subject: [PATCH 10/44] Potentially fixed zero second skip spam --- manifest/manifest.json | 2 +- src/content.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/manifest/manifest.json b/manifest/manifest.json index 5e25732d..9b46873a 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.2.16", + "version": "1.2.17", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [{ diff --git a/src/content.ts b/src/content.ts index dcf8395f..65a31f6b 100644 --- a/src/content.ts +++ b/src/content.ts @@ -44,6 +44,9 @@ var lastPreviewBarUpdate; //whether the duration listener listening for the duration changes of the video has been setup yet var durationListenerSetUp = false; +// Has a zero second sponsor been skipped yet +var skippedZeroSecond = false; + //the channel this video is about var channelURL; @@ -247,6 +250,8 @@ function resetValues() { //reset sponsor data found check sponsorDataFound = false; + + skippedZeroSecond = false; } async function videoIDChange(id) { @@ -455,6 +460,8 @@ function startSponsorSchedule(currentTime?: number): void { let skippingFunction = () => { if (video.currentTime >= skipTime[0] && video.currentTime < skipTime[1]) { + if (currentTime == 0) skippedZeroSecond = true; + skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice); } @@ -562,7 +569,7 @@ function sponsorsLookup(id: string, channelIDPromise?) { } } - if (zeroSecondSponsor) { + if (zeroSecondSponsor && !skippedZeroSecond) { startSponsorSchedule(0); } else { startSponsorSchedule(); From 329b1884358b783c652fcbc3b23d3677ed490b8d Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 27 Feb 2020 22:23:33 -0500 Subject: [PATCH 11/44] Checkout before using other CI --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1bb05345..2947d9ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,7 @@ jobs: steps: # Build Artifacts + - uses: actions/checkout@v1 - name: Build Artifacts uses: ./.github/workflows/ci From 0241e15691de06820697b187d772b700c88bd82c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 28 Feb 2020 15:06:08 -0500 Subject: [PATCH 12/44] Only seek if the video is not paused --- src/content.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index 65a31f6b..be4456d8 100644 --- a/src/content.ts +++ b/src/content.ts @@ -493,8 +493,10 @@ function sponsorsLookup(id: string, channelIDPromise?) { if (!seekListenerSetUp && !Config.config.disableSkipping) { seekListenerSetUp = true; - video.addEventListener('seeked', () => startSponsorSchedule()); video.addEventListener('play', () => startSponsorSchedule()); + video.addEventListener('seeked', () => { + if (!video.paused) startSponsorSchedule() + }); video.addEventListener('ratechange', () => startSponsorSchedule()); video.addEventListener('seeking', cancelSponsorSchedule); video.addEventListener('pause', cancelSponsorSchedule); From ad25bc34de087c33214b0b40d8cc183760d035d7 Mon Sep 17 00:00:00 2001 From: Grishka Date: Sat, 7 Mar 2020 13:37:58 +0300 Subject: [PATCH 13/44] Add missing Russian strings --- public/_locales/en/messages.json | 4 +- public/_locales/ru/messages.json | 294 +++++++++++++++++++++++++++++++ 2 files changed, 296 insertions(+), 2 deletions(-) diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index b49c0bce..07820505 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -160,7 +160,7 @@ "message": "Click the button below when the sponsorship starts and ends to record and\nsubmit it to the database." }, "popupHint": { - "message": "Hint: Press the semicolon key while focused on a video report the start/end of a sponsor and quote to submit. (This can be changed in the options)" + "message": "Hint: Press the semicolon key while focused on a video to report the start/end of a sponsor and quote to submit. (This can be changed in the options)" }, "lastTimes": { "message": "Latest Sponsor Message Times Chosen" @@ -226,7 +226,7 @@ "message": "Show Notice Again" }, "longDescription": { - "message": "SponsorBlock is an extension that will skip over sponsored segments of YouTube videos. SponsorBlock is a crowdsourced browser extension that let's anyone submit the start and end time's of sponsored segments of YouTube videos. Once one person submits this information, everyone else with this extension will skip right over the sponsored segment.", + "message": "SponsorBlock is an extension that will skip over sponsored segments of YouTube videos. SponsorBlock is a crowdsourced browser extension that lets anyone submit the start and end times of sponsored segments of YouTube videos. Once one person submits this information, everyone else with this extension will skip right over the sponsored segment.", "description": "Full description of the extension on the store pages." }, "website": { diff --git a/public/_locales/ru/messages.json b/public/_locales/ru/messages.json index e6c0c9c3..7fda044f 100644 --- a/public/_locales/ru/messages.json +++ b/public/_locales/ru/messages.json @@ -123,5 +123,299 @@ }, "submitCheck": { "message": "Вы уверены, что хотите отправить эту информацию?" + }, + "whitelistChannel": { + "message": "Добавить канал в белый список" + }, + "removeFromWhitelist": { + "message": "Удалить канал из белого списка" + }, + "voteOnTime": { + "message": "Проголосовать за время спонсорской вставки" + }, + "recordTimes": { + "message": "Записать время спонсорской вставки" + }, + "soFarUHSubmited": { + "message": "На данный момент Вы отправили" + }, + "savedPeopleFrom": { + "message": "Вы помогли людям сэкономить " + }, + "viewLeaderboard": { + "message": "Посмотреть доску почёта" + }, + "here": { + "message": "здесь" + }, + "recordTimesDescription": { + "message": "Нажмите кнопку ниже, когда спонсорская вставка начинается и заканчивается, чтобы записать\nи отправить её в базу данных." + }, + "popupHint": { + "message": "Подсказка: нажмите ;, чтобы сообщить начало/конец спонсорской вставки, и \", чтобы отправить. (Это можно изменить в настройках)" + }, + "lastTimes": { + "message": "Последнее выбранное время спонсорской вставки" + }, + "clearTimesButton": { + "message": "Очистить время" + }, + "submitTimesButton": { + "message": "Отправить время" + }, + "publicStats": { + "message": "Оно используется на публичной странице статистики, чтобы показать Ваш вклад. Её можно посмотреть " + }, + "setUsername": { + "message": "Установить имя пользователя" + }, + "discordAdvert": { + "message": "Присоединяйтесь к официальному серверу Discord, чтобы оставить предложения и обратную связь!" + }, + "hideThis": { + "message": "Скрыть это" + }, + "Options": { + "message": "Настройки" + }, + "showButtons": { + "message": "Показывать кнопки в плеере YouTube" + }, + "hideButtons": { + "message": "Скрыть кнопки в плеере YouTube" + }, + "hideButtonsDescription": { + "message": "Эта настройка скрывает кнопки для отправки спонсорских вставок, которые появляются в плеере YouTube. Они могут раздражать\n некоторых. Вместо кнопок для отправки спонсорских вставок можно использовать это всплывающее окно. Чтобы скрыть\nуведомление, нажмите кнопку \"Не показывать снова\" в уведомлении. Вы всегда сможете включить эти настройки обратно." + }, + "showInfoButton": { + "message": "Показывать кнопку информации в плеере YouTube" + }, + "hideInfoButton": { + "message": "Скрыть кнопку информации в плеере YouTube" + }, + "whatInfoButton": { + "message": "Эта кнопка открывает всплывающее окно на странице YouTube." + }, + "hideDeleteButton": { + "message": "Скрыть кнопку удаления в плеере YouTube" + }, + "showDeleteButton": { + "message": "Показывать кнопку удаления в плеере YouTube" + }, + "whatDeleteButton": { + "message": "Эта кнопка позволяет Вам очистить все спонсорские вставки в плеере YouTube." + }, + "disableViewTracking": { + "message": "Отключить отслеживание количества пропусков спонсорских вставок" + }, + "enableViewTracking": { + "message": "Включить отслеживание количества пропусков спонсорских вставок" + }, + "whatViewTracking": { + "message": "Эта возможность отслеживает, какие спонсорские вставки Вы пропустили, чтобы помочь пользователям узнать, насколько их\nвклад помог другим, и используется как метрика, чтобы убедиться, что спам не попадает в базу данных. Расширение отправляет\nсообщение на сервер каждый раз, когда Вы пропускаете спонсорскую вставку. Надеемся, большая часть пользователей не поменяет эту настройку, так что у нас будет точная статистика просмотров :)" + }, + "showNotice": { + "message": "Показывать уведомление снова" + }, + "longDescription": { + "message": "SponsorBlock — это расширение, которое пропускает спонсорские вставки в видео на YouTube. SponsorBlock — это краудсорсинговое расширение, которое позволяет каждому отправить время начала и конца спонсорских сегментов в видео на YouTube. После того, как кто-нибудь отправляет эту информацию, все остальные пользователи расширения будут автоматически пропускать спонсорские сегменты.", + "description": "Полное описание расширения на страницах магазинов." + }, + "website": { + "message": "Сайт", + "description": "Используется на странице магазина Firefox" + }, + "sourceCode": { + "message": "Исходный код", + "description": "Используется на странице магазина Firefox" + }, + "noticeUpdate": { + "message": "Уведомление было обновлено!", + "description": "The first line of the message displayed after the notice was upgraded." + }, + "noticeUpdate2": { + "message": "Если оно Вам всё равно не нравится, нажмите \"не показывать\".", + "description": "The second line of the message displayed after the notice was upgraded." + }, + "setStartSponsorShortcut": { + "message": "Назначить горячую клавишу для начала спонсорской вставки" + }, + "setSubmitKeybind": { + "message": "Назначить горячую клавишу для отправки" + }, + "keybindDescription": { + "message": "Нажмите клавишу, чтобы выбрать её" + }, + "keybindDescriptionComplete": { + "message": "Клавиша назначена на: " + }, + "0": { + "message": "Таймаут подключения. Проверьте ваше соединение с интернетом. Если ваш интернет работает, сервер, скорее всего, перегружен или лежит." + }, + "disableSkipping": { + "message": "Отключить SponsorBlock" + }, + "enableSkipping": { + "message": "Включить SponsorBlock" + }, + "yourWork": { + "message": "Ваша работа", + "description": "Used to describe the section that will show you the statistics from your submissions." + }, + "502": { + "message": "Похоже, сервер перегружен. Попробуйте ещё раз через несколько секунд." + }, + "errorCode": { + "message": "Код ошибки: " + }, + "noticeTitleNotSkipped": { + "message": "Пропустить спонсорскую вставку?" + }, + "skip": { + "message": "Пропустить" + }, + "disableAutoSkip": { + "message": "Отключить автоматический пропуск" + }, + "enableAutoSkip": { + "message": "Включить автоматический пропуск" + }, + "autoSkipDescription": { + "message": "Автоматический пропуск будет пропускать спонсорские вставки за Вас. Если выключено, будет показываться уведомление с предложением пропустить." + }, + "youHaveSkipped": { + "message": "Вы пропустили " + }, + "youHaveSaved": { + "message": "Вы сэкономили " + }, + "minLower": { + "message": "минуту" + }, + "minsLower": { + "message": "минут" + }, + "hourLower": { + "message": "час" + }, + "hoursLower": { + "message": "часов" + }, + "youHaveSavedTime": { + "message": "Вы сэкономили людям" + }, + "youHaveSavedTimeEnd": { + "message": " их жизней." + }, + "guildlinesSummary": { + "message": "- Убедитесь, что Ваш сегмент содержит только платную интеграцию, и больше ничего.\n- Убедитесь, что пропуск этого сегмента не пропустит никакой ценный контент\n- Если всё видео целиком спонсорское, пожалуйста, не сообщайте о нём. Система для сообщения о целых видео скоро выйдет.\n- Пожалуйста, не сообщайте об отказах от ответственности, которые могут показать предвзятость (если видео с обзором проплачено, не пропускайте, когда они это упоминают)." + }, + "statusReminder": { + "message": "Смотрите состояние сервера на status.sponsor.ajay.app." + }, + "changeUserID": { + "message": "Импортировать/экспортировать Ваш идентификатор пользователя" + }, + "whatChangeUserID": { + "message": "Это нужно держать в секрете. Это как пароль, не стоит им ни с кем делиться. Если он у кого-то есть, он сможет выдать себя за Вас." + }, + "setUserID": { + "message": "Установить идентификатор пользователя" + }, + "userIDChangeWarning": { + "message": "Внимание: изменение идентификатора пользователя необратимо. Вы действительно хотите это сделать? Сделайте резервную копию вашего старого на всякий случай." + }, + "createdBy": { + "message": "Создано" + }, + "autoSkip": { + "message": "Автоматический пропуск" + }, + "showSkipNotice": { + "message": "Показывать уведомление после пропуска спонсорской вставки" + }, + "keybindCurrentlySet": { + "message": ". Он сейчас назначен на:" + }, + "supportInvidious": { + "message": "Поддержка Invidious" + }, + "supportInvidiousDescription": { + "message": "Invidious (invidio.us) — это неофициальный клиент YouTube. Чтобы включить поддержку, Вам понадобится принять дополнительные разрешения. Это НЕ работает в приватном режиме в Chrome и других вариантах Chromium." + }, + "optionsInfo": { + "message": "Включить поддержку Invidious, выключить автоматический пропуск, скрыть кнопки и не только." + }, + "addInvidiousInstance": { + "message": "Добавить инстанс Invidious" + }, + "addInvidiousInstanceDescription": { + "message": "Добавить свой инстанс Invidious. Формат: ТОЛЬКО домен. Например, invidious.ajay.app" + }, + "add": { + "message": "Добавить" + }, + "addInvidiousInstanceError": { + "message": "Это неправильный домен. Введите ТОЛЬКО домен. Например, invidious.ajay.app" + }, + "resetInvidiousInstance": { + "message": "Сбросить список инстансов Invidious" + }, + "resetInvidiousInstanceAlert": { + "message": "Вы собираетесь сбросить список инстансов Invidious" + }, + "currentInstances": { + "message": "Текущие инстансы:" + }, + "enableAutoUpvote": { + "message": "Автоматически голосовать \"за\"" + }, + "whatAutoUpvote": { + "message": "Если это включено, расширение будет голосовать \"за\" все предложения других пользователей, если Вы на них не пожалуетесь. Если уведомление отключено, это не будет происходить." + }, + "minDuration": { + "message": "Минимальная длительность (секунд):" + }, + "minDurationDescription": { + "message": "Спонсорские сегменты короче этого значения не будут пропускаться и не будут показаны в плеере." + }, + "shortCheck": { + "message": "Следующий диапазон времени короче, чем Ваша настройка минимальной длительности. Это может означать, что он уже был отправлен, и просто игнорируется из-за этой настройки. Вы действительно хотите отправить?" + }, + "showUploadButton": { + "message": "Показывать кнопку отправки" + }, + "whatUploadButton": { + "message": "Эта кнопка появляется в плеере YouTube после того, как Вы выбрали отметку времени и готовы к отправке." + }, + "customServerAddress": { + "message": "Адрес сервера SponsorBlock" + }, + "customServerAddressDescription": { + "message": "Адрес, по которому SponsorBlock обращается к серверу.\nМеняйте только если Вы подняли свой сервер." + }, + "save": { + "message": "Сохранить" + }, + "reset": { + "message": "Сбросить" + }, + "customAddressError": { + "message": "Этот адрес неправильного формата. Убедитесь, что он начинается с http:// или https://, и что на конце нет слэшей." + }, + "areYouSureReset": { + "message": "Вы действительно хотите это сбросить?" + }, + "confirmPrivacy": { + "message": "Было обнаружено, что это видео непубличное. Нажмите \"отмена\", если не хотите проверять его на спонсоров." + }, + "unlistedCheck": { + "message": "Игнорировать непубличные видео" + }, + "whatUnlistedCheck": { + "message": "Эта настройка значительно замедлит SponsorBlock. Поиск спонсоров требует отправки идентификатора видео на сервер. Если Вас беспокоит отправка идентификаторов непубличных видео по интернету, включите эту настройку." + }, + "mobileUpdateInfo": { + "message": "m.youtube.com теперь поддерживается" } } From 3c63644213b3283024f9c50b8bc10dfc660672d9 Mon Sep 17 00:00:00 2001 From: Grishka Date: Sat, 7 Mar 2020 13:45:56 +0300 Subject: [PATCH 14/44] fix --- public/_locales/ru/messages.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/_locales/ru/messages.json b/public/_locales/ru/messages.json index 7fda044f..f2bece6b 100644 --- a/public/_locales/ru/messages.json +++ b/public/_locales/ru/messages.json @@ -28,10 +28,10 @@ "message": "Канал добавлен в белый список!" }, "Sponsor": { - "message": "Спонсор" + "message": "спонсора" }, "Sponsors": { - "message": "Спонсоры" + "message": "спонсоров" }, "Segment": { "message": "спонсорская вставка" From a484f2f2ccb6b01b0b3a32176bf491d108d53b03 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 8 Mar 2020 23:16:09 -0400 Subject: [PATCH 15/44] Fixed double sponsor skip for zero second sponsors --- src/content.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/content.ts b/src/content.ts index be4456d8..16f732ea 100644 --- a/src/content.ts +++ b/src/content.ts @@ -44,8 +44,8 @@ var lastPreviewBarUpdate; //whether the duration listener listening for the duration changes of the video has been setup yet var durationListenerSetUp = false; -// Has a zero second sponsor been skipped yet -var skippedZeroSecond = false; +// Is the video currently being switched +var switchingVideos = false; //the channel this video is about var channelURL; @@ -250,8 +250,6 @@ function resetValues() { //reset sponsor data found check sponsorDataFound = false; - - skippedZeroSecond = false; } async function videoIDChange(id) { @@ -266,6 +264,8 @@ async function videoIDChange(id) { //id is not valid if (!id) return; + switchingVideos = true; + // Wait for options to be ready await utils.wait(() => Config.config !== null, 5000, 1); @@ -460,8 +460,6 @@ function startSponsorSchedule(currentTime?: number): void { let skippingFunction = () => { if (video.currentTime >= skipTime[0] && video.currentTime < skipTime[1]) { - if (currentTime == 0) skippedZeroSecond = true; - skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice); } @@ -493,9 +491,12 @@ function sponsorsLookup(id: string, channelIDPromise?) { if (!seekListenerSetUp && !Config.config.disableSkipping) { seekListenerSetUp = true; - video.addEventListener('play', () => startSponsorSchedule()); + video.addEventListener('play', () => { + switchingVideos = false; + startSponsorSchedule(); + }); video.addEventListener('seeked', () => { - if (!video.paused) startSponsorSchedule() + if (!video.paused) startSponsorSchedule(); }); video.addEventListener('ratechange', () => startSponsorSchedule()); video.addEventListener('seeking', cancelSponsorSchedule); @@ -571,10 +572,12 @@ function sponsorsLookup(id: string, channelIDPromise?) { } } - if (zeroSecondSponsor && !skippedZeroSecond) { - startSponsorSchedule(0); - } else { - startSponsorSchedule(); + if (!video.paused && !switchingVideos) { + if (zeroSecondSponsor) { + startSponsorSchedule(0); + } else { + startSponsorSchedule(); + } } // Reset skip save From ae94811a0024fd106cdf2d1dd0ceec4f9fece7cf Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 8 Mar 2020 23:16:50 -0400 Subject: [PATCH 16/44] Increase version number --- manifest/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest/manifest.json b/manifest/manifest.json index 9b46873a..81387422 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.2.17", + "version": "1.2.18", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [{ From d7f7acb219aebaf392d2083caebb2d569ed1aad9 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 8 Mar 2020 23:20:41 -0400 Subject: [PATCH 17/44] Fixed release action --- .github/workflows/{ci.yml => ci/action.yml} | 0 .github/workflows/release.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{ci.yml => ci/action.yml} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci/action.yml similarity index 100% rename from .github/workflows/ci.yml rename to .github/workflows/ci/action.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fe17a089..8ee5baf0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: # Build Artifacts - uses: actions/checkout@v1 - name: Build Artifacts - uses: ./.github/workflows/ci.yml + uses: ./.github/workflows/ci/ # Upload each release asset - name: Upload to release From 5ad694af65040a6224841143678d17b6f5b2217c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 8 Mar 2020 23:26:46 -0400 Subject: [PATCH 18/44] Increase version number --- manifest/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest/manifest.json b/manifest/manifest.json index 81387422..02243448 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.2.18", + "version": "1.2.19", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [{ From 73e8926444563eb89a7396c7a70fd33b0a590389 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 10:43:13 -0400 Subject: [PATCH 19/44] Start skip schedule from skip time to prevent slow video updates from breaking it. --- src/content.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index 16f732ea..8488242b 100644 --- a/src/content.ts +++ b/src/content.ts @@ -463,7 +463,7 @@ function startSponsorSchedule(currentTime?: number): void { skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice); } - startSponsorSchedule(); + startSponsorSchedule(skipTime[1]); }; if (timeUntilSponsor <= 0) { From d5f41bf4add31820f6e9acb0845b9473a05c80f5 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 10:49:50 -0400 Subject: [PATCH 20/44] Fixed CI --- .github/ci.yml | 13 +++++++++++++ .github/workflows/ci/action.yml | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .github/ci.yml diff --git a/.github/ci.yml b/.github/ci.yml new file mode 100644 index 00000000..35836a8f --- /dev/null +++ b/.github/ci.yml @@ -0,0 +1,13 @@ +name: CI + +on: [push, pull_request] + +jobs: + + build: + name: Create artifacts + runs-on: ubuntu-latest + + steps: + - uses: ./.github/workflows/ci/ + diff --git a/.github/workflows/ci/action.yml b/.github/workflows/ci/action.yml index 60e01530..e1dc35a0 100644 --- a/.github/workflows/ci/action.yml +++ b/.github/workflows/ci/action.yml @@ -1,7 +1,5 @@ name: CI -on: [push, pull_request] - jobs: build: From 44ca8d47d827ca60ed1861129aaf71cc51402ae9 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 10:51:26 -0400 Subject: [PATCH 21/44] Moved CI into the right place --- .github/{ => workflows}/ci.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/ci.yml (100%) diff --git a/.github/ci.yml b/.github/workflows/ci.yml similarity index 100% rename from .github/ci.yml rename to .github/workflows/ci.yml From d6410663129f8216d9b470a23bbfacf776dd789d Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 10:52:43 -0400 Subject: [PATCH 22/44] Checkout in CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35836a8f..0f0211e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,5 +9,6 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v1 - uses: ./.github/workflows/ci/ From 7b5703aa040d756e729be25a1297521dc4173e47 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 10:56:06 -0400 Subject: [PATCH 23/44] Fixed action format --- .github/workflows/ci/action.yml | 102 ++++++++++++++++---------------- 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci/action.yml b/.github/workflows/ci/action.yml index e1dc35a0..b2ac5b87 100644 --- a/.github/workflows/ci/action.yml +++ b/.github/workflows/ci/action.yml @@ -1,60 +1,58 @@ name: CI -jobs: +runs: + name: Create artifacts + runs-on: ubuntu-latest - build: - name: Create artifacts - runs-on: ubuntu-latest + steps: + # Initialization + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + - run: npm install + - name: Copy configuration + run: cp config.json.example config.json - steps: - # Initialization - - uses: actions/checkout@v1 - - uses: actions/setup-node@v1 - - run: npm install - - name: Copy configuration - run: cp config.json.example config.json + # Create Chrome artifacts + - name: Create Chrome artifacts + run: npm run build:chrome + - uses: actions/upload-artifact@v1 + with: + name: ChromeExtension + path: dist + - run: mkdir ./builds + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/ChromeExtension.zip ./dist - # Create Chrome artifacts - - name: Create Chrome artifacts - run: npm run build:chrome - - uses: actions/upload-artifact@v1 - with: - name: ChromeExtension - path: dist - - run: mkdir ./builds - - uses: montudor/action-zip@v0.1.0 - with: - args: zip -qq -r ./builds/ChromeExtension.zip ./dist + # Create Firefox artifacts + - name: Create Firefox artifacts + run: npm run build:firefox + - uses: actions/upload-artifact@v1 + with: + name: FirefoxExtension + path: dist + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/FirefoxExtension.zip ./dist - # Create Firefox artifacts - - name: Create Firefox artifacts - run: npm run build:firefox - - uses: actions/upload-artifact@v1 - with: - name: FirefoxExtension - path: dist - - uses: montudor/action-zip@v0.1.0 - with: - args: zip -qq -r ./builds/FirefoxExtension.zip ./dist + # Create Beta artifacts (Builds with the name changed to beta) + - name: Create Chrome Beta artifacts + run: npm run build:chrome -- --env.stream=beta + - uses: actions/upload-artifact@v1 + with: + name: ChromeExtensionBeta + path: dist + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/ChromeExtensionBeta.zip ./dist - # Create Beta artifacts (Builds with the name changed to beta) - - name: Create Chrome Beta artifacts - run: npm run build:chrome -- --env.stream=beta - - uses: actions/upload-artifact@v1 - with: - name: ChromeExtensionBeta - path: dist - - uses: montudor/action-zip@v0.1.0 - with: - args: zip -qq -r ./builds/ChromeExtensionBeta.zip ./dist - - - name: Create Firefox Beta artifacts - run: npm run build:firefox -- --env.stream=beta - - uses: actions/upload-artifact@v1 - with: - name: FirefoxExtensionBeta - path: dist - - uses: montudor/action-zip@v0.1.0 - with: - args: zip -qq -r ./builds/FirefoxExtensionBeta.zip ./dist + - name: Create Firefox Beta artifacts + run: npm run build:firefox -- --env.stream=beta + - uses: actions/upload-artifact@v1 + with: + name: FirefoxExtensionBeta + path: dist + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/FirefoxExtensionBeta.zip ./dist From f63abb053d12d7ccdd09ce52f5a74f45f51e134f Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 11:02:14 -0400 Subject: [PATCH 24/44] Revert to only using workflows --- .github/workflows/ci.yml | 52 +++++++++++++++++++++++++++-- .github/workflows/ci/action.yml | 58 --------------------------------- .github/workflows/release.yml | 52 +++++++++++++++++++++++++++-- 3 files changed, 99 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/ci/action.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f0211e9..60e01530 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,54 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: ./.github/workflows/ci/ + # Initialization + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + - run: npm install + - name: Copy configuration + run: cp config.json.example config.json + + # Create Chrome artifacts + - name: Create Chrome artifacts + run: npm run build:chrome + - uses: actions/upload-artifact@v1 + with: + name: ChromeExtension + path: dist + - run: mkdir ./builds + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/ChromeExtension.zip ./dist + + # Create Firefox artifacts + - name: Create Firefox artifacts + run: npm run build:firefox + - uses: actions/upload-artifact@v1 + with: + name: FirefoxExtension + path: dist + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/FirefoxExtension.zip ./dist + + # Create Beta artifacts (Builds with the name changed to beta) + - name: Create Chrome Beta artifacts + run: npm run build:chrome -- --env.stream=beta + - uses: actions/upload-artifact@v1 + with: + name: ChromeExtensionBeta + path: dist + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/ChromeExtensionBeta.zip ./dist + + - name: Create Firefox Beta artifacts + run: npm run build:firefox -- --env.stream=beta + - uses: actions/upload-artifact@v1 + with: + name: FirefoxExtensionBeta + path: dist + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/FirefoxExtensionBeta.zip ./dist diff --git a/.github/workflows/ci/action.yml b/.github/workflows/ci/action.yml deleted file mode 100644 index b2ac5b87..00000000 --- a/.github/workflows/ci/action.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: CI - -runs: - name: Create artifacts - runs-on: ubuntu-latest - - steps: - # Initialization - - uses: actions/checkout@v1 - - uses: actions/setup-node@v1 - - run: npm install - - name: Copy configuration - run: cp config.json.example config.json - - # Create Chrome artifacts - - name: Create Chrome artifacts - run: npm run build:chrome - - uses: actions/upload-artifact@v1 - with: - name: ChromeExtension - path: dist - - run: mkdir ./builds - - uses: montudor/action-zip@v0.1.0 - with: - args: zip -qq -r ./builds/ChromeExtension.zip ./dist - - # Create Firefox artifacts - - name: Create Firefox artifacts - run: npm run build:firefox - - uses: actions/upload-artifact@v1 - with: - name: FirefoxExtension - path: dist - - uses: montudor/action-zip@v0.1.0 - with: - args: zip -qq -r ./builds/FirefoxExtension.zip ./dist - - # Create Beta artifacts (Builds with the name changed to beta) - - name: Create Chrome Beta artifacts - run: npm run build:chrome -- --env.stream=beta - - uses: actions/upload-artifact@v1 - with: - name: ChromeExtensionBeta - path: dist - - uses: montudor/action-zip@v0.1.0 - with: - args: zip -qq -r ./builds/ChromeExtensionBeta.zip ./dist - - - name: Create Firefox Beta artifacts - run: npm run build:firefox -- --env.stream=beta - - uses: actions/upload-artifact@v1 - with: - name: FirefoxExtensionBeta - path: dist - - uses: montudor/action-zip@v0.1.0 - with: - args: zip -qq -r ./builds/FirefoxExtensionBeta.zip ./dist - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8ee5baf0..2e6d2a33 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,10 +9,56 @@ jobs: runs-on: ubuntu-latest steps: - # Build Artifacts + # Initialization - uses: actions/checkout@v1 - - name: Build Artifacts - uses: ./.github/workflows/ci/ + - uses: actions/setup-node@v1 + - run: npm install + - name: Copy configuration + run: cp config.json.example config.json + + # Create Chrome artifacts + - name: Create Chrome artifacts + run: npm run build:chrome + - uses: actions/upload-artifact@v1 + with: + name: ChromeExtension + path: dist + - run: mkdir ./builds + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/ChromeExtension.zip ./dist + + # Create Firefox artifacts + - name: Create Firefox artifacts + run: npm run build:firefox + - uses: actions/upload-artifact@v1 + with: + name: FirefoxExtension + path: dist + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/FirefoxExtension.zip ./dist + + # Create Beta artifacts (Builds with the name changed to beta) + - name: Create Chrome Beta artifacts + run: npm run build:chrome -- --env.stream=beta + - uses: actions/upload-artifact@v1 + with: + name: ChromeExtensionBeta + path: dist + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/ChromeExtensionBeta.zip ./dist + + - name: Create Firefox Beta artifacts + run: npm run build:firefox -- --env.stream=beta + - uses: actions/upload-artifact@v1 + with: + name: FirefoxExtensionBeta + path: dist + - uses: montudor/action-zip@v0.1.0 + with: + args: zip -qq -r ./builds/FirefoxExtensionBeta.zip ./dist # Upload each release asset - name: Upload to release From 50517eb462a14309440e2b946d135518f3846580 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 11:15:29 -0400 Subject: [PATCH 25/44] Switched upload to release action --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2e6d2a33..b3aaacaf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,15 +62,15 @@ jobs: # Upload each release asset - name: Upload to release - uses: JasonEtco/upload-to-release@master + uses: Shopify/upload-to-release@master with: - args: ./builds/ChromeExtension.zip + args: builds/ChromeExtension.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload to release - uses: JasonEtco/upload-to-release@master + uses: Shopify/upload-to-release@master with: - args: ./builds/FirefoxExtension.zip + args: builds/FirefoxExtension.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 760c08dd0c2311f15637fad5d9b073f9ed6b3279 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 18:07:06 -0400 Subject: [PATCH 26/44] Prevent manual skips from triggering a view --- src/content.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/content.ts b/src/content.ts index 8488242b..ef3474e6 100644 --- a/src/content.ts +++ b/src/content.ts @@ -848,16 +848,14 @@ function skipToTime(v, index, sponsorTimes, openNotice) { } //send telemetry that a this sponsor was skipped - if (Config.config.trackViewCount && !sponsorSkipped[index]) { + if (Config.config.trackViewCount && !sponsorSkipped[index] && !Config.config.disableAutoSkip) { utils.sendRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + currentUUID); - if (!Config.config.disableAutoSkip) { - // Count this as a skip - Config.config.minutesSaved = Config.config.minutesSaved + (sponsorTimes[index][1] - sponsorTimes[index][0]) / 60; - Config.config.skipCount = Config.config.skipCount + 1; + // Count this as a skip + Config.config.minutesSaved = Config.config.minutesSaved + (sponsorTimes[index][1] - sponsorTimes[index][0]) / 60; + Config.config.skipCount = Config.config.skipCount + 1; - sponsorSkipped[index] = true; - } + sponsorSkipped[index] = true; } } } From d2bb4b38e353ee5cf4542a918d3b6025d2d4c7d4 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 18:07:29 -0400 Subject: [PATCH 27/44] Increased version number --- manifest/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest/manifest.json b/manifest/manifest.json index 02243448..409c78fa 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.2.19", + "version": "1.2.20", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [{ From ff9b2338e0341fbfb175881ee75c50b488a8102f Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 18:12:05 -0400 Subject: [PATCH 28/44] Fixed scheduling being wrong when manual skip is enabled --- src/content.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index ef3474e6..7017fadc 100644 --- a/src/content.ts +++ b/src/content.ts @@ -463,7 +463,7 @@ function startSponsorSchedule(currentTime?: number): void { skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice); } - startSponsorSchedule(skipTime[1]); + startSponsorSchedule(skipTime[0] + 0.001); }; if (timeUntilSponsor <= 0) { From 0813aa4ba3443c0993dc05aadf41860a9890b162 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 18:30:57 -0400 Subject: [PATCH 29/44] Prevent release workflow from running multiple times --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b3aaacaf..dae30ed1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,8 @@ name: Upload Release Build -on: release +on: + release: + types: [published] jobs: From e6ea9f77e90703128e5d443565e9325f4ff0e67c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 18:34:33 -0400 Subject: [PATCH 30/44] Fixed skip scheduling for auto skip --- src/content.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index 7017fadc..e53e059b 100644 --- a/src/content.ts +++ b/src/content.ts @@ -463,7 +463,12 @@ function startSponsorSchedule(currentTime?: number): void { skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice); } - startSponsorSchedule(skipTime[0] + 0.001); + if (Config.config.disableAutoSkip) { + startSponsorSchedule(skipTime[0] + 0.001); + } else { + startSponsorSchedule(skipTime[1]); + } + }; if (timeUntilSponsor <= 0) { From efec8b320cdb36e493714dd4143e49442115c09b Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 18:38:02 -0400 Subject: [PATCH 31/44] Increase version num --- manifest/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest/manifest.json b/manifest/manifest.json index 409c78fa..022929c3 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.2.20", + "version": "1.2.21", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [{ From 09f244150c85c76994a46de862fe2c5879fd358e Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 23:00:39 -0400 Subject: [PATCH 32/44] Fixed skipping for non zero second sponsors. Also now using the playing event to fix issues with mobile YouTube skipping. --- src/content.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/content.ts b/src/content.ts index e53e059b..37212201 100644 --- a/src/content.ts +++ b/src/content.ts @@ -449,7 +449,7 @@ function startSponsorSchedule(currentTime?: number): void { return; } - if (currentTime === undefined) currentTime = video.currentTime; + if (currentTime === undefined || currentTime === null) currentTime = video.currentTime; let skipInfo = getNextSkipIndex(currentTime); @@ -459,16 +459,19 @@ function startSponsorSchedule(currentTime?: number): void { let timeUntilSponsor = skipTime[0] - currentTime; let skippingFunction = () => { + let forcedSkipTime: number = null; + if (video.currentTime >= skipTime[0] && video.currentTime < skipTime[1]) { skipToTime(video, skipInfo.index, skipInfo.array, skipInfo.openNotice); + + if (Config.config.disableAutoSkip) { + forcedSkipTime = skipTime[0] + 0.001; + } else { + forcedSkipTime = skipTime[1]; + } } - if (Config.config.disableAutoSkip) { - startSponsorSchedule(skipTime[0] + 0.001); - } else { - startSponsorSchedule(skipTime[1]); - } - + startSponsorSchedule(forcedSkipTime); }; if (timeUntilSponsor <= 0) { @@ -500,6 +503,7 @@ function sponsorsLookup(id: string, channelIDPromise?) { switchingVideos = false; startSponsorSchedule(); }); + video.addEventListener('playing', () => startSponsorSchedule()); video.addEventListener('seeked', () => { if (!video.paused) startSponsorSchedule(); }); From c0894afff98478a7b98b68c69281a7386948fb24 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 23:03:24 -0400 Subject: [PATCH 33/44] Prevent manual skipping votes from affecting to UI and happening when auto vote is off --- src/js-components/skipNotice.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/js-components/skipNotice.ts b/src/js-components/skipNotice.ts index 3e981851..ec55f9b7 100644 --- a/src/js-components/skipNotice.ts +++ b/src/js-components/skipNotice.ts @@ -1,5 +1,7 @@ 'use strict'; +import Config from "../config"; + /** * The notice that tells the user that a sponsor was just skipped */ @@ -305,7 +307,7 @@ class SkipNotice { if (this.manualSkip) { this.changeNoticeTitle(chrome.i18n.getMessage("noticeTitle")); - this.contentContainer().vote(1, this.UUID, this); + if (Config.config.autoUpvote) this.contentContainer().vote(1, this.UUID); } } From 50002cfbbdf4deda207e81cd0d1827ec2b414891 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 9 Mar 2020 23:10:59 -0400 Subject: [PATCH 34/44] Fix github token using the wrong key in release workflow --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dae30ed1..7765c18f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,11 +68,11 @@ jobs: with: args: builds/ChromeExtension.zip env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Upload to release uses: Shopify/upload-to-release@master with: args: builds/FirefoxExtension.zip env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} From 2ec47d52cd03028bda8a047699ab6f040be118c4 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 10 Mar 2020 00:33:50 -0400 Subject: [PATCH 35/44] Added basic options import/export --- public/_locales/en/messages.json | 15 ++++++++++++ public/options/options.html | 26 ++++++++++++++++++++ src/options.ts | 41 +++++++++++++++++++++++++++++--- 3 files changed, 79 insertions(+), 3 deletions(-) diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index b49c0bce..2dc611f5 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -425,5 +425,20 @@ }, "mobileUpdateInfo": { "message": "m.youtube.com is now supported" + }, + "exportOptions": { + "message": "Import/Export All Options" + }, + "whatExportOptions": { + "message": "This is your entire configuration in JSON. This includes your userID, so be sure to share this wisely." + }, + "setOptions": { + "message": "Set Options" + }, + "exportOptionsWarning": { + "message": "Warning: Changing the options is permanent and can break your install. Are you sure you would like to do this? Make sure to backup your old one just in case." + }, + "incorrectlyFormattedOptions": { + "message": "This JSON is not formatted correctly. Your options have not been changed." } } diff --git a/public/options/options.html b/public/options/options.html index 72916c3a..37139c31 100644 --- a/public/options/options.html +++ b/public/options/options.html @@ -305,6 +305,32 @@ +
+
+ +
+
+ __MSG_exportOptions__ +
+ +
+ +
__MSG_whatExportOptions__
+ + +
+

diff --git a/src/options.ts b/src/options.ts index 1836c6c3..466a57e6 100644 --- a/src/options.ts +++ b/src/options.ts @@ -345,15 +345,50 @@ function activatePrivateTextChange(element: HTMLElement) { element.querySelector(".option-hidden-section").classList.remove("hidden"); return; } - - textBox.value = Config.config[option]; + + let result = Config.config[option]; + + // See if anything extra must be done + switch (option) { + case "*": + result = JSON.stringify(Config.localConfig); + break; + } + + textBox.value = result; let setButton = element.querySelector(".text-change-set"); setButton.addEventListener("click", () => { let confirmMessage = element.getAttribute("confirm-message"); if (confirmMessage === null || confirm(chrome.i18n.getMessage(confirmMessage))) { - Config.config[option] = textBox.value; + + // See if anything extra must be done + switch (option) { + case "*": + try { + let newConfig = JSON.parse(textBox.value); + for (const key in newConfig) { + Config.config[key] = newConfig[key]; + } + + init(); + + if (newConfig.supportInvidious) { + let checkbox = document.querySelector("#support-invidious > label > label > input"); + + checkbox.checked = true; + invidiousOnClick(checkbox, "supportInvidious"); + } + + } catch (e) { + alert(chrome.i18n.getMessage("incorrectlyFormattedOptions")); + } + + break; + default: + Config.config[option] = textBox.value; + } } }); From f0bf0512590f748b6492396404b23783ab17e26c Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 10 Mar 2020 00:48:53 -0400 Subject: [PATCH 36/44] Properly ask for permissions when changing the server address --- src/options.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/options.ts b/src/options.ts index 466a57e6..27739702 100644 --- a/src/options.ts +++ b/src/options.ts @@ -72,7 +72,7 @@ async function init() { textChangeInput.value = Config.config[textChangeOption]; - textChangeSetButton.addEventListener("click", () => { + textChangeSetButton.addEventListener("click", async () => { // See if anything extra must be done switch (textChangeOption) { case "serverAddress": @@ -84,6 +84,18 @@ async function init() { return; } + // Permission needed on Firefox + if (utils.isFirefox()) { + let permissionSuccess = await new Promise((resolve, reject) => { + chrome.permissions.request({ + origins: [textChangeInput.value + "/"], + permissions: [] + }, resolve); + }); + + if (!permissionSuccess) return; + } + break; } From 140e324bf1d70b159caf09263a260167f0c373e1 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 10 Mar 2020 00:55:18 -0400 Subject: [PATCH 37/44] Update README.md --- README.md | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index cff448c6..ad49a474 100644 --- a/README.md +++ b/README.md @@ -40,32 +40,30 @@ The backend server code is available here: https://github.com/ajayyy/SponsorBloc It is a simple Sqlite database that will hold all the timing data. -To make sure that this project doesn't die, I have made the database publicly downloadable at https://api.sponsor.ajay.app/database.db. So, you can download a backup or get archive.org to take a backup for you if you want. +To make sure that this project doesn't die, I have made the database publicly downloadable at https://api.sponsor.ajay.app/database.db. You can download a backup or get archive.org to take a backup for you if you want. -Hopefully this project can be combined with projects like [this](https://github.com/Sponsoff/sponsorship_remover) and use this data to create a neural network to predict when sponsored segments happen. That project is sadly abandoned now, so I have decided to attempt to revive this idea. +The dataset and API are now being used [ports](https://github.com/ajayyy/SponsorBlock/wiki/Unofficial-Ports) as well as a [neural network](https://github.com/andrewzlee/NeuralBlock). + +A [previous project attempted to]((https://github.com/Sponsoff/sponsorship_remover) create a neural network to predict when sponsored segments happen. That project is sadly abandoned now, so I have decided to attempt to revive this idea starting from a crowd-sourced system instead. # API You can read the API docs [here](https://github.com/ajayyy/SponsorBlockServer#api-docs). -# Build Yourself +# Building -You can load this project as an unpacked extension. Make sure to rename the `config.json.example` file to `config.json` before installing. +There are also other build scripts available. Install `npm`, then run `npm install` in the repository to install dependencies. -There are also other build scripts available. Install `npm`, then run `npm install` in the repository. +Run `npm run build` to generate a Chrome extension. + +Use `npm run build:firefox` to generate a Firefox extension. + +The result is in `dist`. This can be loaded as an unpacked extension ## Developing with a clean profile Run `npm run dev` to run the extension using a clean browser profile with hot reloading. Use `npm run dev:firefox` for Firefox. This uses [`web-ext run`](https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#commands). -## Packing - -Run `npm run build` to generate a packed Chrome extension. - -Use `npm run build:firefox` to generate a Firefox extension. - -The result is in `dist`. - # Credit The awesome [Invidious API](https://github.com/omarroth/invidious/wiki/API) previously was used. From db1def623a68affdd7c482b7c6d5f46d4df4eb69 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 10 Mar 2020 00:56:58 -0400 Subject: [PATCH 38/44] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad49a474..f40a889a 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ The backend server code is available here: https://github.com/ajayyy/SponsorBloc It is a simple Sqlite database that will hold all the timing data. -To make sure that this project doesn't die, I have made the database publicly downloadable at https://api.sponsor.ajay.app/database.db. You can download a backup or get archive.org to take a backup for you if you want. +To make sure that this project doesn't die, I have made the database publicly downloadable at https://sponsor.ajay.app/database.db. You can download a backup or get archive.org to take a backup for you if you want. The dataset and API are now being used [ports](https://github.com/ajayyy/SponsorBlock/wiki/Unofficial-Ports) as well as a [neural network](https://github.com/andrewzlee/NeuralBlock). From 2967fce013d09f521c61bdc16d20b44c0e6d4334 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 10 Mar 2020 00:57:44 -0400 Subject: [PATCH 39/44] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f40a889a..59a2e7e2 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ To make sure that this project doesn't die, I have made the database publicly do The dataset and API are now being used [ports](https://github.com/ajayyy/SponsorBlock/wiki/Unofficial-Ports) as well as a [neural network](https://github.com/andrewzlee/NeuralBlock). -A [previous project attempted to]((https://github.com/Sponsoff/sponsorship_remover) create a neural network to predict when sponsored segments happen. That project is sadly abandoned now, so I have decided to attempt to revive this idea starting from a crowd-sourced system instead. +A [previous project](https://github.com/Sponsoff/sponsorship_remover) attempted to create a neural network to predict when sponsored segments happen. That project is sadly abandoned now, so I have decided to attempt to revive this idea starting from a crowd-sourced system instead. # API From 030256c9e1e38215c90002046371a51fc2614577 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 10 Mar 2020 02:14:00 -0400 Subject: [PATCH 40/44] Enable checkbox when the permission prompt is successful --- src/options.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/options.ts b/src/options.ts index 27739702..de804cde 100644 --- a/src/options.ts +++ b/src/options.ts @@ -271,6 +271,8 @@ function invidiousOnClick(checkbox: HTMLInputElement, option: string) { if (!granted) { Config.config[option] = false; checkbox.checked = false; + } else { + checkbox.checked = true; } }); } else { @@ -428,4 +430,4 @@ function validateServerAddress(input: string): string { } return input; -} \ No newline at end of file +} From 1e26faa57c9fba6e6984632dc02848e3cd8301e1 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 10 Mar 2020 12:11:08 -0400 Subject: [PATCH 41/44] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 59a2e7e2..543c0077 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ It is a simple Sqlite database that will hold all the timing data. To make sure that this project doesn't die, I have made the database publicly downloadable at https://sponsor.ajay.app/database.db. You can download a backup or get archive.org to take a backup for you if you want. -The dataset and API are now being used [ports](https://github.com/ajayyy/SponsorBlock/wiki/Unofficial-Ports) as well as a [neural network](https://github.com/andrewzlee/NeuralBlock). +The dataset and API are now being used in some [ports](https://github.com/ajayyy/SponsorBlock/wiki/Unofficial-Ports) as well as a [neural network](https://github.com/andrewzlee/NeuralBlock). A [previous project](https://github.com/Sponsoff/sponsorship_remover) attempted to create a neural network to predict when sponsored segments happen. That project is sadly abandoned now, so I have decided to attempt to revive this idea starting from a crowd-sourced system instead. From 191e9ceb6f4f71d149187f82d70414133d43086d Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 10 Mar 2020 23:22:17 -0400 Subject: [PATCH 42/44] Makes sure the playing and play listener both don't get called at the same time. This led to double notices. --- src/content.ts | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/content.ts b/src/content.ts index 37212201..7430bcd1 100644 --- a/src/content.ts +++ b/src/content.ts @@ -45,7 +45,12 @@ var lastPreviewBarUpdate; var durationListenerSetUp = false; // Is the video currently being switched -var switchingVideos = false; +var switchingVideos = null; + +// Used by the play and playing listeners to make sure two aren't +// called at the same time +var lastCheckTime = 0; +var lastCheckVideoTime = -1; //the channel this video is about var channelURL; @@ -238,6 +243,9 @@ document.onkeydown = function(e: KeyboardEvent){ } function resetValues() { + lastCheckTime = 0; + lastCheckVideoTime = -1; + //reset sponsor times sponsorTimes = null; UUIDs = []; @@ -250,6 +258,8 @@ function resetValues() { //reset sponsor data found check sponsorDataFound = false; + + if (switchingVideos !== null || true) switchingVideos = true; } async function videoIDChange(id) { @@ -264,8 +274,6 @@ async function videoIDChange(id) { //id is not valid if (!id) return; - switchingVideos = true; - // Wait for options to be ready await utils.wait(() => Config.config !== null, 5000, 1); @@ -501,9 +509,24 @@ function sponsorsLookup(id: string, channelIDPromise?) { video.addEventListener('play', () => { switchingVideos = false; - startSponsorSchedule(); + + // Make sure it doesn't get double called with the playing event + if (lastCheckVideoTime !== video.currentTime && Date.now() - lastCheckTime > 2000) { + lastCheckTime = Date.now(); + lastCheckVideoTime = video.currentTime; + + startSponsorSchedule(); + } + }); + video.addEventListener('playing', () => { + // Make sure it doesn't get double called with the play event + if (lastCheckVideoTime !== video.currentTime && Date.now() - lastCheckTime > 2000) { + lastCheckTime = Date.now(); + lastCheckVideoTime = video.currentTime; + + startSponsorSchedule(); + } }); - video.addEventListener('playing', () => startSponsorSchedule()); video.addEventListener('seeked', () => { if (!video.paused) startSponsorSchedule(); }); From 5595420be636e78e18c52e5a7415a0c2e1ae98f3 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 10 Mar 2020 23:22:57 -0400 Subject: [PATCH 43/44] Removed redundant if statement --- src/content.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index 7430bcd1..218a5401 100644 --- a/src/content.ts +++ b/src/content.ts @@ -259,7 +259,7 @@ function resetValues() { //reset sponsor data found check sponsorDataFound = false; - if (switchingVideos !== null || true) switchingVideos = true; + switchingVideos = true; } async function videoIDChange(id) { From 4a9ed1348e638ce9c157c31aa6b2a39b77168d1b Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 10 Mar 2020 23:23:10 -0400 Subject: [PATCH 44/44] Increase version number --- manifest/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest/manifest.json b/manifest/manifest.json index 022929c3..ea2cee9d 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.2.21", + "version": "1.2.22", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [{