mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 11:37:02 +03:00
Compare commits
74 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0888faf78 | ||
|
|
9951a19478 | ||
|
|
dd4ab2f38a | ||
|
|
227bec4d8e | ||
|
|
556b4f88d2 | ||
|
|
f0e1979aab | ||
|
|
989db6d6b6 | ||
|
|
781096c290 | ||
|
|
536c6e3e41 | ||
|
|
de376176db | ||
|
|
e63389cfa3 | ||
|
|
1c4ca8da26 | ||
|
|
dcbd7ba4cd | ||
|
|
9fc8d385ab | ||
|
|
07e878e065 | ||
|
|
a2af4dba52 | ||
|
|
2fbafb6b10 | ||
|
|
98eb72ef1f | ||
|
|
89d127c5c5 | ||
|
|
a784c8a850 | ||
|
|
a533aaf5cf | ||
|
|
434b5bdbad | ||
|
|
d1f1f9213e | ||
|
|
d498c107a8 | ||
|
|
f12b44762e | ||
|
|
fc4da038e9 | ||
|
|
d5999ad330 | ||
|
|
146ece3bff | ||
|
|
92095acf36 | ||
|
|
279c10d555 | ||
|
|
0ae3820681 | ||
|
|
283e4d053e | ||
|
|
6dbb2f9d10 | ||
|
|
c657bb763b | ||
|
|
259cdb1abe | ||
|
|
86e96e59af | ||
|
|
9ba30dbafa | ||
|
|
2907db705c | ||
|
|
a6a0f917e0 | ||
|
|
bcdba798d9 | ||
|
|
32884372fa | ||
|
|
9b2364cfb7 | ||
|
|
c1aebf45c8 | ||
|
|
6e0c6332cc | ||
|
|
47d0d340d4 | ||
|
|
118804e139 | ||
|
|
0bef50e259 | ||
|
|
bfb876af8b | ||
|
|
84d5d3124c | ||
|
|
825d997d6d | ||
|
|
8e9e5bfddb | ||
|
|
05765682a5 | ||
|
|
2b5d56942a | ||
|
|
f097ff60aa | ||
|
|
655691a28f | ||
|
|
7ddef8d519 | ||
|
|
2fb79f0066 | ||
|
|
655d87ce0f | ||
|
|
ed7c98afa8 | ||
|
|
41bf0c9697 | ||
|
|
5eb0132660 | ||
|
|
c43695e596 | ||
|
|
9aeda25136 | ||
|
|
90e671ebf8 | ||
|
|
3ecc180d06 | ||
|
|
7ac9ec37ef | ||
|
|
e176a9f241 | ||
|
|
91bd910c40 | ||
|
|
a6c77185de | ||
|
|
b871d721db | ||
|
|
85f9bb1d34 | ||
|
|
adb60c6357 | ||
|
|
4db6593681 | ||
|
|
d75a7ca897 |
28
README.md
28
README.md
@@ -1,16 +1,22 @@
|
||||

|
||||
<br/><sub>Logo by [@munadikieh](https://github.com/munadikieh)</sub>
|
||||
<p align="center">
|
||||
<img src="icons/LogoSponsorBlocker256px.png" alt="Logo"></img>
|
||||
|
||||
<br/>
|
||||
<sub>Logo by <a href="https://github.com/munadikieh">@munadikieh</a></sub>
|
||||
</p>
|
||||
|
||||
<h1 align="center">SponsorBlock</h1>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://chrome.google.com/webstore/detail/mnjggcdmjocbbbhaepdhchncahnbgone">Chrome/Chromium</a> |
|
||||
<a href="https://addons.mozilla.org/addon/sponsorblock/?src=external-github">Firefox</a> |
|
||||
<a href="https://sponsor.ajay.app">Website</a> |
|
||||
<a href="https://sponsor.ajay.app/stats">Stats</a>
|
||||
</p>
|
||||
|
||||
# SponsorBlock
|
||||
|
||||
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.
|
||||
|
||||
# Available for Chrome and Firefox
|
||||
|
||||
Chrome: https://chrome.google.com/webstore/detail/mnjggcdmjocbbbhaepdhchncahnbgone
|
||||
|
||||
Firefox: https://addons.mozilla.org/addon/sponsorblock/
|
||||
|
||||
# Server
|
||||
|
||||
The backend server code is available here: https://github.com/ajayyy/SponsorBlockServer
|
||||
@@ -25,10 +31,6 @@ Hopefully this project can be combined with projects like [this](https://github.
|
||||
|
||||
You can read the API docs [here](https://github.com/ajayyy/SponsorBlockServer#api-docs).
|
||||
|
||||
# Previous extension
|
||||
|
||||
This project is partially based off of [this experimental extension](https://github.com/OfficialNoob/YTSponsorSkip), which has the basic video skipping functionality.
|
||||
|
||||
# Build Yourself
|
||||
|
||||
You can load this project as an unpacked extension. Make sure to rename the `config.js.example` file to `config.js` before installing.
|
||||
|
||||
@@ -123,5 +123,17 @@
|
||||
},
|
||||
"leftTimes": {
|
||||
"message": "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted)."
|
||||
},
|
||||
"clearTimes": {
|
||||
"message": "Clear Sponsor Times"
|
||||
},
|
||||
"openPopup": {
|
||||
"message": "Open SponsorBlock Popup"
|
||||
},
|
||||
"SubmitTimes": {
|
||||
"message": "Submit Sponsor Times"
|
||||
},
|
||||
"submitCheck": {
|
||||
"message": "Are you sure you want to submit this?"
|
||||
}
|
||||
}
|
||||
|
||||
129
_locales/fr/messages.json
Normal file
129
_locales/fr/messages.json
Normal file
@@ -0,0 +1,129 @@
|
||||
{
|
||||
"Name": {
|
||||
"message": "SponsorBlock",
|
||||
"description": "Name of the extension."
|
||||
},
|
||||
"fullName": {
|
||||
"message": "SponsorBlock pour YouTube - Enlève les messages commerciaux et publicités intégrées",
|
||||
"description": "Name of the extension."
|
||||
},
|
||||
|
||||
"Description": {
|
||||
"message": "Passe automatiquement les messages commerciaux intégrés dans les vidéos YouTube. Soumettez les segments commerciaux 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 cherchez à envoyer beaucoup de segments, il y en a vraiment autant ?"
|
||||
},
|
||||
"409": {
|
||||
"message": "Déja soumis"
|
||||
},
|
||||
"502": {
|
||||
"message": "Le serveur ne fonctionne pas. Contactez le développeur."
|
||||
},
|
||||
"channelWhitelisted": {
|
||||
"message": "Cette chaine est sur la liste blanche !"
|
||||
},
|
||||
"Sponsor": {
|
||||
"message": "message commercial"
|
||||
},
|
||||
"Sponsors": {
|
||||
"message": "messages commerciaux"
|
||||
},
|
||||
"Segment": {
|
||||
"message": "segment de message commercial"
|
||||
},
|
||||
"Segments": {
|
||||
"message": "segments de message commercial"
|
||||
},
|
||||
"noticeTitle": {
|
||||
"message": "Message passé"
|
||||
},
|
||||
"reportButtonTitle": {
|
||||
"message": "Incorrect"
|
||||
},
|
||||
"reportButtonInfo": {
|
||||
"message": "Signaler que ce segment est incorrect ou n'existe pas."
|
||||
},
|
||||
"Dismiss": {
|
||||
"message": "Fermer"
|
||||
},
|
||||
"Loading": {
|
||||
"message": "Chargement en cours..."
|
||||
},
|
||||
"Mins": {
|
||||
"message": "Minutes"
|
||||
},
|
||||
"Secs": {
|
||||
"message": "Secondes"
|
||||
},
|
||||
"Hide": {
|
||||
"message": "Ne plus montrer"
|
||||
},
|
||||
"hitGoBack": {
|
||||
"message": "Cliquez sur revenir en arrière pour revenir avant le saut du segment"
|
||||
},
|
||||
"unskip": {
|
||||
"message": "Revenir en arrière"
|
||||
},
|
||||
"reskip": {
|
||||
"message": "Sauter"
|
||||
},
|
||||
"paused": {
|
||||
"message": "En pause"
|
||||
},
|
||||
"confirmMSG": {
|
||||
"message": "\n\nPour modifier ou enlever des soumissions, cliquez sur le bouton d'info."
|
||||
},
|
||||
"clearThis": {
|
||||
"message": "Êtes-vous certain(e) que vous voulez enlever vos soumissions ?\n\n"
|
||||
},
|
||||
"Unknown": {
|
||||
"message": "Erreur, essayer plus tard."
|
||||
},
|
||||
"sponsorFound": {
|
||||
"message": "Les messages commerciaux sont déjà dans notre base de donnée pour cette vidéo !"
|
||||
},
|
||||
"sponsor404": {
|
||||
"message": "Pas de messages trouvés"
|
||||
},
|
||||
"sponsorStart": {
|
||||
"message": "Début du message"
|
||||
},
|
||||
"sponsorEnd": {
|
||||
"message": "Fin du message"
|
||||
},
|
||||
"noVideoID": {
|
||||
"message": "Ceci n'est pas un onglet YouTube, ou vous avez cliqué trop tôt. \n Si vous êtes sur(e) que c'est un onglet YouTube, fermez ce menu et réessayer."
|
||||
},
|
||||
"success": {
|
||||
"message": "Succès !"
|
||||
},
|
||||
"voted": {
|
||||
"message": "A voté !"
|
||||
},
|
||||
"voteFail": {
|
||||
"message": "Vous avez déjà voté pour ce choix auparavant."
|
||||
},
|
||||
"serverDown": {
|
||||
"message": "Le serveur ne fonctionne pas. Contactez le développeur."
|
||||
},
|
||||
"connectionError": {
|
||||
"message": "Erreur de connexion, Code : "
|
||||
},
|
||||
"wantToSubmit": {
|
||||
"message": "Voulez-vous soumettre les messages pour cette vidéo"
|
||||
},
|
||||
"leftTimes": {
|
||||
"message": "Vous avez laissé des messages non soumis. Retournez sur la vidéo pour les soumettre (ils ont été conservés)."
|
||||
},
|
||||
"submitCheck": {
|
||||
"message": "Soumettre ce(s) message(s) ?"
|
||||
}
|
||||
}
|
||||
127
_locales/pt_BR/messages.json
Normal file
127
_locales/pt_BR/messages.json
Normal file
@@ -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)."
|
||||
}
|
||||
}
|
||||
130
_locales/ru/messages.json
Normal file
130
_locales/ru/messages.json
Normal file
@@ -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": "Вы уверены, что хотите отправить эту информацию?"
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
});
|
||||
}
|
||||
@@ -56,7 +56,6 @@ chrome.runtime.onInstalled.addListener(function (object) {
|
||||
// TODO (shownInstallPage): remove this if statement, but leave contents
|
||||
if (!shownInstallPage){
|
||||
//open up the install page
|
||||
|
||||
chrome.tabs.create({url: chrome.extension.getURL("/help/"+chrome.i18n.getMessage("helpPage"))});
|
||||
}
|
||||
|
||||
@@ -67,13 +66,10 @@ chrome.runtime.onInstalled.addListener(function (object) {
|
||||
}
|
||||
|
||||
//generate a userID
|
||||
const newUserID = generateUUID();
|
||||
const newUserID = generateUserID();
|
||||
//save this UUID
|
||||
chrome.storage.sync.set({
|
||||
"userID": newUserID,
|
||||
//the last video id loaded, to make sure it is a video id change
|
||||
"sponsorVideoID": null,
|
||||
"previousVideoID": null
|
||||
"userID": newUserID
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -117,6 +113,14 @@ function submitVote(type, UUID, callback) {
|
||||
chrome.storage.sync.get(["userID"], function(result) {
|
||||
let userID = result.userID;
|
||||
|
||||
if (userID == undefined || userID === "undefined") {
|
||||
//generate one
|
||||
userID = generateUserID();
|
||||
chrome.storage.sync.set({
|
||||
"userID": userID
|
||||
});
|
||||
}
|
||||
|
||||
//publish this vote
|
||||
sendRequestToServer("GET", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
@@ -143,11 +147,29 @@ function submitVote(type, UUID, callback) {
|
||||
function submitTimes(videoID, callback) {
|
||||
//get the video times from storage
|
||||
let sponsorTimeKey = 'sponsorTimes' + videoID;
|
||||
chrome.storage.sync.get([sponsorTimeKey, "userID"], function(result) {
|
||||
chrome.storage.sync.get([sponsorTimeKey, "userID"], async function(result) {
|
||||
let sponsorTimes = result[sponsorTimeKey];
|
||||
let userID = result.userID;
|
||||
|
||||
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
||||
let durationResult = await new Promise((resolve, reject) => {
|
||||
chrome.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true
|
||||
}, function(tabs) {
|
||||
chrome.tabs.sendMessage(tabs[0].id, {
|
||||
message: "getVideoDuration"
|
||||
}, (response) => resolve(response));
|
||||
});
|
||||
});
|
||||
|
||||
//check if a sponsor exceeds the duration of the video
|
||||
for (let i = 0; i < sponsorTimes.length; i++) {
|
||||
if (sponsorTimes[i][1] > durationResult.duration) {
|
||||
sponsorTimes[i][1] = durationResult.duration;
|
||||
}
|
||||
}
|
||||
|
||||
//submit these times
|
||||
for (let i = 0; i < sponsorTimes.length; i++) {
|
||||
//submit the sponsorTime
|
||||
@@ -201,10 +223,9 @@ function sendRequestToServer(type, address, callback) {
|
||||
xmlhttp.send();
|
||||
}
|
||||
|
||||
function generateUUID(length = 36) {
|
||||
function generateUserID(length = 36) {
|
||||
let charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
let result = "";
|
||||
let isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
|
||||
if (window.crypto && window.crypto.getRandomValues) {
|
||||
values = new Uint32Array(length);
|
||||
window.crypto.getRandomValues(values);
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
}
|
||||
|
||||
.sponsorSkipNotice {
|
||||
min-width: 280px;
|
||||
min-width: 300px;
|
||||
background-color: rgba(28, 28, 28, 0.9);
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
|
||||
363
content.js
363
content.js
@@ -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;
|
||||
|
||||
@@ -31,11 +28,13 @@ var channelURL;
|
||||
var channelWhitelisted = false;
|
||||
|
||||
// create preview bar
|
||||
var previewBar;
|
||||
var previewBar = null;
|
||||
|
||||
if (id = getYouTubeVideoID(document.URL)) { // Direct Links
|
||||
videoIDChange(id);
|
||||
}
|
||||
//the player controls on the YouTube player
|
||||
var controls = null;
|
||||
|
||||
// Direct Links
|
||||
videoIDChange(getYouTubeVideoID(document.URL));
|
||||
|
||||
//the last time looked at (used to see if this time is in the interval)
|
||||
var lastTime = -1;
|
||||
@@ -93,11 +92,7 @@ function messageListener(request, sender, sendResponse) {
|
||||
//messages from popup script
|
||||
|
||||
if (request.message == "update") {
|
||||
if(id = getYouTubeVideoID(document.URL)){
|
||||
videoIDChange(id);
|
||||
} else {
|
||||
resetValues();
|
||||
}
|
||||
videoIDChange(getYouTubeVideoID(document.URL));
|
||||
}
|
||||
|
||||
if (request.message == "sponsorStart") {
|
||||
@@ -127,10 +122,16 @@ function messageListener(request, sender, sendResponse) {
|
||||
|
||||
if (request.message == "getVideoID") {
|
||||
sendResponse({
|
||||
videoID: getYouTubeVideoID(document.URL)
|
||||
videoID: sponsorVideoID
|
||||
})
|
||||
}
|
||||
|
||||
if (request.message == "getVideoDuration") {
|
||||
sendResponse({
|
||||
duration: v.duration
|
||||
});
|
||||
}
|
||||
|
||||
if (request.message == "skipToTime") {
|
||||
v.currentTime = request.time;
|
||||
}
|
||||
@@ -155,7 +156,7 @@ function messageListener(request, sender, sendResponse) {
|
||||
|
||||
if (request.message == "whitelistChange") {
|
||||
channelWhitelisted = request.value;
|
||||
sponsorsLookup(getYouTubeVideoID(document.URL));
|
||||
sponsorsLookup(sponsorVideoID);
|
||||
}
|
||||
|
||||
if (request.message == "showNoticeAgain") {
|
||||
@@ -211,20 +212,30 @@ function resetValues() {
|
||||
//reset sponsor times
|
||||
sponsorTimes = null;
|
||||
UUIDs = null;
|
||||
sponsorVideoID = id;
|
||||
sponsorLookupRetries = 0;
|
||||
|
||||
//empty the preview bar
|
||||
previewBar.set([], [], 0);
|
||||
if (previewBar !== null) {
|
||||
previewBar.set([], [], 0);
|
||||
}
|
||||
|
||||
//reset sponsor data found check
|
||||
sponsorDataFound = false;
|
||||
}
|
||||
|
||||
function videoIDChange(id) {
|
||||
//not a url change
|
||||
if (sponsorVideoID == id) return;
|
||||
//if the id has not changed return
|
||||
if (sponsorVideoID === id) return;
|
||||
|
||||
//set the global videoID
|
||||
sponsorVideoID = id;
|
||||
|
||||
resetValues();
|
||||
|
||||
//id is not valid
|
||||
if (!id) return;
|
||||
|
||||
//setup the preview bar
|
||||
if (previewBar == null) {
|
||||
//create it
|
||||
let progressBar = document.getElementsByClassName("ytp-progress-bar-container")[0] || document.getElementsByClassName("no-model cue-range-markers")[0];
|
||||
@@ -256,12 +267,7 @@ function videoIDChange(id) {
|
||||
|
||||
//close popup
|
||||
closeInfoMenu();
|
||||
|
||||
resetValues();
|
||||
|
||||
//see if there is a video start time
|
||||
youtubeVideoStartTime = getYouTubeVideoStartTime(document.URL);
|
||||
|
||||
|
||||
sponsorsLookup(id);
|
||||
|
||||
//make sure everything is properly added
|
||||
@@ -271,26 +277,30 @@ function videoIDChange(id) {
|
||||
sponsorTimesSubmitting = [];
|
||||
|
||||
//see if the onvideo control image needs to be changed
|
||||
chrome.runtime.sendMessage({
|
||||
message: "getSponsorTimes",
|
||||
videoID: id
|
||||
}, function(response) {
|
||||
if (response != undefined) {
|
||||
let sponsorTimes = response.sponsorTimes;
|
||||
if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length >= 2) {
|
||||
changeStartSponsorButton(true, true);
|
||||
} else if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) {
|
||||
changeStartSponsorButton(false, true);
|
||||
} else {
|
||||
changeStartSponsorButton(true, false);
|
||||
}
|
||||
|
||||
//see if this data should be saved in the sponsorTimesSubmitting variable
|
||||
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
||||
sponsorTimesSubmitting = sponsorTimes;
|
||||
}
|
||||
}
|
||||
});
|
||||
wait(getControls).then(result => {
|
||||
chrome.runtime.sendMessage({
|
||||
message: "getSponsorTimes",
|
||||
videoID: id
|
||||
}, function(response) {
|
||||
if (response != undefined) {
|
||||
let sponsorTimes = response.sponsorTimes;
|
||||
if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length >= 2) {
|
||||
changeStartSponsorButton(true, true);
|
||||
} else if (sponsorTimes != null && sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) {
|
||||
changeStartSponsorButton(false, true);
|
||||
} else {
|
||||
changeStartSponsorButton(true, false);
|
||||
}
|
||||
|
||||
//see if this data should be saved in the sponsorTimesSubmitting variable
|
||||
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
||||
sponsorTimesSubmitting = sponsorTimes;
|
||||
|
||||
updatePreviewBar();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//see if video controls buttons should be added
|
||||
chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) {
|
||||
@@ -333,6 +343,9 @@ function sponsorsLookup(id) {
|
||||
}
|
||||
|
||||
//check database for sponsor times
|
||||
|
||||
//made true once a setTimeout has been created to try again after a server error
|
||||
let recheckStarted = false;
|
||||
sendRequestToServer('GET', "/api/getVideoSponsorTimes?videoID=" + id, function(xmlhttp) {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
sponsorDataFound = true;
|
||||
@@ -368,7 +381,9 @@ function sponsorsLookup(id) {
|
||||
});
|
||||
|
||||
sponsorLookupRetries = 0;
|
||||
} else if (xmlhttp.readyState == 4 && sponsorLookupRetries < 90) {
|
||||
} else if (xmlhttp.readyState == 4 && sponsorLookupRetries < 90 && !recheckStarted) {
|
||||
recheckStarted = true;
|
||||
|
||||
//some error occurred, try again in a second
|
||||
setTimeout(() => sponsorsLookup(id), 1000);
|
||||
|
||||
@@ -383,10 +398,24 @@ 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);
|
||||
lastPreviewBarUpdate = sponsorVideoID;
|
||||
}
|
||||
|
||||
function getChannelID() {
|
||||
@@ -468,7 +497,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 +508,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
|
||||
@@ -529,53 +558,63 @@ function reskipSponsorTime(UUID) {
|
||||
}
|
||||
}
|
||||
|
||||
//Adds a sponsorship starts button to the player controls
|
||||
function addPlayerControlsButton() {
|
||||
if (document.getElementById("startSponsorButton") != null) {
|
||||
//it's already added
|
||||
return;
|
||||
}
|
||||
|
||||
let startSponsorButton = document.createElement("button");
|
||||
startSponsorButton.id = "startSponsorButton";
|
||||
startSponsorButton.className = "ytp-button playerButton";
|
||||
startSponsorButton.setAttribute("title", chrome.i18n.getMessage("sponsorStart"));
|
||||
startSponsorButton.addEventListener("click", startSponsorClicked);
|
||||
|
||||
let startSponsorImage = document.createElement("img");
|
||||
startSponsorImage.id = "startSponsorImage";
|
||||
startSponsorImage.className = "playerButtonImage";
|
||||
startSponsorImage.src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png");
|
||||
|
||||
//add the image to the button
|
||||
startSponsorButton.appendChild(startSponsorImage);
|
||||
|
||||
let controls = document.getElementsByClassName("ytp-right-controls");
|
||||
let referenceNode = controls[controls.length - 1];
|
||||
|
||||
if (referenceNode == undefined) {
|
||||
//page not loaded yet
|
||||
setTimeout(addPlayerControlsButton, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
referenceNode.prepend(startSponsorButton);
|
||||
}
|
||||
|
||||
function removePlayerControlsButton() {
|
||||
if (!sponsorVideoID) return;
|
||||
|
||||
document.getElementById("startSponsorButton").style.display = "none";
|
||||
document.getElementById("submitButton").style.display = "none";
|
||||
}
|
||||
|
||||
function createButton(baseID, title, callback, imageName, isDraggable=false) {
|
||||
if (document.getElementById(baseID + "Button") != null) return;
|
||||
|
||||
// Button HTML
|
||||
let newButton = document.createElement("button");
|
||||
newButton.draggable = isDraggable;
|
||||
newButton.id = baseID + "Button";
|
||||
newButton.className = "ytp-button playerButton";
|
||||
newButton.setAttribute("title", chrome.i18n.getMessage(title));
|
||||
newButton.addEventListener("click", callback);
|
||||
|
||||
// Image HTML
|
||||
let newButtonImage = document.createElement("img");
|
||||
newButton.draggable = isDraggable;
|
||||
newButtonImage.id = baseID + "Image";
|
||||
newButtonImage.className = "playerButtonImage";
|
||||
newButtonImage.src = chrome.extension.getURL("icons/" + imageName);
|
||||
|
||||
// Append image to button
|
||||
newButton.appendChild(newButtonImage);
|
||||
|
||||
// Add the button to player
|
||||
controls.prepend(newButton);
|
||||
}
|
||||
|
||||
function getControls() {
|
||||
let controls = document.getElementsByClassName("ytp-right-controls");
|
||||
return (!controls || controls.length === 0) ? false : controls[controls.length - 1]
|
||||
};
|
||||
|
||||
//adds all the player controls buttons
|
||||
function createButtons() {
|
||||
wait(getControls).then(result => {
|
||||
//set global controls variable
|
||||
controls = result;
|
||||
|
||||
// Add button if does not already exist in html
|
||||
createButton("startSponsor", "sponsorStart", startSponsorClicked, "PlayerStartIconSponsorBlocker256px.png");
|
||||
createButton("info", "openPopup", openInfoMenu, "PlayerInfoIconSponsorBlocker256px.png")
|
||||
createButton("delete", "clearTimes", clearSponsorTimes, "PlayerDeleteIconSponsorBlocker256px.png");
|
||||
createButton("submit", "SubmitTimes", submitSponsorTimes, "PlayerUploadIconSponsorBlocker256px.png");
|
||||
});
|
||||
}
|
||||
//adds or removes the player controls button to what it should be
|
||||
function updateVisibilityOfPlayerControlsButton() {
|
||||
//not on a proper video yet
|
||||
if (!getYouTubeVideoID(document.URL)) return;
|
||||
if (!sponsorVideoID) return;
|
||||
|
||||
addPlayerControlsButton();
|
||||
addInfoButton();
|
||||
addDeleteButton();
|
||||
addSubmitButton();
|
||||
createButtons();
|
||||
|
||||
if (hideVideoPlayerControls) {
|
||||
removePlayerControlsButton();
|
||||
}
|
||||
@@ -597,7 +636,7 @@ function startSponsorClicked() {
|
||||
chrome.runtime.sendMessage({
|
||||
message: "addSponsorTime",
|
||||
time: v.currentTime,
|
||||
videoID: getYouTubeVideoID(document.URL)
|
||||
videoID: sponsorVideoID
|
||||
}, function(response) {
|
||||
//see if the sponsorTimesSubmitting needs to be updated
|
||||
updateSponsorTimesSubmitting();
|
||||
@@ -607,7 +646,7 @@ function startSponsorClicked() {
|
||||
function updateSponsorTimesSubmitting() {
|
||||
chrome.runtime.sendMessage({
|
||||
message: "getSponsorTimes",
|
||||
videoID: getYouTubeVideoID(document.URL)
|
||||
videoID: sponsorVideoID
|
||||
}, function(response) {
|
||||
if (response != undefined) {
|
||||
let sponsorTimes = response.sponsorTimes;
|
||||
@@ -615,18 +654,24 @@ function updateSponsorTimesSubmitting() {
|
||||
//see if this data should be saved in the sponsorTimesSubmitting variable
|
||||
if (sponsorTimes != undefined) {
|
||||
sponsorTimesSubmitting = sponsorTimes;
|
||||
|
||||
updatePreviewBar();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//is the submit button on the player loaded yet
|
||||
function isSubmitButtonLoaded() {
|
||||
return document.getElementById("submitButton") !== null;
|
||||
}
|
||||
|
||||
function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) {
|
||||
if(!sponsorVideoID) return false;
|
||||
wait(isSubmitButtonLoaded).then(result => {
|
||||
//if it isn't visible, there is no data
|
||||
if (uploadButtonVisible && !hideDeleteButtonPlayerControls) {
|
||||
document.getElementById("deleteButton").style.display = "unset";
|
||||
} else {
|
||||
document.getElementById("deleteButton").style.display = "none";
|
||||
}
|
||||
let shouldHide = (uploadButtonVisible && !hideDeleteButtonPlayerControls) ? "unset":"none"
|
||||
document.getElementById("deleteButton").style.display = shouldHide;
|
||||
|
||||
if (showStartSponsor) {
|
||||
showingStartSponsor = true;
|
||||
@@ -647,118 +692,13 @@ function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) {
|
||||
//disable submit button
|
||||
document.getElementById("submitButton").style.display = "none";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toggleStartSponsorButton() {
|
||||
changeStartSponsorButton(!showingStartSponsor, true);
|
||||
}
|
||||
|
||||
//shows the info button on the video player
|
||||
function addInfoButton() {
|
||||
if (document.getElementById("infoButton") != null) {
|
||||
//it's already added
|
||||
return;
|
||||
}
|
||||
|
||||
//make a submit button
|
||||
let infoButton = document.createElement("button");
|
||||
infoButton.id = "infoButton";
|
||||
infoButton.className = "ytp-button playerButton";
|
||||
infoButton.setAttribute("title", "Open SponsorBlock Popup");
|
||||
infoButton.addEventListener("click", openInfoMenu);
|
||||
|
||||
let infoImage = document.createElement("img");
|
||||
infoImage.id = "infoButtonImage";
|
||||
infoImage.className = "playerButtonImage";
|
||||
infoImage.src = chrome.extension.getURL("icons/PlayerInfoIconSponsorBlocker256px.png");
|
||||
|
||||
//add the image to the button
|
||||
infoButton.appendChild(infoImage);
|
||||
|
||||
let controls = document.getElementsByClassName("ytp-right-controls");
|
||||
let referenceNode = controls[controls.length - 1];
|
||||
|
||||
if (referenceNode == undefined) {
|
||||
//page not loaded yet
|
||||
setTimeout(addInfoButton, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
referenceNode.prepend(infoButton);
|
||||
}
|
||||
|
||||
//shows the delete button on the video player
|
||||
function addDeleteButton() {
|
||||
if (document.getElementById("deleteButton") != null) {
|
||||
//it's already added
|
||||
return;
|
||||
}
|
||||
|
||||
//make a submit button
|
||||
let deleteButton = document.createElement("button");
|
||||
deleteButton.id = "deleteButton";
|
||||
deleteButton.className = "ytp-button playerButton";
|
||||
deleteButton.setAttribute("title", "Clear Sponsor Times");
|
||||
deleteButton.addEventListener("click", clearSponsorTimes);
|
||||
//hide it at the start
|
||||
deleteButton.style.display = "none";
|
||||
|
||||
let deleteImage = document.createElement("img");
|
||||
deleteImage.id = "deleteButtonImage";
|
||||
deleteImage.className = "playerButtonImage";
|
||||
deleteImage.src = chrome.extension.getURL("icons/PlayerDeleteIconSponsorBlocker256px.png");
|
||||
|
||||
//add the image to the button
|
||||
deleteButton.appendChild(deleteImage);
|
||||
|
||||
let controls = document.getElementsByClassName("ytp-right-controls");
|
||||
let referenceNode = controls[controls.length - 1];
|
||||
|
||||
if (referenceNode == undefined) {
|
||||
//page not loaded yet
|
||||
setTimeout(addDeleteButton, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
referenceNode.prepend(deleteButton);
|
||||
}
|
||||
|
||||
//shows the submit button on the video player
|
||||
function addSubmitButton() {
|
||||
if (document.getElementById("submitButton") != null) {
|
||||
//it's already added
|
||||
return;
|
||||
}
|
||||
|
||||
//make a submit button
|
||||
let submitButton = document.createElement("button");
|
||||
submitButton.id = "submitButton";
|
||||
submitButton.className = "ytp-button playerButton";
|
||||
submitButton.setAttribute("title", "Submit Sponsor Times");
|
||||
submitButton.addEventListener("click", submitSponsorTimes);
|
||||
//hide it at the start
|
||||
submitButton.style.display = "none";
|
||||
|
||||
let submitImage = document.createElement("img");
|
||||
submitImage.id = "submitButtonImage";
|
||||
submitImage.className = "playerButtonImage";
|
||||
submitImage.src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png");
|
||||
|
||||
//add the image to the button
|
||||
submitButton.appendChild(submitImage);
|
||||
|
||||
let controls = document.getElementsByClassName("ytp-right-controls");
|
||||
let referenceNode = controls[controls.length - 1];
|
||||
|
||||
if (referenceNode == undefined) {
|
||||
//page not loaded yet
|
||||
setTimeout(addSubmitButton, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
referenceNode.prepend(submitButton);
|
||||
}
|
||||
|
||||
function openInfoMenu() {
|
||||
if (document.getElementById("sponsorBlockPopupContainer") != null) {
|
||||
//it's already added
|
||||
@@ -823,7 +763,7 @@ function clearSponsorTimes() {
|
||||
//it can't update to this info yet
|
||||
closeInfoMenu();
|
||||
|
||||
let currentVideoID = getYouTubeVideoID(document.URL);
|
||||
let currentVideoID = sponsorVideoID;
|
||||
|
||||
let sponsorTimeKey = 'sponsorTimes' + currentVideoID;
|
||||
chrome.storage.sync.get([sponsorTimeKey], function(result) {
|
||||
@@ -841,6 +781,8 @@ function clearSponsorTimes() {
|
||||
//clear sponsor times submitting
|
||||
sponsorTimesSubmitting = [];
|
||||
|
||||
updatePreviewBar();
|
||||
|
||||
//set buttons to be correct
|
||||
changeStartSponsorButton(true, false);
|
||||
}
|
||||
@@ -924,15 +866,24 @@ function submitSponsorTimes() {
|
||||
//it can't update to this info yet
|
||||
closeInfoMenu();
|
||||
|
||||
let currentVideoID = getYouTubeVideoID(document.URL);
|
||||
let currentVideoID = sponsorVideoID;
|
||||
|
||||
let sponsorTimeKey = 'sponsorTimes' + currentVideoID;
|
||||
chrome.storage.sync.get([sponsorTimeKey], function(result) {
|
||||
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."
|
||||
//check if a sponsor exceeds the duration of the video
|
||||
for (let i = 0; i < sponsorTimes.length; i++) {
|
||||
if (sponsorTimes[i][1] > v.duration) {
|
||||
sponsorTimes[i][1] = v.duration;
|
||||
}
|
||||
}
|
||||
//update sponsorTimes
|
||||
chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes});
|
||||
|
||||
let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes);
|
||||
confirmMessage += "\n\n" + chrome.i18n.getMessage("confirmMSG");
|
||||
if(!confirm(confirmMessage)) return;
|
||||
|
||||
sendSubmitMessage();
|
||||
@@ -948,7 +899,7 @@ function sendSubmitMessage(){
|
||||
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadIconSponsorBlocker256px.png");
|
||||
document.getElementById("submitButton").style.animation = "rotate 1s 0s infinite";
|
||||
|
||||
let currentVideoID = getYouTubeVideoID(document.URL);
|
||||
let currentVideoID = sponsorVideoID;
|
||||
|
||||
chrome.runtime.sendMessage({
|
||||
message: "submitTimes",
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
{
|
||||
"name": "__MSG_fullName__",
|
||||
"short_name": "__MSG_Name__",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.4",
|
||||
"default_locale": "en",
|
||||
"description": "__MSG_Description__",
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": [
|
||||
"https://*.youtube.com/*"
|
||||
"https://*.youtube.com/*",
|
||||
"https://www.youtube-nocookie.com/embed/*"
|
||||
],
|
||||
"all_frames": true,
|
||||
"js": [
|
||||
|
||||
4
popup.js
4
popup.js
@@ -981,7 +981,7 @@ function runThePopup() {
|
||||
//set it to false
|
||||
function resetStartTimeChosen() {
|
||||
startTimeChosen = false;
|
||||
SB.sponsorStart.innerHTML = "SP_START";
|
||||
SB.sponsorStart.innerHTML = chrome.i18n.getMessage("sponsorStart");
|
||||
}
|
||||
|
||||
//hides and shows the submit times button when needed
|
||||
@@ -1278,7 +1278,7 @@ function runThePopup() {
|
||||
|
||||
if (chrome.tabs != undefined) {
|
||||
//add the width restriction (because Firefox)
|
||||
document.getElementById("sponorBlockStyleSheet").sheet.insertRule('.popupBody { width: 300 }', 0);
|
||||
document.getElementById("sponorBlockStyleSheet").sheet.insertRule('.popupBody { width: 325 }', 0);
|
||||
|
||||
//this means it is actually opened in the popup
|
||||
runThePopup();
|
||||
|
||||
30
utils.js
30
utils.js
@@ -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,5 @@ 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;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -13,6 +13,10 @@ let barTypes = {
|
||||
"sponsor": {
|
||||
color: "#00d400",
|
||||
opacity: "0.5"
|
||||
},
|
||||
"previewSponsor": {
|
||||
color: "#0000d4",
|
||||
opacity: "0.5"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -359,6 +359,9 @@ class SkipNotice {
|
||||
if (notice != null) {
|
||||
notice.remove();
|
||||
}
|
||||
|
||||
//remove setInterval
|
||||
if (this.countdownInterval != -1) clearInterval(this.countdownInterval);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user