Merge branch 'experimental' into patch-21

This commit is contained in:
Official Noob 2019-08-22 19:48:59 +01:00 committed by GitHub
commit fc4da038e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 460 additions and 43 deletions

View file

@ -1,16 +1,22 @@
![Logo](icons/LogoSponsorBlocker256px.png)
<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/](https://addons.mozilla.org/addon/sponsorblock/?src=external-github)
# 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.

View file

@ -134,4 +134,7 @@
"SubmitTimes": {
"message": "Submit Sponsor Times"
},
"submitCheck": {
"message": "Are you sure you want to submit this?"
}
}

129
_locales/fr/messages.json Normal file
View 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?"
}
}

View 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
View 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": "Вы уверены, что хотите отправить эту информацию?"
}
}

View file

@ -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"
});
}

View file

@ -71,7 +71,7 @@
}
.sponsorSkipNotice {
min-width: 280px;
min-width: 300px;
background-color: rgba(28, 28, 28, 0.9);
position: absolute;
right: 5px;

View file

@ -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;
@ -254,11 +251,11 @@ function videoIDChange(id) {
previousVideoID = id;
}
addButtons();
//close popup
closeInfoMenu();
addButtons();
//see if there is a video start time
youtubeVideoStartTime = sponsorVideoID;
@ -288,11 +285,12 @@ function videoIDChange(id) {
//see if this data should be saved in the sponsorTimesSubmitting variable
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
sponsorTimesSubmitting = sponsorTimes;
}
}
});
});
pdatePreviewBar();
}
}
});
});
//see if video controls buttons should be added
chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) {
@ -385,7 +383,21 @@ function sponsorsLookup(id) {
}
function updatePreviewBar() {
previewBar.set(sponsorTimes, [], v.duration);
let localSponsorTimes = sponsorTimes;
if (localSponsorTimes == null) localSponsorTimes = [];
let allSponsorTimes = localSponsorTimes.concat(sponsorTimesSubmitting);
//create an array of the sponsor types
let types = [];
for (let i = 0; i < localSponsorTimes.length; i++) {
types.push("sponsor");
}
for (let i = 0; i < sponsorTimesSubmitting.length; i++) {
types.push("previewSponsor");
}
previewBar.set(allSponsorTimes, types, v.duration);
//update last video id
lastPreviewBarUpdate = sponsorVideoID;
@ -470,7 +482,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);
@ -481,13 +493,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
@ -619,6 +631,8 @@ function updateSponsorTimesSubmitting() {
//see if this data should be saved in the sponsorTimesSubmitting variable
if (sponsorTimes != undefined) {
sponsorTimesSubmitting = sponsorTimes;
updatePreviewBar();
}
}
});
@ -741,6 +755,8 @@ function clearSponsorTimes() {
//clear sponsor times submitting
sponsorTimesSubmitting = [];
updatePreviewBar();
//set buttons to be correct
changeStartSponsorButton(true, false);
}
@ -831,8 +847,8 @@ function submitSponsorTimes() {
let sponsorTimes = result[sponsorTimeKey];
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
let confirmMessage = "Are you sure you want to submit this?\n\n" + getSponsorTimesMessage(sponsorTimes);
confirmMessage += "\n\nTo edit or delete values, click the info button or open the extension popup by clicking the extension icon in the top right corner."
let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes);
confirmMessage += "\n\n" + chrome.i18n.getMessage("confirmMSG");
if(!confirm(confirmMessage)) return;
sendSubmitMessage();

View file

@ -1,7 +1,7 @@
{
"name": "__MSG_fullName__",
"short_name": "__MSG_Name__",
"version": "1.1.0",
"version": "1.1.2",
"default_locale": "en",
"description": "__MSG_Description__",
"content_scripts": [

View file

@ -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
@ -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;
}

View file

@ -13,6 +13,10 @@ let barTypes = {
"sponsor": {
color: "#00d400",
opacity: "0.5"
},
"previewSponsor": {
color: "#0000d4",
opacity: "0.5"
}
};

View file

@ -359,6 +359,9 @@ class SkipNotice {
if (notice != null) {
notice.remove();
}
//remove setInterval
if (this.countdownInterval != -1) clearInterval(this.countdownInterval);
}
}