mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-16 08:27:03 +03:00
Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ae3820681 | ||
|
|
283e4d053e | ||
|
|
6dbb2f9d10 | ||
|
|
c657bb763b | ||
|
|
259cdb1abe | ||
|
|
86e96e59af | ||
|
|
2907db705c | ||
|
|
a6a0f917e0 | ||
|
|
32884372fa | ||
|
|
c1aebf45c8 | ||
|
|
118804e139 | ||
|
|
0bef50e259 | ||
|
|
f097ff60aa | ||
|
|
655691a28f | ||
|
|
7ddef8d519 | ||
|
|
2fb79f0066 | ||
|
|
655d87ce0f | ||
|
|
ed7c98afa8 | ||
|
|
41bf0c9697 | ||
|
|
5eb0132660 | ||
|
|
c43695e596 | ||
|
|
9aeda25136 | ||
|
|
90e671ebf8 | ||
|
|
3ecc180d06 | ||
|
|
e176a9f241 | ||
|
|
91bd910c40 | ||
|
|
a6c77185de | ||
|
|
b871d721db | ||
|
|
85f9bb1d34 | ||
|
|
adb60c6357 | ||
|
|
90046aed53 | ||
|
|
7adef119d3 | ||
|
|
4db6593681 | ||
|
|
f4c7e11ae1 | ||
|
|
b1393a563f | ||
|
|
279e49a143 | ||
|
|
db4182d074 | ||
|
|
cc2d1405b6 | ||
|
|
19802a7a31 | ||
|
|
50f929c11a | ||
|
|
e5e250ff36 | ||
|
|
6fe94a70a7 | ||
|
|
db2af83a34 | ||
|
|
cbab026f27 | ||
|
|
0c2c868e5c | ||
|
|
175cf62201 | ||
|
|
761ae63845 | ||
|
|
70948d9b36 | ||
|
|
3e0638d811 |
28
README.md
28
README.md
@@ -1,16 +1,22 @@
|
|||||||

|
<p align="center">
|
||||||
<br/><sub>Logo by [@munadikieh](https://github.com/munadikieh)</sub>
|
<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.
|
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
|
# Server
|
||||||
|
|
||||||
The backend server code is available here: https://github.com/ajayyy/SponsorBlockServer
|
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).
|
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
|
# 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.
|
You can load this project as an unpacked extension. Make sure to rename the `config.js.example` file to `config.js` before installing.
|
||||||
|
|||||||
@@ -45,9 +45,6 @@
|
|||||||
"noticeTitle": {
|
"noticeTitle": {
|
||||||
"message": "Sponsor Skipped"
|
"message": "Sponsor Skipped"
|
||||||
},
|
},
|
||||||
"noticeClosingMessage": {
|
|
||||||
"message": "closes in 7s"
|
|
||||||
},
|
|
||||||
"reportButtonTitle": {
|
"reportButtonTitle": {
|
||||||
"message": "Report"
|
"message": "Report"
|
||||||
},
|
},
|
||||||
@@ -72,9 +69,15 @@
|
|||||||
"hitGoBack": {
|
"hitGoBack": {
|
||||||
"message": "Hit unskip to get to where you came from."
|
"message": "Hit unskip to get to where you came from."
|
||||||
},
|
},
|
||||||
"goBack": {
|
"unskip": {
|
||||||
"message": "Unskip"
|
"message": "Unskip"
|
||||||
},
|
},
|
||||||
|
"reskip": {
|
||||||
|
"message": "Reskip"
|
||||||
|
},
|
||||||
|
"paused": {
|
||||||
|
"message": "Paused"
|
||||||
|
},
|
||||||
"confirmMSG": {
|
"confirmMSG": {
|
||||||
"message": "\n\nTo edit or delete individual values, click the info button or open the extension popup by clicking the extension icon in the top right corner."
|
"message": "\n\nTo edit or delete individual values, click the info button or open the extension popup by clicking the extension icon in the top right corner."
|
||||||
},
|
},
|
||||||
@@ -100,7 +103,10 @@
|
|||||||
"noVideoID": {
|
"noVideoID": {
|
||||||
"message": "This probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again."
|
"message": "This probably isn't a YouTube tab, or you clicked too early. \n If you know this is a YouTube tab,\n close this popup and open it again."
|
||||||
},
|
},
|
||||||
"Voted": {
|
"success": {
|
||||||
|
"message": "Success!"
|
||||||
|
},
|
||||||
|
"voted": {
|
||||||
"message": "Voted!"
|
"message": "Voted!"
|
||||||
},
|
},
|
||||||
"voteFail": {
|
"voteFail": {
|
||||||
@@ -117,5 +123,8 @@
|
|||||||
},
|
},
|
||||||
"leftTimes": {
|
"leftTimes": {
|
||||||
"message": "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted)."
|
"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?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
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 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?"
|
||||||
|
}
|
||||||
|
}
|
||||||
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": "Вы уверены, что хотите отправить эту информацию?"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,8 +33,8 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
|
|||||||
case "alertPrevious":
|
case "alertPrevious":
|
||||||
chrome.notifications.create("stillThere" + Math.random(), {
|
chrome.notifications.create("stillThere" + Math.random(), {
|
||||||
type: "basic",
|
type: "basic",
|
||||||
title: "Do you want to submit the sponsor times for video id " + request.previousVideoID + "?",
|
title: chrome.i18n.getMessage("wantToSubmit") + request.previousVideoID + "?",
|
||||||
message: "You seem to have left some sponsor times unsubmitted. Go back to that page to submit them (they are not deleted).",
|
message: chrome.i18n.getMessage("leftTimes"),
|
||||||
iconUrl: "./icons/LogoSponsorBlocker256px.png"
|
iconUrl: "./icons/LogoSponsorBlocker256px.png"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
46
content.css
46
content.css
@@ -58,6 +58,11 @@
|
|||||||
to { opacity: 1; }
|
to { opacity: 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes fadeOut {
|
||||||
|
from { opacity: 1; }
|
||||||
|
to { opacity: 0; }
|
||||||
|
}
|
||||||
|
|
||||||
.sponsorBlockSpacer {
|
.sponsorBlockSpacer {
|
||||||
background-color: rgb(100, 100, 100);
|
background-color: rgb(100, 100, 100);
|
||||||
border-color: rgb(100, 100, 100);
|
border-color: rgb(100, 100, 100);
|
||||||
@@ -66,7 +71,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sponsorSkipNotice {
|
.sponsorSkipNotice {
|
||||||
min-width: 280px;
|
min-width: 300px;
|
||||||
background-color: rgba(28, 28, 28, 0.9);
|
background-color: rgba(28, 28, 28, 0.9);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 5px;
|
right: 5px;
|
||||||
@@ -82,6 +87,10 @@
|
|||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sponsorSkipNoticeFadeOut {
|
||||||
|
animation: fadeOut 3s cubic-bezier(0.55, 0.055, 0.675, 0.19);
|
||||||
|
}
|
||||||
|
|
||||||
.sponsorSkipNoticeTimeLeft {
|
.sponsorSkipNoticeTimeLeft {
|
||||||
color: #eeeeee;
|
color: #eeeeee;
|
||||||
|
|
||||||
@@ -105,11 +114,6 @@
|
|||||||
border-left: 1px solid rgb(150, 150, 150);
|
border-left: 1px solid rgb(150, 150, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sponsorSkipNoticeCloseButton {
|
|
||||||
height: 10px;
|
|
||||||
width: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sponsorSkipNoticeButton {
|
.sponsorSkipNoticeButton {
|
||||||
background: none;
|
background: none;
|
||||||
color: rgb(235, 235, 235);
|
color: rgb(235, 235, 235);
|
||||||
@@ -119,6 +123,23 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
|
||||||
|
padding: 2px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sponsorSkipNoticeButton:hover {
|
||||||
|
background-color: rgba(235, 235, 235,0.2);
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
|
transition: background-color 0.4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sponsorTimesVoteButtonsContainer {
|
||||||
|
float: left;
|
||||||
|
|
||||||
|
padding: 2px 5px;
|
||||||
|
|
||||||
|
margin-right: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sponsorSkipNoticeRightSection {
|
.sponsorSkipNoticeRightSection {
|
||||||
@@ -131,8 +152,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sponsorSkipNoticeRightButton {
|
.sponsorSkipNoticeRightButton {
|
||||||
margin-left: 7px;
|
margin-right: 0;
|
||||||
padding: 0px;
|
}
|
||||||
|
|
||||||
|
.sponsorSkipNoticeCloseButton {
|
||||||
|
height: 10px;
|
||||||
|
width: 10px;
|
||||||
|
|
||||||
|
padding: 2px 5px;
|
||||||
|
|
||||||
|
margin-left: 2px;
|
||||||
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sponsorSkipMessage {
|
.sponsorSkipMessage {
|
||||||
|
|||||||
328
content.js
328
content.js
@@ -10,9 +10,6 @@ var sponsorVideoID = null;
|
|||||||
//these are sponsors that have been downvoted
|
//these are sponsors that have been downvoted
|
||||||
var hiddenSponsorTimes = [];
|
var hiddenSponsorTimes = [];
|
||||||
|
|
||||||
//the time this video is starting at when first played, if not zero
|
|
||||||
var youtubeVideoStartTime = null;
|
|
||||||
|
|
||||||
//the video
|
//the video
|
||||||
var v;
|
var v;
|
||||||
|
|
||||||
@@ -40,9 +37,6 @@ if (id = getYouTubeVideoID(document.URL)) { // Direct Links
|
|||||||
//the last time looked at (used to see if this time is in the interval)
|
//the last time looked at (used to see if this time is in the interval)
|
||||||
var lastTime = -1;
|
var lastTime = -1;
|
||||||
|
|
||||||
//the actual time (not video time) that the last skip happened
|
|
||||||
var lastUnixTimeSkipped = -1;
|
|
||||||
|
|
||||||
//the amount of times the sponsor lookup has retried
|
//the amount of times the sponsor lookup has retried
|
||||||
//this only happens if there is an error
|
//this only happens if there is an error
|
||||||
var sponsorLookupRetries = 0;
|
var sponsorLookupRetries = 0;
|
||||||
@@ -61,10 +55,6 @@ var hideVideoPlayerControls = false;
|
|||||||
var hideInfoButtonPlayerControls = false;
|
var hideInfoButtonPlayerControls = false;
|
||||||
var hideDeleteButtonPlayerControls = false;
|
var hideDeleteButtonPlayerControls = false;
|
||||||
|
|
||||||
//the downloaded sponsor times
|
|
||||||
var sponsorTimes = [];
|
|
||||||
var UUIDs = [];
|
|
||||||
|
|
||||||
//the sponsor times being prepared to be submitted
|
//the sponsor times being prepared to be submitted
|
||||||
var sponsorTimesSubmitting = [];
|
var sponsorTimesSubmitting = [];
|
||||||
|
|
||||||
@@ -214,7 +204,6 @@ document.onkeydown = function(e){
|
|||||||
function resetValues() {
|
function resetValues() {
|
||||||
//reset last sponsor times
|
//reset last sponsor times
|
||||||
lastTime = -1;
|
lastTime = -1;
|
||||||
lastUnixTimeSkipped = -1;
|
|
||||||
|
|
||||||
//reset sponsor times
|
//reset sponsor times
|
||||||
sponsorTimes = null;
|
sponsorTimes = null;
|
||||||
@@ -267,9 +256,6 @@ function videoIDChange(id) {
|
|||||||
|
|
||||||
resetValues();
|
resetValues();
|
||||||
|
|
||||||
//see if there is a video start time
|
|
||||||
youtubeVideoStartTime = getYouTubeVideoStartTime(document.URL);
|
|
||||||
|
|
||||||
sponsorsLookup(id);
|
sponsorsLookup(id);
|
||||||
|
|
||||||
//make sure everything is properly added
|
//make sure everything is properly added
|
||||||
@@ -296,6 +282,8 @@ function videoIDChange(id) {
|
|||||||
//see if this data should be saved in the sponsorTimesSubmitting variable
|
//see if this data should be saved in the sponsorTimesSubmitting variable
|
||||||
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
||||||
sponsorTimesSubmitting = sponsorTimes;
|
sponsorTimesSubmitting = sponsorTimes;
|
||||||
|
|
||||||
|
updatePreviewBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -391,7 +379,21 @@ function sponsorsLookup(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updatePreviewBar() {
|
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
|
//update last video id
|
||||||
lastPreviewBarUpdate = getYouTubeVideoID(document.URL);
|
lastPreviewBarUpdate = getYouTubeVideoID(document.URL);
|
||||||
@@ -476,7 +478,7 @@ function checkSponsorTime(sponsorTimes, index, openNotice) {
|
|||||||
lastTime = v.currentTime - 0.0001;
|
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
|
//skip it
|
||||||
skipToTime(v, index, sponsorTimes, openNotice);
|
skipToTime(v, index, sponsorTimes, openNotice);
|
||||||
|
|
||||||
@@ -487,15 +489,13 @@ function checkSponsorTime(sponsorTimes, index, openNotice) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkIfTimeToSkip(currentVideoTime, startTime) {
|
function checkIfTimeToSkip(currentVideoTime, startTime, endTime) {
|
||||||
let currentTime = Date.now();
|
|
||||||
|
|
||||||
//If the sponsor time is in between these times, skip it
|
//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
|
//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)
|
// 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
|
//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) < 0.3 && startTime >= lastTime && startTime <= currentVideoTime &&
|
return (Math.abs(currentVideoTime - startTime) < 3 && startTime >= lastTime && startTime <= currentVideoTime) ||
|
||||||
(lastUnixTimeSkipped == -1 || currentTime - lastUnixTimeSkipped > 500)) || (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
|
//skip fromt he start time to the end time for a certain index sponsor time
|
||||||
@@ -509,13 +509,13 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
|
|||||||
|
|
||||||
if (openNotice) {
|
if (openNotice) {
|
||||||
//send out the message saying that a sponsor message was skipped
|
//send out the message saying that a sponsor message was skipped
|
||||||
openSkipNotice(currentUUID);
|
if (!dontShowNotice) {
|
||||||
|
new SkipNotice(this, currentUUID);
|
||||||
setTimeout(() => closeSkipNotice(currentUUID), 7000);
|
|
||||||
|
|
||||||
//auto-upvote this sponsor
|
//auto-upvote this sponsor
|
||||||
if (trackViewCount) {
|
if (trackViewCount) {
|
||||||
vote(1, currentUUID, true);
|
vote(1, currentUUID, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -525,12 +525,17 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function goBackToPreviousTime(UUID) {
|
function unskipSponsorTime(UUID) {
|
||||||
if (sponsorTimes != null) {
|
if (sponsorTimes != null) {
|
||||||
//add a tiny bit of time to make sure it is not skipped again
|
//add a tiny bit of time to make sure it is not skipped again
|
||||||
v.currentTime = sponsorTimes[UUIDs.indexOf(UUID)][0] + 0.001;
|
v.currentTime = sponsorTimes[UUIDs.indexOf(UUID)][0] + 0.001;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
closeSkipNotice(UUID);
|
function reskipSponsorTime(UUID) {
|
||||||
|
if (sponsorTimes != null) {
|
||||||
|
//add a tiny bit of time to make sure it is not skipped again
|
||||||
|
v.currentTime = sponsorTimes[UUIDs.indexOf(UUID)][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -620,6 +625,8 @@ function updateSponsorTimesSubmitting() {
|
|||||||
//see if this data should be saved in the sponsorTimesSubmitting variable
|
//see if this data should be saved in the sponsorTimesSubmitting variable
|
||||||
if (sponsorTimes != undefined) {
|
if (sponsorTimes != undefined) {
|
||||||
sponsorTimesSubmitting = sponsorTimes;
|
sponsorTimesSubmitting = sponsorTimes;
|
||||||
|
|
||||||
|
updatePreviewBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -846,244 +853,20 @@ function clearSponsorTimes() {
|
|||||||
//clear sponsor times submitting
|
//clear sponsor times submitting
|
||||||
sponsorTimesSubmitting = [];
|
sponsorTimesSubmitting = [];
|
||||||
|
|
||||||
|
updatePreviewBar();
|
||||||
|
|
||||||
//set buttons to be correct
|
//set buttons to be correct
|
||||||
changeStartSponsorButton(true, false);
|
changeStartSponsorButton(true, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//Opens the notice that tells the user that a sponsor was just skipped
|
//if skipNotice is null, it will not affect the UI
|
||||||
function openSkipNotice(UUID){
|
function vote(type, UUID, skipNotice) {
|
||||||
if (dontShowNotice) {
|
if (skipNotice != null) {
|
||||||
//don't show, return
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let amountOfPreviousNotices = document.getElementsByClassName("sponsorSkipNotice").length;
|
|
||||||
|
|
||||||
if (amountOfPreviousNotices > 0) {
|
|
||||||
//already exists
|
|
||||||
|
|
||||||
let previousNotice = document.getElementsByClassName("sponsorSkipNotice")[0];
|
|
||||||
previousNotice.classList.add("secondSkipNotice")
|
|
||||||
}
|
|
||||||
|
|
||||||
let noticeElement = document.createElement("div");
|
|
||||||
//what sponsor time this is about
|
|
||||||
noticeElement.id = "sponsorSkipNotice" + UUID;
|
|
||||||
noticeElement.classList.add("sponsorSkipObject");
|
|
||||||
noticeElement.classList.add("sponsorSkipNotice");
|
|
||||||
noticeElement.style.zIndex = 50 + amountOfPreviousNotices;
|
|
||||||
|
|
||||||
//the row that will contain the info
|
|
||||||
let firstRow = document.createElement("tr");
|
|
||||||
firstRow.id = "sponsorSkipNoticeFirstRow" + UUID;
|
|
||||||
|
|
||||||
let logoColumn = document.createElement("td");
|
|
||||||
|
|
||||||
let logoElement = document.createElement("img");
|
|
||||||
logoElement.id = "sponsorSkipLogo" + UUID;
|
|
||||||
logoElement.className = "sponsorSkipLogo sponsorSkipObject";
|
|
||||||
logoElement.src = chrome.extension.getURL("icons/IconSponsorBlocker256px.png");
|
|
||||||
|
|
||||||
let noticeMessage = document.createElement("span");
|
|
||||||
noticeMessage.id = "sponsorSkipMessage" + UUID;
|
|
||||||
noticeMessage.classList.add("sponsorSkipMessage");
|
|
||||||
noticeMessage.classList.add("sponsorSkipObject");
|
|
||||||
noticeMessage.innerText = chrome.i18n.getMessage("noticeTitle");
|
|
||||||
|
|
||||||
//create the first column
|
|
||||||
logoColumn.appendChild(logoElement);
|
|
||||||
logoColumn.appendChild(noticeMessage);
|
|
||||||
|
|
||||||
//add the x button
|
|
||||||
let closeButtonContainer = document.createElement("td");
|
|
||||||
closeButtonContainer.className = "sponsorSkipNoticeRightSection";
|
|
||||||
closeButtonContainer.style.top = "11px";
|
|
||||||
|
|
||||||
let timeLeft = document.createElement("span");
|
|
||||||
timeLeft.innerText = chrome.i18n.getMessage("noticeClosingMessage");
|
|
||||||
timeLeft.className = "sponsorSkipObject sponsorSkipNoticeTimeLeft";
|
|
||||||
|
|
||||||
let hideButton = document.createElement("img");
|
|
||||||
hideButton.src = chrome.extension.getURL("icons/close.png");
|
|
||||||
hideButton.className = "sponsorSkipObject sponsorSkipNoticeButton sponsorSkipNoticeCloseButton sponsorSkipNoticeRightButton";
|
|
||||||
hideButton.addEventListener("click", () => closeSkipNotice(UUID));
|
|
||||||
|
|
||||||
closeButtonContainer.appendChild(timeLeft);
|
|
||||||
closeButtonContainer.appendChild(hideButton);
|
|
||||||
|
|
||||||
//add all objects to first row
|
|
||||||
firstRow.appendChild(logoColumn);
|
|
||||||
firstRow.appendChild(closeButtonContainer);
|
|
||||||
|
|
||||||
let spacer = document.createElement("hr");
|
|
||||||
spacer.id = "sponsorSkipNoticeSpacer" + UUID;
|
|
||||||
spacer.className = "sponsorBlockSpacer";
|
|
||||||
|
|
||||||
//the row that will contain the buttons
|
|
||||||
let secondRow = document.createElement("tr");
|
|
||||||
secondRow.id = "sponsorSkipNoticeSecondRow" + UUID;
|
|
||||||
|
|
||||||
//thumbs up and down buttons
|
|
||||||
let voteButtonsContainer = document.createElement("td");
|
|
||||||
voteButtonsContainer.id = "sponsorTimesVoteButtonsContainer" + UUID;
|
|
||||||
|
|
||||||
let reportText = document.createElement("span");
|
|
||||||
reportText.id = "sponsorTimesReportText" + UUID;
|
|
||||||
reportText.className = "sponsorTimesInfoMessage sponsorTimesVoteButtonMessage";
|
|
||||||
reportText.innerText = chrome.i18n.getMessage("reportButtonTitle");
|
|
||||||
reportText.style.marginRight = "5px";
|
|
||||||
reportText.setAttribute("title", chrome.i18n.getMessage("reportButtonInfo"));
|
|
||||||
|
|
||||||
let downvoteButton = document.createElement("img");
|
|
||||||
downvoteButton.id = "sponsorTimesDownvoteButtonsContainer" + UUID;
|
|
||||||
downvoteButton.className = "sponsorSkipObject voteButton";
|
|
||||||
downvoteButton.src = chrome.extension.getURL("icons/report.png");
|
|
||||||
downvoteButton.addEventListener("click", () => vote(0, UUID));
|
|
||||||
downvoteButton.setAttribute("title", chrome.i18n.getMessage("reportButtonInfo"));
|
|
||||||
|
|
||||||
//add downvote and report text to container
|
|
||||||
voteButtonsContainer.appendChild(reportText);
|
|
||||||
voteButtonsContainer.appendChild(downvoteButton);
|
|
||||||
|
|
||||||
//add unskip button
|
|
||||||
let unskipContainer = document.createElement("td");
|
|
||||||
unskipContainer.className = "sponsorSkipNoticeUnskipSection";
|
|
||||||
|
|
||||||
let unskipButton = document.createElement("button");
|
|
||||||
unskipButton.innerText = chrome.i18n.getMessage("goBack");
|
|
||||||
unskipButton.className = "sponsorSkipObject sponsorSkipNoticeButton";
|
|
||||||
unskipButton.addEventListener("click", () => goBackToPreviousTime(UUID));
|
|
||||||
|
|
||||||
unskipContainer.appendChild(unskipButton);
|
|
||||||
|
|
||||||
//add don't show again button
|
|
||||||
let dontshowContainer = document.createElement("td");
|
|
||||||
dontshowContainer.className = "sponsorSkipNoticeRightSection";
|
|
||||||
|
|
||||||
let dontShowAgainButton = document.createElement("button");
|
|
||||||
dontShowAgainButton.innerText = chrome.i18n.getMessage("Hide");
|
|
||||||
dontShowAgainButton.className = "sponsorSkipObject sponsorSkipNoticeButton sponsorSkipNoticeRightButton";
|
|
||||||
dontShowAgainButton.addEventListener("click", dontShowNoticeAgain);
|
|
||||||
|
|
||||||
dontshowContainer.appendChild(dontShowAgainButton);
|
|
||||||
|
|
||||||
//add to row
|
|
||||||
secondRow.appendChild(voteButtonsContainer);
|
|
||||||
secondRow.appendChild(unskipContainer);
|
|
||||||
secondRow.appendChild(dontshowContainer);
|
|
||||||
|
|
||||||
noticeElement.appendChild(firstRow);
|
|
||||||
noticeElement.appendChild(spacer);
|
|
||||||
noticeElement.appendChild(secondRow);
|
|
||||||
|
|
||||||
let referenceNode = document.getElementById("movie_player");
|
|
||||||
if (referenceNode == null) {
|
|
||||||
//for embeds
|
|
||||||
let player = document.getElementById("player");
|
|
||||||
referenceNode = player.firstChild;
|
|
||||||
let index = 1;
|
|
||||||
|
|
||||||
//find the child that is the video player (sometimes it is not the first)
|
|
||||||
while (!referenceNode.classList.contains("html5-video-player") || !referenceNode.classList.contains("ytp-embed")) {
|
|
||||||
referenceNode = player.children[index];
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
referenceNode.prepend(noticeElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
function afterDownvote(UUID) {
|
|
||||||
addVoteButtonInfo(chrome.i18n.getMessage("Voted"), UUID);
|
|
||||||
addNoticeInfoMessage(chrome.i18n.getMessage("hitGoBack"), UUID);
|
|
||||||
|
|
||||||
//remove this sponsor from the sponsors looked up
|
|
||||||
//find which one it is
|
|
||||||
for (let i = 0; i < sponsorTimes.length; i++) {
|
|
||||||
if (UUIDs[i] == UUID) {
|
|
||||||
//this one is the one to hide
|
|
||||||
|
|
||||||
//add this as a hidden sponsorTime
|
|
||||||
hiddenSponsorTimes.push(i);
|
|
||||||
|
|
||||||
let sponsorTimesLeft = sponsorTimes.slice();
|
|
||||||
for (let j = 0; j < hiddenSponsorTimes.length; j++) {
|
|
||||||
//remove this sponsor time
|
|
||||||
sponsorTimesLeft.splice(hiddenSponsorTimes[j], 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//update the preview
|
|
||||||
previewBar.set(sponsorTimesLeft, [], v.duration);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addNoticeInfoMessage(message, UUID) {
|
|
||||||
let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + UUID);
|
|
||||||
if (previousInfoMessage != null) {
|
|
||||||
//remove it
|
|
||||||
document.getElementById("sponsorSkipNotice" + UUID).removeChild(previousInfoMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
//add info
|
|
||||||
let thanksForVotingText = document.createElement("p");
|
|
||||||
thanksForVotingText.id = "sponsorTimesInfoMessage" + UUID;
|
|
||||||
thanksForVotingText.className = "sponsorTimesInfoMessage";
|
|
||||||
thanksForVotingText.innerText = message;
|
|
||||||
|
|
||||||
//add element to div
|
|
||||||
document.getElementById("sponsorSkipNotice" + UUID).insertBefore(thanksForVotingText, document.getElementById("sponsorSkipNoticeSpacer" + UUID));
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetNoticeInfoMessage(UUID) {
|
|
||||||
let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + UUID);
|
|
||||||
if (previousInfoMessage != null) {
|
|
||||||
//remove it
|
|
||||||
document.getElementById("sponsorSkipNotice" + UUID).removeChild(previousInfoMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addVoteButtonInfo(message, UUID) {
|
|
||||||
resetVoteButtonInfo(UUID);
|
|
||||||
|
|
||||||
//hide vote button
|
|
||||||
let downvoteButton = document.getElementById("sponsorTimesDownvoteButtonsContainer" + UUID);
|
|
||||||
if (downvoteButton != null) {
|
|
||||||
document.getElementById("sponsorTimesDownvoteButtonsContainer" + UUID).style.display = "none";
|
|
||||||
}
|
|
||||||
|
|
||||||
//add info
|
|
||||||
let thanksForVotingText = document.createElement("td");
|
|
||||||
thanksForVotingText.id = "sponsorTimesVoteButtonInfoMessage" + UUID;
|
|
||||||
thanksForVotingText.className = "sponsorTimesInfoMessage sponsorTimesVoteButtonMessage";
|
|
||||||
thanksForVotingText.innerText = message;
|
|
||||||
|
|
||||||
//add element to div
|
|
||||||
document.getElementById("sponsorSkipNoticeSecondRow" + UUID).prepend(thanksForVotingText);
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetVoteButtonInfo(UUID) {
|
|
||||||
let previousInfoMessage = document.getElementById("sponsorTimesVoteButtonInfoMessage" + UUID);
|
|
||||||
if (previousInfoMessage != null) {
|
|
||||||
//remove it
|
|
||||||
document.getElementById("sponsorSkipNoticeSecondRow" + UUID).removeChild(previousInfoMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
//show button again
|
|
||||||
document.getElementById("sponsorTimesDownvoteButtonsContainer" + UUID).style.removeProperty("display");
|
|
||||||
}
|
|
||||||
|
|
||||||
//if inTheBackground is true, then no UI methods will be called
|
|
||||||
function vote(type, UUID, inTheBackground = false) {
|
|
||||||
if (!inTheBackground) {
|
|
||||||
//add loading info
|
//add loading info
|
||||||
addVoteButtonInfo("Loading...", UUID)
|
skipNotice.addVoteButtonInfo.bind(skipNotice)("Loading...")
|
||||||
resetNoticeInfoMessage(UUID);
|
skipNotice.resetNoticeInfoMessage.bind(skipNotice)();
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
@@ -1093,24 +876,24 @@ function vote(type, UUID, inTheBackground = false) {
|
|||||||
}, function(response) {
|
}, function(response) {
|
||||||
if (response != undefined) {
|
if (response != undefined) {
|
||||||
//see if it was a success or failure
|
//see if it was a success or failure
|
||||||
if (!inTheBackground) {
|
if (skipNotice != null) {
|
||||||
if (response.successType == 1) {
|
if (response.successType == 1) {
|
||||||
//success
|
//success
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
afterDownvote(UUID);
|
skipNotice.afterDownvote.bind(skipNotice)();
|
||||||
}
|
}
|
||||||
} else if (response.successType == 0) {
|
} else if (response.successType == 0) {
|
||||||
//failure: duplicate vote
|
//failure: duplicate vote
|
||||||
addNoticeInfoMessage(chrome.i18n.getMessage("voteFAIL"), UUID)
|
skipNotice.addNoticeInfoMessage.bind(skipNotice)(chrome.i18n.getMessage("voteFail"))
|
||||||
resetVoteButtonInfo(UUID);
|
skipNotice.resetVoteButtonInfo.bind(skipNotice)();
|
||||||
} else if (response.successType == -1) {
|
} else if (response.successType == -1) {
|
||||||
if (response.statusCode == 502) {
|
if (response.statusCode == 502) {
|
||||||
addNoticeInfoMessage(chrome.i18n.getMessage("serverDown"), UUID)
|
skipNotice.addNoticeInfoMessage.bind(skipNotice)(chrome.i18n.getMessage("serverDown"))
|
||||||
resetVoteButtonInfo(UUID);
|
skipNotice.resetVoteButtonInfo.bind(skipNotice)();
|
||||||
} else {
|
} else {
|
||||||
//failure: unknown error
|
//failure: unknown error
|
||||||
addNoticeInfoMessage(chrome.i18n.getMessage("connectionError") + response.statusCode, UUID);
|
skipNotice.addNoticeInfoMessage.bind(skipNotice)(chrome.i18n.getMessage("connectionError") + response.statusCode);
|
||||||
resetVoteButtonInfo(UUID);
|
skipNotice.resetVoteButtonInfo.bind(skipNotice)();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1118,14 +901,6 @@ function vote(type, UUID, inTheBackground = false) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//Closes the notice that tells the user that a sponsor was just skipped for this UUID
|
|
||||||
function closeSkipNotice(UUID){
|
|
||||||
let notice = document.getElementById("sponsorSkipNotice" + UUID);
|
|
||||||
if (notice != null) {
|
|
||||||
notice.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Closes all notices that tell the user that a sponsor was just skipped
|
//Closes all notices that tell the user that a sponsor was just skipped
|
||||||
function closeAllSkipNotices(){
|
function closeAllSkipNotices(){
|
||||||
let notices = document.getElementsByClassName("sponsorSkipNotice");
|
let notices = document.getElementsByClassName("sponsorSkipNotice");
|
||||||
@@ -1170,8 +945,8 @@ function submitSponsorTimes() {
|
|||||||
let sponsorTimes = result[sponsorTimeKey];
|
let sponsorTimes = result[sponsorTimeKey];
|
||||||
|
|
||||||
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
||||||
let confirmMessage = "Are you sure you want to submit this?\n\n" + getSponsorTimesMessage(sponsorTimes);
|
let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\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."
|
confirmMessage += "\n\n" + chrome.i18n.getMessage("confirmMSG");
|
||||||
if(!confirm(confirmMessage)) return;
|
if(!confirm(confirmMessage)) return;
|
||||||
|
|
||||||
sendSubmitMessage();
|
sendSubmitMessage();
|
||||||
@@ -1217,7 +992,6 @@ function sendSubmitMessage(){
|
|||||||
//request the sponsors from the server again
|
//request the sponsors from the server again
|
||||||
sponsorsLookup(currentVideoID);
|
sponsorsLookup(currentVideoID);
|
||||||
} else {
|
} else {
|
||||||
//for a more detailed error message, they should check the popup
|
|
||||||
//show that the upload failed
|
//show that the upload failed
|
||||||
document.getElementById("submitButton").style.animation = "unset";
|
document.getElementById("submitButton").style.animation = "unset";
|
||||||
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png");
|
document.getElementById("submitButtonImage").src = chrome.extension.getURL("icons/PlayerUploadFailedIconSponsorBlocker256px.png");
|
||||||
|
|||||||
8
firefox_manifest-extra.json
Normal file
8
firefox_manifest-extra.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"browser_specific_settings": {
|
||||||
|
"gecko": {
|
||||||
|
"id": "sponsorBlocker@ajay.app",
|
||||||
|
"strict_min_version": "57.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "SponsorBlock - YouTube Sponsorship Blocker",
|
|
||||||
"short_name": "SponsorBlock",
|
|
||||||
"version": "1.0.12",
|
|
||||||
"description": "Skip over sponsorship on YouTube videos. Report sponsors on videos you watch to save the time of others.",
|
|
||||||
"content_scripts": [
|
|
||||||
{
|
|
||||||
"matches": [
|
|
||||||
"https://*.youtube.com/*"
|
|
||||||
],
|
|
||||||
"js": [
|
|
||||||
"config.js",
|
|
||||||
"content.js",
|
|
||||||
"popup.js"
|
|
||||||
],
|
|
||||||
"css": [
|
|
||||||
"content.css",
|
|
||||||
"./libs/Source+Sans+Pro.css",
|
|
||||||
"popup.css"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"web_accessible_resources": [
|
|
||||||
"icons/LogoSponsorBlocker256px.png",
|
|
||||||
"icons/IconSponsorBlocker256px.png",
|
|
||||||
"icons/PlayerStartIconSponsorBlocker256px.png",
|
|
||||||
"icons/PlayerStopIconSponsorBlocker256px.png",
|
|
||||||
"icons/PlayerUploadIconSponsorBlocker256px.png",
|
|
||||||
"icons/PlayerUploadFailedIconSponsorBlocker256px.png",
|
|
||||||
"icons/upvote.png",
|
|
||||||
"icons/downvote.png",
|
|
||||||
"icons/PlayerInfoIconSponsorBlocker256px.png",
|
|
||||||
"icons/PlayerDeleteIconSponsorBlocker256px.png",
|
|
||||||
"popup.html",
|
|
||||||
"help/index.html",
|
|
||||||
"help/style.css"
|
|
||||||
],
|
|
||||||
"permissions": [
|
|
||||||
"tabs",
|
|
||||||
"storage",
|
|
||||||
"notifications",
|
|
||||||
"https://sponsor.ajay.app/*"
|
|
||||||
],
|
|
||||||
"browser_action": {
|
|
||||||
"default_title": "SponsorBlock",
|
|
||||||
"default_popup": "popup.html"
|
|
||||||
},
|
|
||||||
"background": {
|
|
||||||
"scripts":[
|
|
||||||
"config.js",
|
|
||||||
"background.js"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"icons": {
|
|
||||||
"16": "icons/IconSponsorBlocker16px.png",
|
|
||||||
"32": "icons/IconSponsorBlocker32px.png",
|
|
||||||
"64": "icons/LogoSponsorBlocker64px.png",
|
|
||||||
"128": "icons/LogoSponsorBlocker128px.png",
|
|
||||||
"256": "icons/LogoSponsorBlocker256px.png"
|
|
||||||
},
|
|
||||||
"browser_specific_settings": {
|
|
||||||
"gecko": {
|
|
||||||
"id": "sponsorBlocker@ajay.app",
|
|
||||||
"strict_min_version": "57.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"manifest_version": 2
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "__MSG_fullName__",
|
"name": "__MSG_fullName__",
|
||||||
"short_name": "__MSG_Name__",
|
"short_name": "__MSG_Name__",
|
||||||
"version": "1.0.38",
|
"version": "1.1.2",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"description": "__MSG_Description__",
|
"description": "__MSG_Description__",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
"js": [
|
"js": [
|
||||||
"config.js",
|
"config.js",
|
||||||
"utils/previewBar.js",
|
"utils/previewBar.js",
|
||||||
|
"utils/skipNotice.js",
|
||||||
"utils.js",
|
"utils.js",
|
||||||
"content.js",
|
"content.js",
|
||||||
"popup.js"
|
"popup.js"
|
||||||
|
|||||||
12
popup.css
12
popup.css
@@ -110,17 +110,17 @@ h1.popupElement {
|
|||||||
text-decoration:none;
|
text-decoration:none;
|
||||||
text-shadow:0px 0px 0px #27663c;
|
text-shadow:0px 0px 0px #27663c;
|
||||||
}
|
}
|
||||||
.whitelistButton:hover.popupElement {
|
.whitelistButton:hover.popupElement {
|
||||||
background-color:#218b26;
|
background-color:#218b26;
|
||||||
}
|
}
|
||||||
.whitelistButton:focus.popupElement {
|
.whitelistButton:focus.popupElement {
|
||||||
outline: none;
|
outline: none;
|
||||||
background-color:#218b26;
|
background-color:#218b26;
|
||||||
}
|
}
|
||||||
.whitelistButton:active.popupElement {
|
.whitelistButton:active.popupElement {
|
||||||
position:relative;
|
position:relative;
|
||||||
top:1px;
|
top:1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.greenButton.popupElement {
|
.greenButton.popupElement {
|
||||||
background-color:#ec1c1c;
|
background-color:#ec1c1c;
|
||||||
|
|||||||
29
popup.js
29
popup.js
@@ -799,7 +799,13 @@ function runThePopup() {
|
|||||||
|
|
||||||
clearTimes();
|
clearTimes();
|
||||||
} else {
|
} else {
|
||||||
let errorMessage = getErrorMessage(response.statusCode);
|
let errorMessage = "";
|
||||||
|
|
||||||
|
if([400,429,409,502].includes(response.statusCode)) {
|
||||||
|
errorMessage = chrome.i18n.getMessage(response.statusCode);
|
||||||
|
} else {
|
||||||
|
errorMessage = chrome.i18n.getMessage("connectionError") + response.statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById("submitTimesInfoMessage").innerText = errorMessage;
|
document.getElementById("submitTimesInfoMessage").innerText = errorMessage;
|
||||||
document.getElementById("submitTimesInfoMessageContainer").style.display = "unset";
|
document.getElementById("submitTimesInfoMessageContainer").style.display = "unset";
|
||||||
@@ -1010,11 +1016,14 @@ function runThePopup() {
|
|||||||
|
|
||||||
SB.setUsernameContainer.style.display = "none";
|
SB.setUsernameContainer.style.display = "none";
|
||||||
SB.setUsername.style.display = "unset";
|
SB.setUsername.style.display = "unset";
|
||||||
} else {
|
|
||||||
|
SB.setUsernameStatusContainer.style.display = "none";
|
||||||
|
} else if (xmlhttp.readyState == 4) {
|
||||||
SB.setUsername.style.display = "unset";
|
SB.setUsername.style.display = "unset";
|
||||||
SB.submitUsername.style.display = "none";
|
SB.submitUsername.style.display = "none";
|
||||||
SB.usernameInput.style.display = "none";
|
SB.usernameInput.style.display = "none";
|
||||||
|
|
||||||
|
SB.setUsernameStatusContainer.style.display = "unset";
|
||||||
SB.setUsernameStatus.innerText = "Couldn't connect to server. Error code: " + xmlhttp.status;
|
SB.setUsernameStatus.innerText = "Couldn't connect to server. Error code: " + xmlhttp.status;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1035,11 +1044,17 @@ function runThePopup() {
|
|||||||
SB.submitUsername.style.display = "none";
|
SB.submitUsername.style.display = "none";
|
||||||
SB.usernameInput.style.display = "none";
|
SB.usernameInput.style.display = "none";
|
||||||
|
|
||||||
SB.setUsernameStatus.innerText = "Success!";
|
SB.setUsernameStatus.innerText = chrome.i18n.getMessage("success");
|
||||||
} else if (xmlhttp.readyState == 4 && xmlhttp.status == 400) {
|
} else if (xmlhttp.readyState == 4) {
|
||||||
SB.setUsernameStatus.innerText = "Bad Request";
|
let errorMessage = "";
|
||||||
|
|
||||||
|
if([400, 429, 409, 502].includes(xmlhttp.status)) {
|
||||||
|
errorMessage = chrome.i18n.getMessage(xmlhttp.status);
|
||||||
} else {
|
} else {
|
||||||
SB.setUsernameStatus.innerText = getErrorMessage(EN_US, xmlhttp.status);
|
errorMessage = chrome.i18n.getMessage("connectionError") + xmlhttp.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
SB.setUsernameStatus.innerText = errorMessage;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1088,7 +1103,7 @@ function runThePopup() {
|
|||||||
//see if it was a success or failure
|
//see if it was a success or failure
|
||||||
if (response.successType == 1) {
|
if (response.successType == 1) {
|
||||||
//success
|
//success
|
||||||
addVoteMessage(chrome.i18n.getMessage("Voted"), UUID)
|
addVoteMessage(chrome.i18n.getMessage("voted"), UUID)
|
||||||
} else if (response.successType == 0) {
|
} else if (response.successType == 0) {
|
||||||
//failure: duplicate vote
|
//failure: duplicate vote
|
||||||
addVoteMessage(chrome.i18n.getMessage("voteFail"), UUID)
|
addVoteMessage(chrome.i18n.getMessage("voteFail"), UUID)
|
||||||
|
|||||||
27
utils.js
27
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) {
|
function getYouTubeVideoID(url) {
|
||||||
//Attempt to parse url
|
//Attempt to parse url
|
||||||
let urlObject = null;
|
let urlObject = null;
|
||||||
@@ -5,7 +19,7 @@ function getYouTubeVideoID(url) {
|
|||||||
urlObject = new URL(url);
|
urlObject = new URL(url);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("[SB] Unable to parse URL: " + url);
|
console.error("[SB] Unable to parse URL: " + url);
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if valid hostname
|
//Check if valid hostname
|
||||||
@@ -24,14 +38,3 @@ function getYouTubeVideoID(url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ let barTypes = {
|
|||||||
"sponsor": {
|
"sponsor": {
|
||||||
color: "#00d400",
|
color: "#00d400",
|
||||||
opacity: "0.5"
|
opacity: "0.5"
|
||||||
|
},
|
||||||
|
"previewSponsor": {
|
||||||
|
color: "#0000d4",
|
||||||
|
opacity: "0.5"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
367
utils/skipNotice.js
Normal file
367
utils/skipNotice.js
Normal file
@@ -0,0 +1,367 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
//The notice that tells the user that a sponsor was just skipped
|
||||||
|
class SkipNotice {
|
||||||
|
constructor(parent, UUID) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.UUID = UUID;
|
||||||
|
|
||||||
|
this.maxCountdownTime = () => 4;
|
||||||
|
//the countdown until this notice closes
|
||||||
|
this.countdownTime = this.maxCountdownTime();
|
||||||
|
//the id for the setInterval running the countdown
|
||||||
|
this.countdownInterval = -1;
|
||||||
|
|
||||||
|
//the unskip button's callback
|
||||||
|
this.unskipCallback = this.unskip.bind(this);
|
||||||
|
|
||||||
|
//add notice
|
||||||
|
let amountOfPreviousNotices = document.getElementsByClassName("sponsorSkipNotice").length;
|
||||||
|
|
||||||
|
//this is the suffix added at the end of every id
|
||||||
|
this.idSuffix = this.UUID + amountOfPreviousNotices;
|
||||||
|
|
||||||
|
if (amountOfPreviousNotices > 0) {
|
||||||
|
//already exists
|
||||||
|
|
||||||
|
let previousNotice = document.getElementsByClassName("sponsorSkipNotice")[0];
|
||||||
|
previousNotice.classList.add("secondSkipNotice")
|
||||||
|
}
|
||||||
|
|
||||||
|
let noticeElement = document.createElement("div");
|
||||||
|
//what sponsor time this is about
|
||||||
|
noticeElement.id = "sponsorSkipNotice" + this.idSuffix;
|
||||||
|
noticeElement.classList.add("sponsorSkipObject");
|
||||||
|
noticeElement.classList.add("sponsorSkipNotice");
|
||||||
|
noticeElement.style.zIndex = 50 + amountOfPreviousNotices;
|
||||||
|
|
||||||
|
//add mouse enter and leave listeners
|
||||||
|
noticeElement.addEventListener("mouseenter", this.pauseCountdown.bind(this));
|
||||||
|
noticeElement.addEventListener("mouseleave", this.startCountdown.bind(this));
|
||||||
|
|
||||||
|
//the row that will contain the info
|
||||||
|
let firstRow = document.createElement("tr");
|
||||||
|
firstRow.id = "sponsorSkipNoticeFirstRow" + this.idSuffix;
|
||||||
|
|
||||||
|
let logoColumn = document.createElement("td");
|
||||||
|
|
||||||
|
let logoElement = document.createElement("img");
|
||||||
|
logoElement.id = "sponsorSkipLogo" + this.idSuffix;
|
||||||
|
logoElement.className = "sponsorSkipLogo sponsorSkipObject";
|
||||||
|
logoElement.src = chrome.extension.getURL("icons/IconSponsorBlocker256px.png");
|
||||||
|
|
||||||
|
let noticeMessage = document.createElement("span");
|
||||||
|
noticeMessage.id = "sponsorSkipMessage" + this.idSuffix;
|
||||||
|
noticeMessage.classList.add("sponsorSkipMessage");
|
||||||
|
noticeMessage.classList.add("sponsorSkipObject");
|
||||||
|
noticeMessage.innerText = chrome.i18n.getMessage("noticeTitle");
|
||||||
|
|
||||||
|
//create the first column
|
||||||
|
logoColumn.appendChild(logoElement);
|
||||||
|
logoColumn.appendChild(noticeMessage);
|
||||||
|
|
||||||
|
//add the x button
|
||||||
|
let closeButtonContainer = document.createElement("td");
|
||||||
|
closeButtonContainer.className = "sponsorSkipNoticeRightSection";
|
||||||
|
closeButtonContainer.style.top = "11px";
|
||||||
|
|
||||||
|
let timeLeft = document.createElement("span");
|
||||||
|
timeLeft.id = "sponsorSkipNoticeTimeLeft" + this.idSuffix;
|
||||||
|
timeLeft.innerText = this.countdownTime + "s";
|
||||||
|
timeLeft.className = "sponsorSkipObject sponsorSkipNoticeTimeLeft";
|
||||||
|
|
||||||
|
let hideButton = document.createElement("img");
|
||||||
|
hideButton.src = chrome.extension.getURL("icons/close.png");
|
||||||
|
hideButton.className = "sponsorSkipObject sponsorSkipNoticeButton sponsorSkipNoticeCloseButton sponsorSkipNoticeRightButton";
|
||||||
|
hideButton.addEventListener("click", this.close.bind(this));
|
||||||
|
|
||||||
|
closeButtonContainer.appendChild(timeLeft);
|
||||||
|
closeButtonContainer.appendChild(hideButton);
|
||||||
|
|
||||||
|
//add all objects to first row
|
||||||
|
firstRow.appendChild(logoColumn);
|
||||||
|
firstRow.appendChild(closeButtonContainer);
|
||||||
|
|
||||||
|
let spacer = document.createElement("hr");
|
||||||
|
spacer.id = "sponsorSkipNoticeSpacer" + this.idSuffix;
|
||||||
|
spacer.className = "sponsorBlockSpacer";
|
||||||
|
|
||||||
|
//the row that will contain the buttons
|
||||||
|
let secondRow = document.createElement("tr");
|
||||||
|
secondRow.id = "sponsorSkipNoticeSecondRow" + this.idSuffix;
|
||||||
|
|
||||||
|
//thumbs up and down buttons
|
||||||
|
let voteButtonsContainer = document.createElement("td");
|
||||||
|
voteButtonsContainer.id = "sponsorTimesVoteButtonsContainer" + this.idSuffix;
|
||||||
|
voteButtonsContainer.className = "sponsorTimesVoteButtonsContainer"
|
||||||
|
|
||||||
|
let reportText = document.createElement("span");
|
||||||
|
reportText.id = "sponsorTimesReportText" + this.idSuffix;
|
||||||
|
reportText.className = "sponsorTimesInfoMessage sponsorTimesVoteButtonMessage";
|
||||||
|
reportText.innerText = chrome.i18n.getMessage("reportButtonTitle");
|
||||||
|
reportText.style.marginRight = "5px";
|
||||||
|
reportText.setAttribute("title", chrome.i18n.getMessage("reportButtonInfo"));
|
||||||
|
|
||||||
|
let downvoteButton = document.createElement("img");
|
||||||
|
downvoteButton.id = "sponsorTimesDownvoteButtonsContainer" + this.idSuffix;
|
||||||
|
downvoteButton.className = "sponsorSkipObject voteButton";
|
||||||
|
downvoteButton.src = chrome.extension.getURL("icons/report.png");
|
||||||
|
downvoteButton.addEventListener("click", () => vote(0, this.UUID, this));
|
||||||
|
downvoteButton.setAttribute("title", chrome.i18n.getMessage("reportButtonInfo"));
|
||||||
|
|
||||||
|
//add downvote and report text to container
|
||||||
|
voteButtonsContainer.appendChild(reportText);
|
||||||
|
voteButtonsContainer.appendChild(downvoteButton);
|
||||||
|
|
||||||
|
//add unskip button
|
||||||
|
let unskipContainer = document.createElement("td");
|
||||||
|
unskipContainer.className = "sponsorSkipNoticeUnskipSection";
|
||||||
|
|
||||||
|
let unskipButton = document.createElement("button");
|
||||||
|
unskipButton.id = "sponsorSkipUnskipButton" + this.idSuffix;
|
||||||
|
unskipButton.innerText = chrome.i18n.getMessage("unskip");
|
||||||
|
unskipButton.className = "sponsorSkipObject sponsorSkipNoticeButton";
|
||||||
|
unskipButton.addEventListener("click", this.unskipCallback);
|
||||||
|
|
||||||
|
unskipButton.style.marginLeft = "4px";
|
||||||
|
|
||||||
|
unskipContainer.appendChild(unskipButton);
|
||||||
|
|
||||||
|
//add don't show again button
|
||||||
|
let dontshowContainer = document.createElement("td");
|
||||||
|
dontshowContainer.className = "sponsorSkipNoticeRightSection";
|
||||||
|
|
||||||
|
let dontShowAgainButton = document.createElement("button");
|
||||||
|
dontShowAgainButton.innerText = chrome.i18n.getMessage("Hide");
|
||||||
|
dontShowAgainButton.className = "sponsorSkipObject sponsorSkipNoticeButton sponsorSkipNoticeRightButton";
|
||||||
|
dontShowAgainButton.addEventListener("click", dontShowNoticeAgain);
|
||||||
|
|
||||||
|
dontshowContainer.appendChild(dontShowAgainButton);
|
||||||
|
|
||||||
|
//add to row
|
||||||
|
secondRow.appendChild(voteButtonsContainer);
|
||||||
|
secondRow.appendChild(unskipContainer);
|
||||||
|
secondRow.appendChild(dontshowContainer);
|
||||||
|
|
||||||
|
noticeElement.appendChild(firstRow);
|
||||||
|
noticeElement.appendChild(spacer);
|
||||||
|
noticeElement.appendChild(secondRow);
|
||||||
|
|
||||||
|
//get reference node
|
||||||
|
let referenceNode = document.getElementById("movie_player");
|
||||||
|
if (referenceNode == null) {
|
||||||
|
//for embeds
|
||||||
|
let player = document.getElementById("player");
|
||||||
|
referenceNode = player.firstChild;
|
||||||
|
let index = 1;
|
||||||
|
|
||||||
|
//find the child that is the video player (sometimes it is not the first)
|
||||||
|
while (!referenceNode.classList.contains("html5-video-player") || !referenceNode.classList.contains("ytp-embed")) {
|
||||||
|
referenceNode = player.children[index];
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
referenceNode.prepend(noticeElement);
|
||||||
|
|
||||||
|
this.startCountdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
//called every second to lower the countdown before hiding the notice
|
||||||
|
countdown() {
|
||||||
|
this.countdownTime--;
|
||||||
|
|
||||||
|
if (this.countdownTime <= 0) {
|
||||||
|
//remove this from setInterval
|
||||||
|
clearInterval(this.countdownInterval);
|
||||||
|
|
||||||
|
//time to close this notice
|
||||||
|
this.close();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.countdownTime == 3) {
|
||||||
|
//start fade out animation
|
||||||
|
let notice = document.getElementById("sponsorSkipNotice" + this.idSuffix);
|
||||||
|
notice.style.removeProperty("animation");
|
||||||
|
notice.classList.add("sponsorSkipNoticeFadeOut");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateTimerDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
pauseCountdown() {
|
||||||
|
//remove setInterval
|
||||||
|
clearInterval(this.countdownInterval);
|
||||||
|
this.countdownInterval = -1;
|
||||||
|
|
||||||
|
//reset countdown
|
||||||
|
this.countdownTime = this.maxCountdownTime();
|
||||||
|
|
||||||
|
//inform the user
|
||||||
|
let timeLeft = document.getElementById("sponsorSkipNoticeTimeLeft" + this.idSuffix);
|
||||||
|
timeLeft.innerText = chrome.i18n.getMessage("paused");
|
||||||
|
|
||||||
|
//remove the fade out class if it exists
|
||||||
|
let notice = document.getElementById("sponsorSkipNotice" + this.idSuffix);
|
||||||
|
notice.classList.remove("sponsorSkipNoticeFadeOut");
|
||||||
|
notice.style.animation = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
startCountdown() {
|
||||||
|
//if it has already started, don't start it again
|
||||||
|
if (this.countdownInterval != -1) return;
|
||||||
|
|
||||||
|
this.countdownInterval = setInterval(this.countdown.bind(this), 1000);
|
||||||
|
|
||||||
|
this.updateTimerDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTimerDisplay() {
|
||||||
|
//update the timer display
|
||||||
|
let timeLeft = document.getElementById("sponsorSkipNoticeTimeLeft" + this.idSuffix);
|
||||||
|
timeLeft.innerText = this.countdownTime + "s";
|
||||||
|
}
|
||||||
|
|
||||||
|
unskip() {
|
||||||
|
unskipSponsorTime(this.UUID);
|
||||||
|
|
||||||
|
//change unskip button to a reskip button
|
||||||
|
let unskipButton = document.getElementById("sponsorSkipUnskipButton" + this.idSuffix);
|
||||||
|
unskipButton.innerText = chrome.i18n.getMessage("reskip");
|
||||||
|
unskipButton.removeEventListener("click", this.unskipCallback);
|
||||||
|
|
||||||
|
//setup new callback
|
||||||
|
this.unskipCallback = this.reskip.bind(this);
|
||||||
|
unskipButton.addEventListener("click", this.unskipCallback);
|
||||||
|
|
||||||
|
//change max duration to however much of the sponsor is left
|
||||||
|
this.maxCountdownTime = function() {
|
||||||
|
let sponsorTime = sponsorTimes[UUIDs.indexOf(this.UUID)];
|
||||||
|
let duration = Math.round(sponsorTime[1] - v.currentTime);
|
||||||
|
|
||||||
|
return Math.max(duration, 4);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.countdownTime = this.maxCountdownTime();
|
||||||
|
this.updateTimerDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
reskip() {
|
||||||
|
reskipSponsorTime(this.UUID);
|
||||||
|
|
||||||
|
//change unskip button to a reskip button
|
||||||
|
let unskipButton = document.getElementById("sponsorSkipUnskipButton" + this.idSuffix);
|
||||||
|
unskipButton.innerText = chrome.i18n.getMessage("unskip");
|
||||||
|
unskipButton.removeEventListener("click", this.unskipCallback);
|
||||||
|
|
||||||
|
//setup new callback
|
||||||
|
this.unskipCallback = this.unskip.bind(this);
|
||||||
|
unskipButton.addEventListener("click", this.unskipCallback);
|
||||||
|
|
||||||
|
//reset duration
|
||||||
|
this.maxCountdownTime = () => 4;
|
||||||
|
this.countdownTime = this.maxCountdownTime();
|
||||||
|
this.updateTimerDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
afterDownvote() {
|
||||||
|
this.addVoteButtonInfo(chrome.i18n.getMessage("voted"));
|
||||||
|
this.addNoticeInfoMessage(chrome.i18n.getMessage("hitGoBack"));
|
||||||
|
|
||||||
|
//remove this sponsor from the sponsors looked up
|
||||||
|
//find which one it is
|
||||||
|
for (let i = 0; i < sponsorTimes.length; i++) {
|
||||||
|
if (UUIDs[i] == this.UUID) {
|
||||||
|
//this one is the one to hide
|
||||||
|
|
||||||
|
//add this as a hidden sponsorTime
|
||||||
|
hiddenSponsorTimes.push(i);
|
||||||
|
|
||||||
|
let sponsorTimesLeft = sponsorTimes.slice();
|
||||||
|
for (let j = 0; j < hiddenSponsorTimes.length; j++) {
|
||||||
|
//remove this sponsor time
|
||||||
|
sponsorTimesLeft.splice(hiddenSponsorTimes[j], 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//update the preview
|
||||||
|
previewBar.set(sponsorTimesLeft, [], v.duration);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addNoticeInfoMessage(message) {
|
||||||
|
let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + this.idSuffix);
|
||||||
|
if (previousInfoMessage != null) {
|
||||||
|
//remove it
|
||||||
|
document.getElementById("sponsorSkipNotice" + this.idSuffix).removeChild(previousInfoMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
//add info
|
||||||
|
let thanksForVotingText = document.createElement("p");
|
||||||
|
thanksForVotingText.id = "sponsorTimesInfoMessage" + this.idSuffix;
|
||||||
|
thanksForVotingText.className = "sponsorTimesInfoMessage";
|
||||||
|
thanksForVotingText.innerText = message;
|
||||||
|
|
||||||
|
//add element to div
|
||||||
|
document.getElementById("sponsorSkipNotice" + this.idSuffix).insertBefore(thanksForVotingText, document.getElementById("sponsorSkipNoticeSpacer" + this.idSuffix));
|
||||||
|
}
|
||||||
|
|
||||||
|
resetNoticeInfoMessage() {
|
||||||
|
let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + this.idSuffix);
|
||||||
|
if (previousInfoMessage != null) {
|
||||||
|
//remove it
|
||||||
|
document.getElementById("sponsorSkipNotice" + this.idSuffix).removeChild(previousInfoMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addVoteButtonInfo(message) {
|
||||||
|
this.resetVoteButtonInfo();
|
||||||
|
|
||||||
|
//hide report button and text for it
|
||||||
|
let downvoteButton = document.getElementById("sponsorTimesDownvoteButtonsContainer" + this.idSuffix);
|
||||||
|
if (downvoteButton != null) {
|
||||||
|
downvoteButton.style.display = "none";
|
||||||
|
}
|
||||||
|
let downvoteButtonText = document.getElementById("sponsorTimesReportText" + this.idSuffix);
|
||||||
|
if (downvoteButtonText != null) {
|
||||||
|
downvoteButtonText.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
//add info
|
||||||
|
let thanksForVotingText = document.createElement("td");
|
||||||
|
thanksForVotingText.id = "sponsorTimesVoteButtonInfoMessage" + this.idSuffix;
|
||||||
|
thanksForVotingText.className = "sponsorTimesInfoMessage sponsorTimesVoteButtonMessage";
|
||||||
|
thanksForVotingText.innerText = message;
|
||||||
|
|
||||||
|
//add element to div
|
||||||
|
document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).prepend(thanksForVotingText);
|
||||||
|
}
|
||||||
|
|
||||||
|
resetVoteButtonInfo() {
|
||||||
|
let previousInfoMessage = document.getElementById("sponsorTimesVoteButtonInfoMessage" + this.idSuffix);
|
||||||
|
if (previousInfoMessage != null) {
|
||||||
|
//remove it
|
||||||
|
document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).removeChild(previousInfoMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
//show button again
|
||||||
|
document.getElementById("sponsorTimesDownvoteButtonsContainer" + this.idSuffix).style.removeProperty("display");
|
||||||
|
}
|
||||||
|
|
||||||
|
//close this notice
|
||||||
|
close() {
|
||||||
|
let notice = document.getElementById("sponsorSkipNotice" + this.idSuffix);
|
||||||
|
if (notice != null) {
|
||||||
|
notice.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove setInterval
|
||||||
|
if (this.countdownInterval != -1) clearInterval(this.countdownInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user