Compare commits

..

24 Commits

Author SHA1 Message Date
Ajay Ramachandran
ae6d63c3ab Merge pull request #168 from ajayyy/experimental-ajay
Fixed notice never hiding
2019-11-07 13:05:22 -05:00
Ajay Ramachandran
a3214f0fa7 Fixed notice never hiding. 2019-11-07 13:04:31 -05:00
Ajay Ramachandran
44516648a1 Merge pull request #163 from ajayyy/experimental-ajay
Keybind edit, show notice again, ignore rate limits
2019-10-30 23:39:18 -04:00
Ajay Ramachandran
fbeabc830b Merge branch 'firefox-optimizations' of https://github.com/ajayyy/SponsorBlock into experimental-ajay 2019-10-30 23:38:56 -04:00
Ajay Ramachandran
f370746382 Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into experimental-ajay 2019-10-30 23:38:18 -04:00
Ajay Ramachandran
e82beb861a Merge pull request #153 from owendaprile/firefox-optimizations
Some Firefox Optimizations
2019-10-30 23:38:13 -04:00
Ajay Ramachandran
1791d31681 Revert "Moved browser specific settings into manifest"
This reverts commit 047432af03.
2019-10-30 23:37:36 -04:00
Ajay Ramachandran
784ddea34a Updated version number. 2019-10-30 23:33:10 -04:00
Ajay Ramachandran
69c93a0563 Removed deprecated show install page code 2019-10-30 23:32:32 -04:00
Ajay Ramachandran
4e4d50de82 Fixed feature to show the notice to users again. 2019-10-30 23:30:30 -04:00
Ajay Ramachandran
25b9edabf8 Changed hint to say that you can change the keybind. 2019-10-28 16:16:13 -04:00
Ajay Ramachandran
6851470547 Added the ability to change the keybind. 2019-10-28 16:13:37 -04:00
Ajay Ramachandran
73c1fc17b3 Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into experimental-ajay 2019-10-28 11:59:10 -04:00
Ajay Ramachandran
cba5b05c0c Merge pull request #160 from ptalmeida/master
Add european portuguese translation
2019-10-27 20:17:22 -04:00
Pedro Almeida
3f1573f1b3 Improve portuguese locales 2019-10-27 22:11:47 +01:00
Pedro Almeida
93ffc93943 Improve Brazilian Portuguese locale 2019-10-27 19:28:16 +01:00
Pedro Almeida
4214af4d56 Add support for European Portuguese 2019-10-27 19:27:22 +01:00
Owen D'Aprile
01405dd32e Ignore WebStorm project configuration folder 2019-10-15 17:49:01 -04:00
Owen D'Aprile
047432af03 Moved browser specific settings into manifest 2019-10-15 17:48:40 -04:00
Owen D'Aprile
a8bd5d0068 Suppress Firefox error when changing tabs 2019-10-15 17:46:42 -04:00
Ajay Ramachandran
eeb6d20e96 Fixed grammar 2019-10-13 12:09:14 -04:00
Ajay Ramachandran
8bb8511bf4 Fixed indenting. 2019-09-24 18:21:47 -04:00
Ajay Ramachandran
563610cbcd Made it show the new notice again. 2019-09-24 18:16:57 -04:00
Ajay Ramachandran
04190b27d8 Made it ignore rate limits for voting. 2019-09-24 17:55:07 -04:00
11 changed files with 527 additions and 55 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
config.js config.js
ignored ignored
.idea/

View File

@@ -32,7 +32,7 @@ The backend server code is available here: https://github.com/ajayyy/SponsorBloc
It is a simple Sqlite database that will hold all the timing data. It is a simple Sqlite database that will hold all the timing data.
To make sure that this project doesn't die, I have made the database publicly downloadable at https://sponsor.ajay.app/database.db. So, you can download a backup or get archive.org to take a backup if you do desire. To make sure that this project doesn't die, I have made the database publicly downloadable at https://sponsor.ajay.app/database.db. So, you can download a backup or get archive.org to take a backup for you if you want.
Hopefully this project can be combined with projects like [this](https://github.com/Sponsoff/sponsorship_remover) and use this data to create a neural network to predict when sponsored segments happen. That project is sadly abandoned now, so I have decided to attempt to revive this idea. Hopefully this project can be combined with projects like [this](https://github.com/Sponsoff/sponsorship_remover) and use this data to create a neural network to predict when sponsored segments happen. That project is sadly abandoned now, so I have decided to attempt to revive this idea.

View File

@@ -87,7 +87,6 @@
"Unknown": { "Unknown": {
"message": "There was an error submitting your sponsor times, please try again later." "message": "There was an error submitting your sponsor times, please try again later."
}, },
"sponsorFound": { "sponsorFound": {
"message": "This video's sponsors are in the database!" "message": "This video's sponsors are in the database!"
}, },
@@ -167,7 +166,7 @@
"message": "Click the button below when the sponsorship starts and ends to record and\nsubmit it to the database." "message": "Click the button below when the sponsorship starts and ends to record and\nsubmit it to the database."
}, },
"popupHint": { "popupHint": {
"message": "Hint: Press the semicolon key while focused on a video report the start/end of a sponsor and quote to submit." "message": "Hint: Press the semicolon key while focused on a video report the start/end of a sponsor and quote to submit. (This can be changed in the options)"
}, },
"lastTimes": { "lastTimes": {
"message": "Latest Sponsor Message Times Chosen" "message": "Latest Sponsor Message Times Chosen"
@@ -243,5 +242,25 @@
"sourceCode": { "sourceCode": {
"message": "Source Code", "message": "Source Code",
"description": "Used on Firefox Store Page" "description": "Used on Firefox Store Page"
},
"noticeUpdate": {
"message": "The notice has been upgraded!",
"description": "The first line of the message displayed after the notice was upgraded."
},
"noticeUpdate2": {
"message": "If you still don't like it, hit the never show button.",
"description": "The second line of the message displayed after the notice was upgraded."
},
"setStartSponsorShortcut": {
"message": "Set key for start sponsor keybind"
},
"setSubmitKeybind": {
"message": "Set key for submission keybind"
},
"keybindDescription": {
"message": "Select a key by typing it"
},
"keybindDescriptionComplete": {
"message": "The keybind has been set to: "
} }
} }

View File

@@ -28,7 +28,7 @@
"message": "Parece que o servidor caiu. Contate o desenvolvedor para informá-los." "message": "Parece que o servidor caiu. Contate o desenvolvedor para informá-los."
}, },
"channelWhitelisted": { "channelWhitelisted": {
"message": "Canal adicionado a lista branca!" "message": "Canal adicionado à lista branca!"
}, },
"Sponsor": { "Sponsor": {
"message": "patrocinador" "message": "patrocinador"
@@ -40,7 +40,7 @@
"message": "segmento de patrocinador" "message": "segmento de patrocinador"
}, },
"Segments": { "Segments": {
"message": "segmento de patrocinadores" "message": "segmentos de patrocinadores"
}, },
"noticeTitle": { "noticeTitle": {
"message": "Patrocinador pulado" "message": "Patrocinador pulado"
@@ -85,7 +85,7 @@
"message": "Tem certeza que quer limpar isso?\n\n" "message": "Tem certeza que quer limpar isso?\n\n"
}, },
"Unknown": { "Unknown": {
"message": "Teve um erro ao enviar seus segmentos, tente novamente depois" "message": "Teve um erro ao enviar seus segmentos, tente novamente depois."
}, },
"sponsorFound": { "sponsorFound": {
@@ -101,7 +101,7 @@
"message": "Patrocínio termina agora" "message": "Patrocínio termina agora"
}, },
"noVideoID": { "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." "message": "Isso provavelmente não é uma tab do YouTube, ou você clicou muito cedo. \n Se sabe que é uma tab do YouTube,\n feche esse popup e abra de novo."
}, },
"success": { "success": {
"message": "Sucesso!" "message": "Sucesso!"
@@ -122,6 +122,126 @@
"message": "Quer enviar os segmentos para o vídeo de ID" "message": "Quer enviar os segmentos para o vídeo de ID"
}, },
"leftTimes": { "leftTimes": {
"message": "Parece que você esqueceu de enviar alguns segmentos. Volta pra página para enviar eles (não foram deletados)." "message": "Parece que você se esqueceu de enviar alguns segmentos. Volta pra página para os enviar (não foram deletados)."
},
"clearTimes": {
"message": "Apagar intervalos dos patrocínios"
},
"openPopup": {
"message": "Abrir o Popup SponsorBlock"
},
"SubmitTimes": {
"message": "Submeter intervalos dos patrocínios"
},
"submitCheck": {
"message": "Tem a certeza que pretende submeter?"
},
"whitelistChannel": {
"message": "Meter canal na Whitelist"
},
"removeFromWhitelist": {
"message": "Remover canal da Whitelist"
},
"whitelistDescription": {
"message": "Colocar na Whitelist canais com patrocínios éticos que encoragem boas atitude, ou simplesmente canais com patrocínios engraçados. Ou não, é consigo."
},
"voteOnTime": {
"message": "Vote num intervalo de patrocínio"
},
"recordTimes": {
"message": "Registe um intervalo de patrocínio"
},
"soFarUHSubmited": {
"message": "Até agora submeteu"
},
"savedPeopleFrom": {
"message": "Poupaste a outros de "
},
"viewLeaderboard": {
"message": "Ver a leaderboard"
},
"here": {
"message": "aqui"
},
"recordTimesDescription": {
"message": "Carregue neste botão abaixo quando o patrocínio começar e quando\n acabar para registar e submetê-lo à base de dados"
},
"popupHint": {
"message": "Dica: Carregue na tecla ; enquanto num vídeo para registar o começo/fim de um patrocínio e \" para submeter"
},
"lastTimes": {
"message": "Intervalos de Patrocínios Escolhidos mais Recentemente"
},
"clearTimesButton": {
"message": "Limpar Intervalos"
},
"submitTimesButton": {
"message": "Submeter Intervalos"
},
"publicStats": {
"message": "Isto é usado na página pública de estatísticas que mostra o quanto já contríbuíu. Veje-a"
},
"setUsername": {
"message": "Criar nomde de utilizador"
},
"discordAdvert": {
"message": "Junte-se ao discord oficial para sugerir dicas e sugestões!"
},
"hideThis": {
"message": "Esconder isto"
},
"Options": {
"message": "Opções"
},
"showButtons": {
"message": "Esconder botões no player do Youtube"
},
"hideButtons": {
"message": "Mostrar botões no player do Youtube"
},
"hideButtonsDescription": {
"message": "Isto esconde os botões que aparecem no player do Youtube para submeter patrocínios. Entendemos que possa ser\n incómodo a algumas pessoas. Em vez de usar esses botões pode usar os do popup. Para esconder a mensagem que aparece, \n ususe o botão na mesma que diz \"Don't show this again\". Pode sempre reactivar estas definições novamente."
},
"showInfoButton": {
"message": "Mostrar botão de Informações no player do Youtube"
},
"hideInfoButton": {
"message": "Esconder botão de Informações no player do Youtube"
},
"whatInfoButton": {
"message": "Este é o botão que abre o popup na pagina do Youtube."
},
"hideDeleteButton": {
"message": "Esconder botão de Apagar no player do Youtube"
},
"showDeleteButton": {
"message": "Mostrar botão de Apagar no player do Youtube"
},
"whatDeleteButton": {
"message": "Este é o botão que lhe permite saltar todos os patrocínios do player do Youtube."
},
"disableViewTracking": {
"message": "Desactivar registo de visualização de patrocínios"
},
"enableViewTracking": {
"message": "Activar registo de visualização de patrocínios"
},
"whatViewTracking": {
"message": "Esta funcionalidade regista que patrocínios tem saltado para que outros utilizadores saibam o quanto as suas submições têm ajudado outros\n e é usado como métrica de votos para evitar spam na base de dados. A extenção \n envia uma notificação ao servidor sempre que salta um patrocínio. Quanto menos pessoas desactivarem esta funcionalidade mais precisas serão as estimativas :)"
},
"showNotice": {
"message": "Mostrar notificação outra vez"
},
"longDescription": {
"message": "SponsorBlock é uma extensão que salta segmentos patrocinados em vídeos do YouTube. SponsorBlock é uma extenção crowdfunded que permite a qualquer um submeter o início e o fim de segmentos patrocinados. Assim que uma pessoa submete essa informação todos com a extenção poderam saltar automaticamete o patrocínio.",
"description": "Descrição completa da extençao nas lojas dos browsers."
},
"website": {
"message": "Site",
"description": "Usado na pagina da loja do Firefox"
},
"sourceCode": {
"message": "Código fonte",
"description": "Usado na pagina da loja do Firefox"
} }
} }

View File

@@ -0,0 +1,246 @@
{
"Name": {
"message": "SponsorBlock",
"description": "Nome da extensão."
},
"fullName": {
"message": "SponsorBlock para o YouTube - Salte patrocínios",
"description": "Nome da extensão."
},
"Description": {
"message": "Salte patrocinadores em vídeos do YouTube. Reporte patrocinadores em vídeos que assista para poupar tempo a outros.",
"description": "Descrição da extensão."
},
"helpPage": {
"message": "index_en.html"
},
"400": {
"message": "O servidor disse que este pedido foi inválido"
},
"429": {
"message": "Enviou muitos segmentos para este vídeo, tem certeza que tem assim tantos?"
},
"409": {
"message": "Isso já foi enviado antes"
},
"502": {
"message": "Parece que o servidor caiu. Contacte o desenvolvedor para o informar."
},
"channelWhitelisted": {
"message": "Canal adicionado à whitelist!"
},
"Sponsor": {
"message": "patrocinador"
},
"Sponsors": {
"message": "patrocinadores"
},
"Segment": {
"message": "segmento de patrocínio"
},
"Segments": {
"message": "segmentos de patrocínio"
},
"noticeTitle": {
"message": "Patrocínio saltado"
},
"reportButtonTitle": {
"message": "Reportar"
},
"reportButtonInfo": {
"message": "Reportar subimissão como inválida."
},
"Dismiss": {
"message": "Ignorar"
},
"Loading": {
"message": "A carregar..."
},
"Mins": {
"message": "Minutos"
},
"Secs": {
"message": "Segundos"
},
"Hide": {
"message": "Nunca mostrar"
},
"hitGoBack": {
"message": "Carregue em reverter salto para voltar a onde estava"
},
"unskip": {
"message": "Reverter salto"
},
"reskip": {
"message": "Saltar novamente"
},
"paused": {
"message": "Pausado"
},
"confirmMSG": {
"message": "\n\nPara editar ou remover linhas individuais, carregue com o botão direito ou abra o popup da extensão pelo icone no canto superior direito."
},
"clearThis": {
"message": "Tem certeza que deseja limpar isto?\n\n"
},
"Unknown": {
"message": "Erro ao enviar os seus segmentos, tente novamente mais tarde."
},
"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": "Isto provavelmente não é uma tab do YouTube, ou pode ter clicado muito cedo. \n Se sabe que é uma tab do YouTube,\n feche este popup e abra de novo."
},
"success": {
"message": "Sucesso!"
},
"voted": {
"message": "Votado!"
},
"voteFail": {
"message": "Já votou antes."
},
"serverDown": {
"message": "Parece que o servidor caiu. Contacte o desenvolvedor o quanto antes."
},
"connectionError": {
"message": "Deu-se um erro de conecção: Código: "
},
"wantToSubmit": {
"message": "Quer enviar os segmentos para o vídeo de ID"
},
"leftTimes": {
"message": "Parece que se esqueceu de enviar alguns segmentos. Retorne à página para os enviar (não foram apagados)."
},
"clearTimes": {
"message": "Apagar intervalos dos patrocínios"
},
"openPopup": {
"message": "Abrir o Popup SponsorBlock"
},
"SubmitTimes": {
"message": "Submeter intervalos dos patrocínios"
},
"submitCheck": {
"message": "Tem a certeza que pretende submeter?"
},
"whitelistChannel": {
"message": "Meter canal na Whitelist"
},
"removeFromWhitelist": {
"message": "Remover canal da Whitelist"
},
"whitelistDescription": {
"message": "Colocar na Whitelist canais com patrocínios éticos que encoragem boas atitude, ou simplesmente canais com patrocínios engraçados. Ou não, é consigo."
},
"voteOnTime": {
"message": "Vote num intervalo de patrocínio"
},
"recordTimes": {
"message": "Registe um intervalo de patrocínio"
},
"soFarUHSubmited": {
"message": "Até agora submeteu"
},
"savedPeopleFrom": {
"message": "Poupaste a outros de "
},
"viewLeaderboard": {
"message": "Ver a leaderboard"
},
"here": {
"message": "aqui"
},
"recordTimesDescription": {
"message": "Carregue neste botão abaixo quando o patrocínio começar e quando\n acabar para registar e submetê-lo à base de dados"
},
"popupHint": {
"message": "Dica: Carregue na tecla ; enquanto num vídeo para registar o começo/fim de um patrocínio e \" para submeter"
},
"lastTimes": {
"message": "Intervalos de Patrocínios Escolhidos mais Recentemente"
},
"clearTimesButton": {
"message": "Limpar Intervalos"
},
"submitTimesButton": {
"message": "Submeter Intervalos"
},
"publicStats": {
"message": "Isto é usado na página pública de estatísticas que mostra o quanto já contríbuíu. Veje-a"
},
"setUsername": {
"message": "Criar nomde de utilizador"
},
"discordAdvert": {
"message": "Junte-se ao discord oficial para sugerir dicas e sugestões!"
},
"hideThis": {
"message": "Esconder isto"
},
"Options": {
"message": "Opções"
},
"showButtons": {
"message": "Esconder botões no player do Youtube"
},
"hideButtons": {
"message": "Mostrar botões no player do Youtube"
},
"hideButtonsDescription": {
"message": "Isto esconde os botões que aparecem no player do Youtube para submeter patrocínios. Entendemos que possa ser\n incómodo a algumas pessoas. Em vez de usar esses botões pode usar os do popup. Para esconder a mensagem que aparece, \n ususe o botão na mesma que diz \"Don't show this again\". Pode sempre reactivar estas definições novamente."
},
"showInfoButton": {
"message": "Mostrar botão de Informações no player do Youtube"
},
"hideInfoButton": {
"message": "Esconder botão de Informações no player do Youtube"
},
"whatInfoButton": {
"message": "Este é o botão que abre o popup na pagina do Youtube."
},
"hideDeleteButton": {
"message": "Esconder botão de Apagar no player do Youtube"
},
"showDeleteButton": {
"message": "Mostrar botão de Apagar no player do Youtube"
},
"whatDeleteButton": {
"message": "Este é o botão que lhe permite saltar todos os patrocínios do player do Youtube."
},
"disableViewTracking": {
"message": "Desactivar registo de visualização de patrocínios"
},
"enableViewTracking": {
"message": "Activar registo de visualização de patrocínios"
},
"whatViewTracking": {
"message": "Esta funcionalidade regista que patrocínios tem saltado para que outros utilizadores saibam o quanto as suas submições têm ajudado outros\n e é usado como métrica de votos para evitar spam na base de dados. A extenção \n envia uma notificação ao servidor sempre que salta um patrocínio. Quanto menos pessoas desactivarem esta funcionalidade mais precisas serão as estimativas :)"
},
"showNotice": {
"message": "Mostrar notificação outra vez"
},
"longDescription": {
"message": "SponsorBlock é uma extensão que salta segmentos patrocinados em vídeos do YouTube. SponsorBlock é uma extenção crowdfunded que permite a qualquer um submeter o início e o fim de segmentos patrocinados. Assim que uma pessoa submete essa informação todos com a extenção poderam saltar automaticamete o patrocínio.",
"description": "Descrição completa da extençao nas lojas dos browsers."
},
"website": {
"message": "Site",
"description": "Usado na pagina da loja do Firefox"
},
"sourceCode": {
"message": "Código fonte",
"description": "Usado na pagina da loja do Firefox"
}
}

View File

@@ -1,7 +1,7 @@
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { chrome.tabs.onUpdated.addListener(function(tabId) {
chrome.tabs.sendMessage(tabId, { chrome.tabs.sendMessage(tabId, {
message: 'update', message: 'update',
}); }, () => void chrome.runtime.lastError ); // Suppress error on Firefox
}); });
chrome.runtime.onMessage.addListener(function (request, sender, callback) { chrome.runtime.onMessage.addListener(function (request, sender, callback) {
@@ -42,28 +42,13 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
//add help page on install //add help page on install
chrome.runtime.onInstalled.addListener(function (object) { chrome.runtime.onInstalled.addListener(function (object) {
// TODO (shownInstallPage): remove shownInstallPage logic after sufficient amount of time,
// so that people have time to upgrade and move to shownInstallPage-free code.
chrome.storage.sync.get(["userID", "shownInstallPage"], function(result) { chrome.storage.sync.get(["userID", "shownInstallPage"], function(result) {
const userID = result.userID; const userID = result.userID;
// TODO (shownInstallPage): delete row below
const shownInstallPage = result.shownInstallPage;
// If there is no userID, then it is the first install. // If there is no userID, then it is the first install.
if (!userID){ if (!userID){
// Show install page, if there is no user id //open up the install page
// and there is no shownInstallPage. chrome.tabs.create({url: chrome.extension.getURL("/help/"+chrome.i18n.getMessage("helpPage"))});
// 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"))});
}
// TODO (shownInstallPage): delete if statement and contents
// If shownInstallPage is set, remove it.
if (!!shownInstallPage){
chrome.storage.sync.remove("shownInstallPage");
}
//generate a userID //generate a userID
const newUserID = generateUserID(); const newUserID = generateUserID();

View File

@@ -80,11 +80,20 @@ chrome.storage.sync.get(["trackViewCount"], function(result) {
//if the notice should not be shown //if the notice should not be shown
//happens when the user click's the "Don't show notice again" button //happens when the user click's the "Don't show notice again" button
//option renamed when new notice was made
var dontShowNotice = false; var dontShowNotice = false;
chrome.storage.sync.get(["dontShowNotice"], function(result) {
let dontShowNoticeAgain = result.dontShowNotice;
if (dontShowNoticeAgain != undefined) {
dontShowNotice = dontShowNoticeAgain;
}
});
//load the legacy option to hide the notice
var dontShowNoticeOld = false;
chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) {
let dontShowNoticeAgain = result.dontShowNoticeAgain; let dontShowNoticeAgain = result.dontShowNoticeAgain;
if (dontShowNoticeAgain != undefined) { if (dontShowNoticeAgain != undefined) {
dontShowNotice = dontShowNoticeAgain; dontShowNoticeOld = dontShowNoticeAgain;
} }
}); });
@@ -195,18 +204,32 @@ function messageListener(request, sender, sendResponse) {
} }
//check for hotkey pressed //check for hotkey pressed
document.onkeydown = function(e){ document.onkeydown = async function(e){
e = e || window.event; e = e || window.event;
var key = e.key; var key = e.key;
let video = document.getElementById("movie_player"); let video = document.getElementById("movie_player");
let startSponsorKey = await new Promise((resolve, reject) => {
chrome.storage.sync.get(["startSponsorKeybind"], (result) => resolve(result));
});
let submitKey = await new Promise((resolve, reject) => {
chrome.storage.sync.get(["submitKeybind"], (result) => resolve(result));
});
if (startSponsorKey.startSponsorKeybind === undefined) {
startSponsorKey.startSponsorKeybind = ";"
}
if (submitKey.submitKeybind === undefined) {
submitKey.submitKeybind = "'"
}
//is the video in focus, otherwise they could be typing a comment //is the video in focus, otherwise they could be typing a comment
if (document.activeElement === video) { if (document.activeElement === video) {
if(key == ';'){ if(key == startSponsorKey.startSponsorKeybind){
//semicolon //semicolon
startSponsorClicked(); startSponsorClicked();
} else if (key == "'") { } else if (key == submitKey.submitKeybind) {
//single quote //single quote
submitSponsorTimes(); submitSponsorTimes();
} }
@@ -591,7 +614,16 @@ 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
if (!dontShowNotice) { if (!dontShowNotice) {
new SkipNotice(this, currentUUID); let skipNotice = new SkipNotice(this, currentUUID);
if (dontShowNoticeOld) {
//show why this notice is showing
skipNotice.addNoticeInfoMessage(chrome.i18n.getMessage("noticeUpdate"), chrome.i18n.getMessage("noticeUpdate2"));
//remove this setting
chrome.storage.sync.remove(["dontShowNoticeAgain"]);
dontShowNoticeOld = false;
}
//auto-upvote this sponsor //auto-upvote this sponsor
if (trackViewCount) { if (trackViewCount) {
@@ -879,8 +911,8 @@ function vote(type, UUID, skipNotice) {
if (response != undefined) { if (response != undefined) {
//see if it was a success or failure //see if it was a success or failure
if (skipNotice != null) { if (skipNotice != null) {
if (response.successType == 1) { if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) {
//success //success (treat rate limits as a success)
if (type == 0) { if (type == 0) {
skipNotice.afterDownvote.bind(skipNotice)(); skipNotice.afterDownvote.bind(skipNotice)();
} }
@@ -912,7 +944,7 @@ function closeAllSkipNotices(){
} }
function dontShowNoticeAgain() { function dontShowNoticeAgain() {
chrome.storage.sync.set({"dontShowNoticeAgain": true}); chrome.storage.sync.set({"dontShowNotice": true});
dontShowNotice = true; dontShowNotice = true;
@@ -920,15 +952,15 @@ function dontShowNoticeAgain() {
} }
function sponsorMessageStarted(callback) { function sponsorMessageStarted(callback) {
v = document.querySelector('video'); v = document.querySelector('video');
//send back current time //send back current time
callback({ callback({
time: v.currentTime time: v.currentTime
}) })
//update button //update button
toggleStartSponsorButton(); toggleStartSponsorButton();
} }
function submitSponsorTimes() { function submitSponsorTimes() {

View File

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

View File

@@ -172,6 +172,19 @@
<br/> <br/>
<h3>__MSG_Options__</h3> <h3>__MSG_Options__</h3>
<span id="keybindButtons">
<button id="setStartSponsorKeybind" class="warningButton popupElement">__MSG_setStartSponsorShortcut__</button>
<br/>
<br/>
<button id="setSubmitKeybind" class="warningButton popupElement">__MSG_setSubmitKeybind__</button>
<br/>
</span>
<h2 id="keybindDescription" style="display: none" class="popupElement">__MSG_keybindDescription__</h2>
<br/>
<br/>
<button id="hideVideoPlayerControls" class="warningButton popupElement">__MSG_hideButtons__</button> <button id="hideVideoPlayerControls" class="warningButton popupElement">__MSG_hideButtons__</button>
<button id="showVideoPlayerControls" style="display: none" class="warningButton popupElement">__MSG_showButtons__</button> <button id="showVideoPlayerControls" style="display: none" class="warningButton popupElement">__MSG_showButtons__</button>

View File

@@ -70,6 +70,10 @@ function runThePopup() {
"videoFound", "videoFound",
"sponsorMessageTimes", "sponsorMessageTimes",
"downloadedSponsorMessageTimes", "downloadedSponsorMessageTimes",
// Keybinds
"setStartSponsorKeybind",
"setSubmitKeybind",
"keybindDescription"
].forEach(id => SB[id] = document.getElementById(id)); ].forEach(id => SB[id] = document.getElementById(id));
//setup click listeners //setup click listeners
@@ -79,6 +83,8 @@ function runThePopup() {
SB.clearTimes.addEventListener("click", clearTimes); SB.clearTimes.addEventListener("click", clearTimes);
SB.submitTimes.addEventListener("click", submitTimes); SB.submitTimes.addEventListener("click", submitTimes);
SB.showNoticeAgain.addEventListener("click", showNoticeAgain); SB.showNoticeAgain.addEventListener("click", showNoticeAgain);
SB.setStartSponsorKeybind.addEventListener("click", () => setKeybind(true));
SB.setSubmitKeybind.addEventListener("click", () => setKeybind(false));
SB.hideVideoPlayerControls.addEventListener("click", hideVideoPlayerControls); SB.hideVideoPlayerControls.addEventListener("click", hideVideoPlayerControls);
SB.showVideoPlayerControls.addEventListener("click", showVideoPlayerControls); SB.showVideoPlayerControls.addEventListener("click", showVideoPlayerControls);
SB.hideInfoButtonPlayerControls.addEventListener("click", hideInfoButtonPlayerControls); SB.hideInfoButtonPlayerControls.addEventListener("click", hideInfoButtonPlayerControls);
@@ -104,6 +110,9 @@ function runThePopup() {
//is this a YouTube tab? //is this a YouTube tab?
let isYouTubeTab = false; let isYouTubeTab = false;
// Is the start sponsor keybind currently being set
let setStartSponsorKeybind = false;
//see if discord link can be shown //see if discord link can be shown
chrome.storage.sync.get(["hideDiscordLink"], function(result) { chrome.storage.sync.get(["hideDiscordLink"], function(result) {
@@ -127,9 +136,9 @@ function runThePopup() {
//if the don't show notice again letiable is true, an option to //if the don't show notice again letiable is true, an option to
// disable should be available // disable should be available
chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { chrome.storage.sync.get(["dontShowNotice"], function(result) {
let dontShowNoticeAgain = result.dontShowNoticeAgain; let dontShowNotice = result.dontShowNotice;
if (dontShowNoticeAgain != undefined && dontShowNoticeAgain) { if (dontShowNotice != undefined && dontShowNotice) {
SB.showNoticeAgain.style.display = "unset"; SB.showNoticeAgain.style.display = "unset";
} }
}); });
@@ -819,7 +828,7 @@ function runThePopup() {
} }
function showNoticeAgain() { function showNoticeAgain() {
chrome.storage.sync.set({"dontShowNoticeAgain": false}); chrome.storage.sync.set({"dontShowNotice": false});
chrome.tabs.query({ chrome.tabs.query({
active: true, active: true,
@@ -1102,8 +1111,8 @@ function runThePopup() {
}, 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 (response.successType == 1) { if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) {
//success //success (treat rate limits as a 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
@@ -1236,7 +1245,35 @@ function runThePopup() {
); );
}); });
} }
function setKeybind(startSponsorKeybind) {
document.getElementById("keybindButtons").style.display = "none";
document.getElementById("keybindDescription").style.display = "initial";
document.getElementById("keybindDescription").innerText = chrome.i18n.getMessage("keybindDescription");
setStartSponsorKeybind = startSponsorKeybind;
document.addEventListener("keydown", onKeybindSet)
}
function onKeybindSet(e) {
e = e || window.event;
var key = e.key;
if (setStartSponsorKeybind) {
chrome.storage.sync.set({"startSponsorKeybind": key});
} else {
chrome.storage.sync.set({"submitKeybind": key});
}
document.removeEventListener("keydown", onKeybindSet);
document.getElementById("keybindDescription").innerText = chrome.i18n.getMessage("keybindDescriptionComplete") + " " + key;
document.getElementById("keybindButtons").style.display = "unset";
}
//converts time in seconds to minutes //converts time in seconds to minutes
function getTimeInMinutes(seconds) { function getTimeInMinutes(seconds) {
let minutes = Math.floor(seconds / 60); let minutes = Math.floor(seconds / 60);

View File

@@ -294,21 +294,37 @@ class SkipNotice {
} }
} }
addNoticeInfoMessage(message) { addNoticeInfoMessage(message, message2) {
let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + this.idSuffix); let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + this.idSuffix);
if (previousInfoMessage != null) { if (previousInfoMessage != null) {
//remove it //remove it
document.getElementById("sponsorSkipNotice" + this.idSuffix).removeChild(previousInfoMessage); document.getElementById("sponsorSkipNotice" + this.idSuffix).removeChild(previousInfoMessage);
} }
let previousInfoMessage2 = document.getElementById("sponsorTimesInfoMessage" + this.idSuffix + "2");
if (previousInfoMessage2 != null) {
//remove it
document.getElementById("sponsorSkipNotice" + this.idSuffix).removeChild(previousInfoMessage2);
}
//add info //add info
let thanksForVotingText = document.createElement("p"); let thanksForVotingText = document.createElement("p");
thanksForVotingText.id = "sponsorTimesInfoMessage" + this.idSuffix; thanksForVotingText.id = "sponsorTimesInfoMessage" + this.idSuffix;
thanksForVotingText.className = "sponsorTimesInfoMessage"; thanksForVotingText.className = "sponsorTimesInfoMessage";
thanksForVotingText.innerText = message; thanksForVotingText.innerText = message;
//add element to div //add element to div
document.getElementById("sponsorSkipNotice" + this.idSuffix).insertBefore(thanksForVotingText, document.getElementById("sponsorSkipNoticeSpacer" + this.idSuffix)); document.getElementById("sponsorSkipNotice" + this.idSuffix).insertBefore(thanksForVotingText, document.getElementById("sponsorSkipNoticeSpacer" + this.idSuffix));
if (message2 !== undefined) {
let thanksForVotingText2 = document.createElement("p");
thanksForVotingText2.id = "sponsorTimesInfoMessage" + this.idSuffix + "2";
thanksForVotingText2.className = "sponsorTimesInfoMessage";
thanksForVotingText2.innerText = message2;
//add element to div
document.getElementById("sponsorSkipNotice" + this.idSuffix).insertBefore(thanksForVotingText2, document.getElementById("sponsorSkipNoticeSpacer" + this.idSuffix));
}
} }
resetNoticeInfoMessage() { resetNoticeInfoMessage() {
@@ -337,7 +353,7 @@ class SkipNotice {
thanksForVotingText.id = "sponsorTimesVoteButtonInfoMessage" + this.idSuffix; thanksForVotingText.id = "sponsorTimesVoteButtonInfoMessage" + this.idSuffix;
thanksForVotingText.className = "sponsorTimesInfoMessage sponsorTimesVoteButtonMessage"; thanksForVotingText.className = "sponsorTimesInfoMessage sponsorTimesVoteButtonMessage";
thanksForVotingText.innerText = message; thanksForVotingText.innerText = message;
//add element to div //add element to div
document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).prepend(thanksForVotingText); document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).prepend(thanksForVotingText);
} }
@@ -348,13 +364,16 @@ class SkipNotice {
//remove it //remove it
document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).removeChild(previousInfoMessage); document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).removeChild(previousInfoMessage);
} }
//show button again //show button again
document.getElementById("sponsorTimesDownvoteButtonsContainer" + this.idSuffix).style.removeProperty("display"); document.getElementById("sponsorTimesDownvoteButtonsContainer" + this.idSuffix).style.removeProperty("display");
} }
//close this notice //close this notice
close() { close() {
//reset message
this.resetNoticeInfoMessage();
let notice = document.getElementById("sponsorSkipNotice" + this.idSuffix); let notice = document.getElementById("sponsorSkipNotice" + this.idSuffix);
if (notice != null) { if (notice != null) {
notice.remove(); notice.remove();