diff options
author | Ajay Ramachandran <[email protected]> | 2019-08-21 20:01:43 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-21 20:01:43 -0400 |
commit | 0ae3820681764c4d33bb26674f9d025e283fae22 (patch) | |
tree | a43b71751d90c16e92c14aaa85a9939f5d728654 | |
parent | 86e96e59afae025849d857530875ba212dd75afa (diff) | |
parent | 283e4d053e3516c4cc518022a1c6255be78f3daa (diff) | |
download | SponsorBlock-0ae3820681764c4d33bb26674f9d025e283fae22.tar.gz SponsorBlock-0ae3820681764c4d33bb26674f9d025e283fae22.zip |
Merge pull request #127 from ajayyy/experimental1.1.2
Update master
-rw-r--r-- | _locales/en/messages.json | 3 | ||||
-rw-r--r-- | _locales/fr/messages.json | 129 | ||||
-rw-r--r-- | _locales/pt_BR/messages.json | 127 | ||||
-rw-r--r-- | _locales/ru/messages.json | 130 | ||||
-rw-r--r-- | background.js | 6 | ||||
-rw-r--r-- | content.css | 2 | ||||
-rw-r--r-- | content.js | 38 | ||||
-rw-r--r-- | manifest.json | 2 | ||||
-rw-r--r-- | utils.js | 29 | ||||
-rw-r--r-- | utils/previewBar.js | 4 | ||||
-rw-r--r-- | utils/skipNotice.js | 3 |
11 files changed, 443 insertions, 30 deletions
diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 00d65946..391c8d5e 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -123,5 +123,8 @@ }, "leftTimes": { "message": "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted)." + }, + "submitCheck": { + "message": "Are you sure you want to submit this?" } } diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json new file mode 100644 index 00000000..e15255f7 --- /dev/null +++ b/_locales/fr/messages.json @@ -0,0 +1,129 @@ +{ + "Name": { + "message": "SponsorBlock", + "description": "Name of the extension." + }, + "fullName": { + "message": "SponsorBlock pour YouTube - Enlève les endossements", + "description": "Name of the extension." + }, + + "Description": { + "message": "Enlève les endossements dans les vidéos YouTube. Soummettre les endossements dans les vidéos que vous regardez pour aidez les autres.", + "description": "Description of the extension." + }, + "helpPage": { + "message": "index_en.html" + }, + "400": { + "message": "Soumission invalide" + }, + "429": { + "message": "Vous avez soummetez trop de endossements, il y a vraiment cette montant?" + }, + "409": { + "message": "Déjas soummis" + }, + "502": { + "message": "Le serveur ne fonctionne pas. Message le développeur." + }, + "channelWhitelisted": { + "message": "Cette channel est sur la liste blanche!" + }, + "Sponsor": { + "message": "endossement" + }, + "Sponsors": { + "message": "endossements" + }, + "Segment": { + "message": "section d'endossement" + }, + "Segments": { + "message": "section d'endossements" + }, + "noticeTitle": { + "message": "Endossement Passer" + }, + "reportButtonTitle": { + "message": "Incorrect" + }, + "reportButtonInfo": { + "message": "Informe que cette endossement est incorrect ou n'existe pas." + }, + "Dismiss": { + "message": "Ferme" + }, + "Loading": { + "message": "Chargement en cours..." + }, + "Mins": { + "message": "Minutes" + }, + "Secs": { + "message": "Seconds" + }, + "Hide": { + "message": "Ne Montre Jaimais" + }, + "hitGoBack": { + "message": "Clique retourne pour si vous avez manqué parti." + }, + "unskip": { + "message": "Retourne" + }, + "reskip": { + "message": "Resaute" + }, + "paused": { + "message": "Pause" + }, + "confirmMSG": { + "message": "\n\nPour modifier ou enlever des soumissions, clique sur le bouton d'info." + }, + "clearThis": { + "message": "Êtes-vous certaines vous voulez enlever vos soumissions?\n\n" + }, + "Unknown": { + "message": "Erreur, essayer encore plus tard." + }, + "sponsorFound": { + "message": "Cette vidéo est dans le database!" + }, + "sponsor404": { + "message": "Rien d'endossements trouvé" + }, + "sponsorStart": { + "message": "Endossement Commence Maintenant" + }, + "sponsorEnd": { + "message": "Endossement Arête Maintenant" + }, + "noVideoID": { + "message": "Ceci n'est pas une tab de YouTube, ou vous avez cliqué trop tôt. \n Si vous savez que ceci est une tab YouTube, ferme ce menu et essayé encore." + }, + "success": { + "message": "Succès!" + }, + "voted": { + "message": "Voté!" + }, + "voteFail": { + "message": "Vous avez déjà voté la même façon." + }, + "serverDown": { + "message": "Le serveur ne fonctionne pas. Message le développeur." + }, + "connectionError": { + "message": "Erreur. Code: " + }, + "wantToSubmit": { + "message": "Voulez-vous soumettre les endossements sur le vidéo" + }, + "leftTimes": { + "message": "Vous avez laissé les endossements qui n'étaient pas soumis. Retournez à la page pour les soumettre (Ils ne sont pas enlevés)." + }, + "submitCheck": { + "message": "Êtes-vous certaines vous voulez soumettre?" + } +} diff --git a/_locales/pt_BR/messages.json b/_locales/pt_BR/messages.json new file mode 100644 index 00000000..b5ec5bd8 --- /dev/null +++ b/_locales/pt_BR/messages.json @@ -0,0 +1,127 @@ +{ + "Name": { + "message": "SponsorBlock", + "description": "Nome da extensão." + }, + "fullName": { + "message": "SponsorBlock para YouTube - Pule patrocínios", + "description": "Nome da extensão." + }, + + "Description": { + "message": "Pule patrocinadores em vídeos do YouTube. Reporte patrocinadores em videos que você assiste para salvar o tempo dos outros.", + "description": "Descrição da extensão." + }, + "helpPage": { + "message": "index_en.html" + }, + "400": { + "message": "O servidor disse que esse pedido foi inválido" + }, + "429": { + "message": "Você enviou muitos segmentos para esse vídeo, tem certeza que tem tantos assim?" + }, + "409": { + "message": "Isso já foi enviado antes" + }, + "502": { + "message": "Parece que o servidor caiu. Contate o desenvolvedor para informá-los." + }, + "channelWhitelisted": { + "message": "Canal adicionado a lista branca!" + }, + "Sponsor": { + "message": "patrocinador" + }, + "Sponsors": { + "message": "patrocinadores" + }, + "Segment": { + "message": "segmento de patrocinador" + }, + "Segments": { + "message": "segmento de patrocinadores" + }, + "noticeTitle": { + "message": "Patrocinador pulado" + }, + "reportButtonTitle": { + "message": "Reportar" + }, + "reportButtonInfo": { + "message": "Reportar essa subimissão como inválida." + }, + "Dismiss": { + "message": "Ignorar" + }, + "Loading": { + "message": "Carregando..." + }, + "Mins": { + "message": "Minutos" + }, + "Secs": { + "message": "Segundos" + }, + "Hide": { + "message": "Nunca mostrar" + }, + "hitGoBack": { + "message": "Aperta reverter pulo para voltar onde estava" + }, + "unskip": { + "message": "Reverter pulo" + }, + "reskip": { + "message": "Pular novamente" + }, + "paused": { + "message": "Pausado" + }, + "confirmMSG": { + "message": "\n\nPara editar ou remover linhas individuais, clique com o botão direito ou abra o popup da extensão pelo icone no canto superior direito." + }, + "clearThis": { + "message": "Tem certeza que quer limpar isso?\n\n" + }, + "Unknown": { + "message": "Teve um erro ao enviar seus segmentos, tente novamente depois" + }, + + "sponsorFound": { + "message": "Os patrocinadores desse vídeo estão no banco de dados!" + }, + "sponsor404": { + "message": "Nenhum patrocinador encontrado" + }, + "sponsorStart": { + "message": "Patrocínio começa agora" + }, + "sponsorEnd": { + "message": "Patrocínio termina agora" + }, + "noVideoID": { + "message": "Isso provavelmente não é uma tab do YouTube, ou você clicou muito cedo. \n Se sabe que é uma tab do YouTube,\n fecha esse popup e abre de novo." + }, + "success": { + "message": "Sucesso!" + }, + "voted": { + "message": "Votado!" + }, + "voteFail": { + "message": "Você já votou antes." + }, + "serverDown": { + "message": "Parece que o servidor caiu. Contate o desenvolvedor o quanto antes." + }, + "connectionError": { + "message": "Um erro de conexão aconteceu: Código: " + }, + "wantToSubmit": { + "message": "Quer enviar os segmentos para o vídeo de ID" + }, + "leftTimes": { + "message": "Parece que você esqueceu de enviar alguns segmentos. Volta pra página para enviar eles (não foram deletados)." + } +}
\ No newline at end of file diff --git a/_locales/ru/messages.json b/_locales/ru/messages.json new file mode 100644 index 00000000..4ef09dd8 --- /dev/null +++ b/_locales/ru/messages.json @@ -0,0 +1,130 @@ +{ + "Name": { + "message": "SponsorBlock", + "description": "Название расширения, не переводится." + }, + "fullName": { + "message": "SponsorBlock для YouTube - Пропускайте спонсорские вставки", + "description": "Название расширения." + }, + + "Description": { + "message": "Пропускайте спонсорские вставки в видео на YouTube. Сообщайте о спонсорских вставках в видео, которые Вы смотрите, чтобы сэкономить время других пользователей.", + "description": "Описание раширения." + }, + "helpPage": { + "message": "index_en.html" + }, + "400": { + "message": "Сервер отклонил этот запрос." + }, + "429": { + "message": "Вы отправили слишком много спонсоров для этого видео. Вы уверены, что их так много?" + }, + "409": { + "message": "Этот запрос был отправлен ранее." + }, + "502": { + "message": "Сервер недоступен. Свяжитесь с разработчиком и сообщите ему об этом." + }, + "channelWhitelisted": { + "message": "Канал добавлен в белый список!" + }, + "Sponsor": { + "message": "Спонсор" + }, + "Sponsors": { + "message": "Спонсоры" + }, + "Segment": { + "message": "спонсорская вставка" + }, + "Segments": { + "message": "спонсорские вставки" + }, + "noticeTitle": { + "message": "Спонсор пропущен" + }, + "reportButtonTitle": { + "message": "Ошибка" + }, + "reportButtonInfo": { + "message": "Сообщить, что информация об этом спонсорском сегменте ошибочна." + }, + "Dismiss": { + "message": "Закрыть" + }, + "Loading": { + "message": "Загрузка..." + }, + "Mins": { + "message": "мин" + }, + "Secs": { + "message": "сек" + }, + "Hide": { + "message": "Не показывать" + }, + "hitGoBack": { + "message": "Нажмите «Назад», чтобы вернуться обратно." + }, + "unskip": { + "message": "Назад" + }, + "reskip": { + "message": "Пропустить" + }, + "paused": { + "message": "Пауза" + }, + "confirmMSG": { + "message": "\n\nЧтобы изменить или удалить отдельные значения, нажмите кнопку «Информация» или откройте всплывающее окно расширения, щелкнув значок расширения в правом верхнем углу." + }, + "clearThis": { + "message": "Вы уверены, что хотите удалить эту информацию?\n\n" + }, + "Unknown": { + "message": "При отправке отчета о спонсорском сегменте произошла ошибка. Попытайтесь отправить его позже." + }, + + "sponsorFound": { + "message": "Спонсоры этого видео уже находятся в базе данных!" + }, + "sponsor404": { + "message": "Спонсорские вставки не найдены" + }, + "sponsorStart": { + "message": "Спонсорская вставка начинается сейчас" + }, + "sponsorEnd": { + "message": "Спонсорская вставка оканчивается сейчас" + }, + "noVideoID": { + "message": "Возможно, это не вкладка YouTube, или Вы нажали слишком рано. \n Если это вкладка YouTube,\n закройте это всплывающее окно и откройте его снова." + }, + "success": { + "message": "Успех!" + }, + "voted": { + "message": "Голос засчитан!" + }, + "voteFail": { + "message": "Вы уже проголосовали таким образом раньше." + }, + "serverDown": { + "message": "Кажется, сервер не работает. Свяжитесь с разработчиком." + }, + "connectionError": { + "message": "Ошибка соединения. Код ошибки: " + }, + "wantToSubmit": { + "message": "Вы точно хотите отправить отчёт о спонсорских вставках в видео с идентификатором" + }, + "leftTimes": { + "message": "Вы ещё не отправили отчёты о некоторых спонсорских вставках. Хотите вернуться на эту страницу, чтобы отправить их (они не удаляются)." + }, + "submitCheck": { + "message": "Вы уверены, что хотите отправить эту информацию?" + } +} diff --git a/background.js b/background.js index d0efeb08..afbe1644 100644 --- a/background.js +++ b/background.js @@ -1,6 +1,6 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { chrome.tabs.sendMessage(tabId, { - message: 'update', + message: 'update', }); }); @@ -33,8 +33,8 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) { case "alertPrevious": chrome.notifications.create("stillThere" + Math.random(), { type: "basic", - title: "Do you want to submit the sponsor times for video id " + request.previousVideoID + "?", - message: "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted).", + title: chrome.i18n.getMessage("wantToSubmit") + request.previousVideoID + "?", + message: chrome.i18n.getMessage("leftTimes"), iconUrl: "./icons/LogoSponsorBlocker256px.png" }); } diff --git a/content.css b/content.css index d6fd89aa..525fedc3 100644 --- a/content.css +++ b/content.css @@ -71,7 +71,7 @@ } .sponsorSkipNotice { - min-width: 280px; + min-width: 300px; background-color: rgba(28, 28, 28, 0.9); position: absolute; right: 5px; @@ -10,9 +10,6 @@ var sponsorVideoID = null; //these are sponsors that have been downvoted var hiddenSponsorTimes = []; -//the time this video is starting at when first played, if not zero -var youtubeVideoStartTime = null; - //the video var v; @@ -259,9 +256,6 @@ function videoIDChange(id) { resetValues(); - //see if there is a video start time - youtubeVideoStartTime = getYouTubeVideoStartTime(document.URL); - sponsorsLookup(id); //make sure everything is properly added @@ -288,6 +282,8 @@ function videoIDChange(id) { //see if this data should be saved in the sponsorTimesSubmitting variable if (sponsorTimes != undefined && sponsorTimes.length > 0) { sponsorTimesSubmitting = sponsorTimes; + + updatePreviewBar(); } } }); @@ -383,7 +379,21 @@ function sponsorsLookup(id) { } function updatePreviewBar() { - previewBar.set(sponsorTimes, [], v.duration); + let localSponsorTimes = sponsorTimes; + if (localSponsorTimes == null) localSponsorTimes = []; + + let allSponsorTimes = localSponsorTimes.concat(sponsorTimesSubmitting); + + //create an array of the sponsor types + let types = []; + for (let i = 0; i < localSponsorTimes.length; i++) { + types.push("sponsor"); + } + for (let i = 0; i < sponsorTimesSubmitting.length; i++) { + types.push("previewSponsor"); + } + + previewBar.set(allSponsorTimes, types, v.duration); //update last video id lastPreviewBarUpdate = getYouTubeVideoID(document.URL); @@ -468,7 +478,7 @@ function checkSponsorTime(sponsorTimes, index, openNotice) { lastTime = v.currentTime - 0.0001; } - if (checkIfTimeToSkip(v.currentTime, sponsorTimes[index][0]) && !hiddenSponsorTimes.includes(index)) { + if (checkIfTimeToSkip(v.currentTime, sponsorTimes[index][0], sponsorTimes[index][1]) && !hiddenSponsorTimes.includes(index)) { //skip it skipToTime(v, index, sponsorTimes, openNotice); @@ -479,13 +489,13 @@ function checkSponsorTime(sponsorTimes, index, openNotice) { return false; } -function checkIfTimeToSkip(currentVideoTime, startTime) { +function checkIfTimeToSkip(currentVideoTime, startTime, endTime) { //If the sponsor time is in between these times, skip it //Checks if the last time skipped to is not too close to now, to make sure not to get too many // sponsor times in a row (from one troll) //the last term makes 0 second start times possible only if the video is not setup to start at a different time from zero return (Math.abs(currentVideoTime - startTime) < 3 && startTime >= lastTime && startTime <= currentVideoTime) || - (lastTime == -1 && startTime == 0 && youtubeVideoStartTime == null) + (lastTime == -1 && startTime == 0 && currentVideoTime < endTime) } //skip fromt he start time to the end time for a certain index sponsor time @@ -615,6 +625,8 @@ function updateSponsorTimesSubmitting() { //see if this data should be saved in the sponsorTimesSubmitting variable if (sponsorTimes != undefined) { sponsorTimesSubmitting = sponsorTimes; + + updatePreviewBar(); } } }); @@ -841,6 +853,8 @@ function clearSponsorTimes() { //clear sponsor times submitting sponsorTimesSubmitting = []; + updatePreviewBar(); + //set buttons to be correct changeStartSponsorButton(true, false); } @@ -931,8 +945,8 @@ function submitSponsorTimes() { let sponsorTimes = result[sponsorTimeKey]; if (sponsorTimes != undefined && sponsorTimes.length > 0) { - let confirmMessage = "Are you sure you want to submit this?\n\n" + getSponsorTimesMessage(sponsorTimes); - confirmMessage += "\n\nTo edit or delete values, click the info button or open the extension popup by clicking the extension icon in the top right corner." + let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes); + confirmMessage += "\n\n" + chrome.i18n.getMessage("confirmMSG"); if(!confirm(confirmMessage)) return; sendSubmitMessage(); diff --git a/manifest.json b/manifest.json index 3677fc80..427e063c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.1.0", + "version": "1.1.2", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [ @@ -1,3 +1,17 @@ +// Function that can be used to wait for a condition before returning +async function wait(condition, timeout = 5000, check = 100) { + return await new Promise((resolve, reject) => { + setTimeout(() => {reject("TIMEOUT")}, timeout); + const interval = setInterval(() => { + let result = condition(); + if (result !== false) { + resolve(result); + clearInterval(interval); + }; + }, check); + }); +} + function getYouTubeVideoID(url) { //Attempt to parse url let urlObject = null; @@ -5,7 +19,7 @@ function getYouTubeVideoID(url) { urlObject = new URL(url); } catch (e) { console.error("[SB] Unable to parse URL: " + url); - return false + return false; } //Check if valid hostname @@ -23,15 +37,4 @@ function getYouTubeVideoID(url) { return false; } } -} - -//returns the start time of the video if there was one specified (ex. ?t=5s) -function getYouTubeVideoStartTime(url) { - let searchParams = new URL(url).searchParams; - let startTime = searchParams.get("t"); - if (startTime == null) { - startTime = searchParams.get("time_continue"); - } - - return startTime; -} +}
\ No newline at end of file diff --git a/utils/previewBar.js b/utils/previewBar.js index 95454e9d..c746c5d4 100644 --- a/utils/previewBar.js +++ b/utils/previewBar.js @@ -13,6 +13,10 @@ let barTypes = { "sponsor": { color: "#00d400", opacity: "0.5" + }, + "previewSponsor": { + color: "#0000d4", + opacity: "0.5" } }; diff --git a/utils/skipNotice.js b/utils/skipNotice.js index e57a56e2..511baf4a 100644 --- a/utils/skipNotice.js +++ b/utils/skipNotice.js @@ -359,6 +359,9 @@ class SkipNotice { if (notice != null) { notice.remove(); } + + //remove setInterval + if (this.countdownInterval != -1) clearInterval(this.countdownInterval); } }
\ No newline at end of file |