Compare commits

..

17 Commits

Author SHA1 Message Date
Ajay Ramachandran
3640463112 New Crowdin translations (#353)
* New translations messages.json (Portuguese, Brazilian)

* New translations messages.json (Portuguese, Brazilian)
2020-05-15 21:00:07 -04:00
Ajay Ramachandran
d872ed642d Merge pull request #351 from ajayyy/react
Category Improvements
2020-05-15 20:56:09 -04:00
Ajay Ramachandran
1ab1f33caf Change zip binary in release workflow 2020-05-15 20:51:24 -04:00
Ajay Ramachandran
ba13f5951e Increase version number 2020-05-15 19:40:24 -04:00
Ajay Ramachandran
f66e8ddf92 Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into react 2020-05-15 19:40:12 -04:00
Ajay Ramachandran
cff72b19c7 Enable category vote on main server 2020-05-15 19:39:37 -04:00
Ajay Ramachandran
941bd41cdb Added another check to prevent phantom skips 2020-05-13 21:11:00 -04:00
Ajay Ramachandran
a72f571bd4 Update manifest.json 2020-05-12 22:03:38 -04:00
Ajay Ramachandran
50c9c9fe8a Merge pull request #349 from ajayyy/react
Hotfixes for 1.2.28.1
2020-05-12 21:56:14 -04:00
Ajay Ramachandran
7f8badb34d New Crowdin translations (#348)
* New translations messages.json (Chinese Simplified)

* New translations messages.json (Chinese Simplified)
2020-05-12 21:55:43 -04:00
Ajay Ramachandran
f9d8daeca0 Upgraded web-ext 2020-05-12 21:18:07 -04:00
Ajay Ramachandran
55070d5852 Fixed mutation listener stack overflow on Firefox. 2020-05-12 21:17:52 -04:00
Ajay Ramachandran
789bd5939b Fixed zipping command in release workflow 2020-05-11 21:13:19 -04:00
Ajay Ramachandran
b591fbfc4b Removed log 2020-05-11 21:04:28 -04:00
Ajay Ramachandran
57eb122fce Changed rough time calculation to only use real time or end time.
Also fixed getting the replay button element.
2020-05-11 21:04:10 -04:00
Ajay Ramachandran
aec287f0cf Fixed preview bar hover text error 2020-05-11 20:59:30 -04:00
Ajay Ramachandran
c68aabaa40 Added null coalescence checks to video info 2020-05-11 20:45:48 -04:00
12 changed files with 2052 additions and 1599 deletions

View File

@@ -17,6 +17,9 @@ jobs:
- run: npm install
- name: Copy configuration
run: cp config.json.example config.json
- name: Install Zip
run: sudo apt-get install zip
# Create Chrome artifacts
- name: Create Chrome artifacts
@@ -26,9 +29,10 @@ jobs:
name: ChromeExtension
path: dist
- run: mkdir ./builds
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./builds/ChromeExtension.zip ./dist/*
- name: Zip Artifacts
run: cd ./dist
- run: zip -r ../builds/ChromeExtension.zip *
- run: cd ../
# Create Firefox artifacts
- name: Create Firefox artifacts
@@ -37,9 +41,12 @@ jobs:
with:
name: FirefoxExtension
path: dist
- name: Zip Artifacts
run: cd ./dist
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./builds/FirefoxExtension.zip ./dist/*
args: zip -r ../builds/FirefoxExtension.zip *
- run: cd ../
# Create Beta artifacts (Builds with the name changed to beta)
- name: Create Chrome Beta artifacts
@@ -48,9 +55,10 @@ jobs:
with:
name: ChromeExtensionBeta
path: dist
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./builds/ChromeExtensionBeta.zip ./dist/*
- name: Zip Artifacts
run: cd ./dist
- run: zip -r ../builds/ChromeExtensionBeta.zip *
- run: cd ../
- name: Create Firefox Beta artifacts
run: npm run build:firefox -- --env.stream=beta
@@ -58,9 +66,10 @@ jobs:
with:
name: FirefoxExtensionBeta
path: dist
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./builds/FirefoxExtensionBeta.zip ./dist/*
- name: Zip Artifacts
run: cd ./dist
- run: zip -r ../builds/FirefoxExtensionBeta.zip *
- run: cd ../
# Create Firefox Signed Beta version
- name: Create Firefox Signed Beta artifacts

View File

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

3171
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,7 +15,7 @@
"react-dom": "^16.12.0"
},
"devDependencies": {
"web-ext": "^4.0.0",
"web-ext": "^4.2.0",
"@types/chrome": "0.0.91",
"@types/firefox-webext-browser": "70.0.1",
"@types/jest": "^24.0.23",

View File

@@ -1,4 +1,8 @@
{
"Name": {
"message": "SponsorBlock",
"description": "Name of the extension."
},
"fullName": {
"message": "SponsorBlock para YouTube - Pule patrocínios",
"description": "Name of the extension."
@@ -149,22 +153,22 @@
"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"
"message": "Clique no botão abaixo quando o patrocínio começar e quando terminar para registrar 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"
"message": "Dica: Aperte a tecla ; enquanto reproduzir o vídeo para registar o começo/fim de um patrocínio e \" para enviar. (Essa configuração pode ser mudada em opções.)"
},
"lastTimes": {
"message": "Intervalos de Patrocínios Escolhidos mais Recentemente"
"message": "Últimos Intervalos de Patrocínios Seleciados"
},
"clearTimesButton": {
"message": "Limpar Intervalos"
},
"submitTimesButton": {
"message": "Submeter Intervalos"
"message": "Enviar Intervalos"
},
"publicStats": {
"message": "Isto é usado na página pública de estatísticas que mostra o quanto já contríbuíu. Veje-a"
"message": "Isso é usado na página pública de estatísticas que mostra o quanto você já contríbuíu. Veja-a"
},
"setUsername": {
"message": "Criar nomde de utilizador"
@@ -228,5 +232,339 @@
"sourceCode": {
"message": "Código fonte",
"description": "Used on Firefox Store Page"
},
"noticeUpdate": {
"message": "A notificação foi atualizada!",
"description": "The first line of the message displayed after the notice was upgraded."
},
"noticeUpdate2": {
"message": "Se você ainda não gostar dessa, aperte o botão não mostrar novamente.",
"description": "The second line of the message displayed after the notice was upgraded."
},
"setStartSponsorShortcut": {
"message": "Defina a tecla para que marca o início do patrocínio"
},
"setSubmitKeybind": {
"message": "Defina a tecla para enviar o segmento de patrocínio"
},
"keybindDescription": {
"message": "Selecione uma tecla apertando-a"
},
"keybindDescriptionComplete": {
"message": "A tecla foi definida para: "
},
"0": {
"message": "Tempo limite de conexão excedida. Cheque a sua conexão de internet. Se a sua internet estiver funcionando, o servidor está sobrecarregado ou fora do ar."
},
"disableSkipping": {
"message": "Desativar SponsorBlock"
},
"enableSkipping": {
"message": "Ativar SponsorBlock"
},
"yourWork": {
"message": "Suas submissões",
"description": "Used to describe the section that will show you the statistics from your submissions."
},
"502": {
"message": "O servidor parece estar sobrecarregado. Tente novamente em alguns segundos."
},
"errorCode": {
"message": "Código de erro: "
},
"noticeTitleNotSkipped": {
"message": "Pular patrocinador?"
},
"skip": {
"message": "Pular"
},
"disableAutoSkip": {
"message": "Desativar Salto Automático"
},
"enableAutoSkip": {
"message": "Ativar Salto Automático"
},
"autoSkipDescription": {
"message": "Pular automaticamente irá pular patrocínios por você. Se desabilitado, um aviso irá aparecer perguntando se deseja pular o anúncio."
},
"audioNotification": {
"message": "Notificação de áudio ao pular"
},
"audioNotificationDescription": {
"message": "A notificação de áudio ao pular irá tocar um som sempre que um patrocínio for ignorado. Se desativado (ou o pulo automático estiver desativado), nenhum som será reproduzido."
},
"youHaveSkipped": {
"message": "Você pulou "
},
"youHaveSaved": {
"message": "Você poupou "
},
"minLower": {
"message": "minuto"
},
"minsLower": {
"message": "minutos"
},
"hourLower": {
"message": "hora"
},
"hoursLower": {
"message": "horas"
},
"youHaveSavedTime": {
"message": "Você poupou outros"
},
"youHaveSavedTimeEnd": {
"message": " de suas vidas."
},
"guildlinesSummary": {
"message": "- Certifique-se de que seu segmento contém apenas patrocínio, nada mais.\n- Certifique-se de que pular esse segmento não vai pular conteúdo importante.\n- Se todo o vídeo for patrocinado, por favor não o denuncie. Um sistema completo de relatório de vídeo virá em breve.\n- Por favor, não denuncie avisos de parcialidade do vídeo (se um vídeo de avaliação for patrocinado, não pule quando eles mencionarem que é patrocinado)."
},
"statusReminder": {
"message": "Verifique status.sponsor.ajay.app para o status do servidor."
},
"changeUserID": {
"message": "Importar/Exportar seu ID de usuário"
},
"whatChangeUserID": {
"message": "Isso deve ser mantido em segredo. É como se fosse uma senha e não deve ser compartilhado com ninguém. Se alguém tiver isso, poderá se passar por você."
},
"setUserID": {
"message": "Definir ID de usuário"
},
"userIDChangeWarning": {
"message": "Atenção: A alteração do ID de usuário é permanente. Você tem certeza que deseja fazer isso? Certifique-se de fazer backup de seu ID antigo por precaução."
},
"createdBy": {
"message": "Criado por"
},
"autoSkip": {
"message": "Pular automaticamente"
},
"showSkipNotice": {
"message": "Mostrar aviso após um patrocínio ser ignorado"
},
"keybindCurrentlySet": {
"message": ". Atualmente, está definido para:"
},
"supportInvidious": {
"message": "Apoiar Invidious"
},
"supportInvidiousDescription": {
"message": "Invidious (invidio.us) é um cliente para YouTube de terceiros. Para ativar o apoio, você precisa aceitar as permissões adicionais. Isso não funciona em modo anônimo no Chrome ou em outras variantes do Chromium."
},
"optionsInfo": {
"message": "Ativar apoio ao Invidious, desabilitar pular automaticamente, ocultar botões e mais."
},
"addInvidiousInstance": {
"message": "Adicionar instância do Invidious"
},
"addInvidiousInstanceDescription": {
"message": "Adicionar uma instância personalizada do Invidious. Deve ser formatado com APENAS o domínio. Exemplo: invidious.ajay.app"
},
"add": {
"message": "Adicionar"
},
"addInvidiousInstanceError": {
"message": "Este é um domínio inválido. Ele deve incluir APENAS a parte do domínio. Exemplo: invidious.ajay.app"
},
"resetInvidiousInstance": {
"message": "Redefinir Lista de Instâncias do Invidious"
},
"resetInvidiousInstanceAlert": {
"message": "Você está prestes a redefinir a lista de instâncias do Invidious"
},
"currentInstances": {
"message": "Instâncias Atuais:"
},
"enableAutoUpvote": {
"message": "Upvote automático"
},
"whatAutoUpvote": {
"message": "Com isto habilitado, a extensão dará upvote em todas as submissões que você ver se você não reportar. Não funcionará se o aviso estiver desativado."
},
"minDuration": {
"message": "Duração mínima (segundos):"
},
"minDurationDescription": {
"message": "Segmentos de patrocinadores menores do que o valor definido não serão pulados ou mostrados no reprodutor."
},
"shortCheck": {
"message": "A seguinte submissão é mais curta do que sua opção de duração mínima. Isto significa que já foi enviada e que está sendo ignorada devido a esta opção. Tem certeza que deseja enviar mesmo assim?"
},
"showUploadButton": {
"message": "Mostrar botão de envio"
},
"whatUploadButton": {
"message": "Este botão aparece no reprodutor do YouTube depois de ter selecionado um carimbo de data/hora e está pronto para ser enviado."
},
"customServerAddress": {
"message": "Endereço do servidor do SponsorBlock"
},
"customServerAddressDescription": {
"message": "Endereço que o SponsorBlock usa para fazer chamadas ao servidor.\nA menos que você tenha sua própria instância de servidor, isso não deve ser alterado."
},
"save": {
"message": "Salvar"
},
"reset": {
"message": "Redefinir"
},
"customAddressError": {
"message": "Este endereço não está na forma correta. Certifique-se de que possui http:// ou https:// no início e sem barras no final."
},
"areYouSureReset": {
"message": "Tem certeza que deseja redefinir?"
},
"confirmPrivacy": {
"message": "O este vídeo está marcado como não listado. Clique em cancelar se você não deseja verificar se há patrocínios."
},
"unlistedCheck": {
"message": "Ignorar vídeos não listados/privados"
},
"whatUnlistedCheck": {
"message": "Esta configuração irá diminuir um pouco o desempenho do SponsorBlock. As pesquisas do patrocinador exigem que se envie o ID do vídeo para o servidor. Se você estiver preocupado com o envio de IDs de vídeo não listados pela internet, habilite essa opção."
},
"mobileUpdateInfo": {
"message": "m.youtube.com agora é suportado"
},
"exportOptions": {
"message": "Importar/Exportar Todas as Opções"
},
"whatExportOptions": {
"message": "Essa suas preferências em JSON. Isso inclui seu ID de usuário, então lembre-se de compartilhar com cuidado."
},
"setOptions": {
"message": "Definir Opções"
},
"exportOptionsWarning": {
"message": "Aviso: Alterar as opções é permanente e pode fazer a extensão parar de funcionar. Tem certeza que deseja fazer isso? Certifique-se de fazer um backup de seu antigo por precaução."
},
"incorrectlyFormattedOptions": {
"message": "Este JSON não está formatado corretamente. Suas opções não foram alteradas."
},
"confirmNoticeTitle": {
"message": "Enviar Segmento"
},
"submit": {
"message": "Enviar"
},
"cancel": {
"message": "Cancelar"
},
"delete": {
"message": "Deletar"
},
"preview": {
"message": "Pré-visualizar"
},
"edit": {
"message": "Editar"
},
"copyDebugInformation": {
"message": "Copiar Informações de Depuração Para Área de Transferência"
},
"copyDebugInformationFailed": {
"message": "Erro ao copiar para a área de transferência"
},
"copyDebugInformationOptions": {
"message": "Copia informações para a área de transferência para serem fornecidas a um desenvolvedor quando houver um bug / quando um solicitado pelo desenvolvedor. Informações sensíveis como seu ID de usuário, canais na lista de permissões e endereço personalizado do servidor foram removidos. No entanto, ele contém informações como seu useragent, navegador, sistema operacional e número de versão de extensão. "
},
"copyDebugInformationComplete": {
"message": "A informação de depuração foi copiada para a área de transferência. Sinta-se à vontade para remover qualquer informação que prefira não compartilhar. Salve em um arquivo de texto ou cole-a no relatório de bug."
},
"theKey": {
"message": "A tecla"
},
"keyAlreadyUsedByYouTube": {
"message": "já está sendo usado pelo youtube. Por favor, selecione outra tecla."
},
"keyAlreadyUsed": {
"message": "está vinculado a outra ação. Por favor, selecione outra tecla."
},
"to": {
"message": "até",
"description": "Used between sponsor times. Example: 1:20 to 1:30"
},
"category_sponsor": {
"message": "Patrocinador"
},
"category_intro": {
"message": "Animação de Introdução"
},
"category_outro": {
"message": "Finalização/Créditos"
},
"category_interaction": {
"message": "Lembrete de interação (inscrever-se)"
},
"category_selfpromo": {
"message": "Auto-Promoção e Mercadorias"
},
"category_music_offtopic": {
"message": "Música: Seção sem música"
},
"category_livestream_messages": {
"message": "Livestream: Leituras de Doação/Mensagem"
},
"disable": {
"message": "Desativar"
},
"manualSkip": {
"message": "Pular manualmente"
},
"showOverlay": {
"message": "Mostrar barra de progresso"
},
"enableTestingServer": {
"message": "Habilitar Servidor em teste Beta"
},
"whatEnableTestingServer": {
"message": "Seus envios e votos NÃO SERÃO ENVIADOS para o servidor principal. Use isso apenas para testes."
},
"testingServerWarning": {
"message": "Todas os envios e votos NÃO SERÃO ENVIADOS para o servidor principal enquanto se conecta ao servidor de teste. Certifique-se de desativar isso quando você quiser fazer envios reais."
},
"bracketNow": {
"message": "(agora)"
},
"moreCategories": {
"message": "Mais categorias"
},
"bracketEnd": {
"message": "(Fim)"
},
"hiddenDueToDownvote": {
"message": "oculto: Downvote"
},
"hiddenDueToDuration": {
"message": "oculto: muito curto"
},
"channelDataNotFound": {
"message": "ID do canal ainda não carregado."
},
"adblockerIssue": {
"message": "Parece que algo está bloqueando o SponsorBlock de obter dados de vídeo. Isso é provavelmente o seu bloqueador de anúncios. Por favor, verifique https://github.com/ajayyy/SponsorBlock/wiki/Fix-Ad-Blocker-Blocking-SponsorBlock-Requests"
},
"itCouldBeAdblockerIssue": {
"message": "Se isso continuar acontecendo, pode ser causado pelo seu bloqueador de anúncios. Por favor, verifique https://github.com/ajayyy/SponsorBlock/wiki/Fix-Ad-Blocker-Blocking-SponsorBlock-Requests"
},
"forceChannelCheck": {
"message": "Forçar verificação do canal antes de pular os patrocínios"
},
"whatForceChannelCheck": {
"message": "Por padrão, isso pulará os patrocínios imediatamente mesmo antes de saber qual é o canal. Por padrão, alguns patrocinadores de zero segundo podem ser ignorados nos canais da lista branca. Habilitar esta opção evitará isso, mas irá fazer com que todos os saltos tenham um ligeiro atraso, já que obter o channelID pode levar algum tempo. Este atraso pode não ser perceptível se você tiver internet rápida."
},
"forceChannelCheckPopup": {
"message": "Considere habilitar a verificação de canal forçada antes de pular os patrocinadores"
},
"downvoteDescription": {
"message": "Incorreto"
},
"incorrectCategory": {
"message": "Categoria errada"
},
"nonMusicCategoryOnMusic": {
"message": "Este vídeo é classificado como música. Você tem certeza que deseja enviar segmentos com categorias que não são músicas? A menos que esse vídeo não seja de fato música, você não deve enviar esse segmento. Por favor leia as orientações se estiver em dúvidas."
}
}

View File

@@ -350,6 +350,9 @@
"supportInvidious": {
"message": "支持 Invidious"
},
"supportInvidiousDescription": {
"message": "Invidious (invidio.us) 是一个第三方 Youtube 客户端。要启用支持,您必须允许额外的权限。在 Chrome 及其他 Chromium 变种的匿名模式中无法工作。"
},
"optionsInfo": {
"message": "启用 Invidious 支持,禁用自动跳过,隐藏按钮等等。"
},
@@ -486,9 +489,21 @@
"category_sponsor": {
"message": "赞助商广告"
},
"category_intro": {
"message": "介绍动画"
},
"category_interaction": {
"message": "互动提醒(订阅)"
},
"category_selfpromo": {
"message": "自我推销和商品"
},
"category_music_offtopic": {
"message": "音乐:非音乐部分"
},
"category_livestream_messages": {
"message": "直播:捐赠/消息阅读"
},
"disable": {
"message": "禁用"
},
@@ -539,5 +554,14 @@
},
"forceChannelCheckPopup": {
"message": "请考虑启用跳过赞助商广告前强制进行频道检查"
},
"downvoteDescription": {
"message": "不正确"
},
"incorrectCategory": {
"message": "错误的类别"
},
"nonMusicCategoryOnMusic": {
"message": "此视频被归类为音乐。您确定要提交带有非音乐类别的片段吗?除非此视频实际上不是音乐,否则您不应提交此片段。如果您感到困惑,请阅读指南。"
}
}

View File

@@ -198,13 +198,11 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
</button>
{/* Category vote */}
{Config.config.testingServer &&
<button className="sponsorSkipObject sponsorSkipNoticeButton"
onClick={() => this.openCategoryChooser()}>
<button className="sponsorSkipObject sponsorSkipNoticeButton"
onClick={() => this.openCategoryChooser()}>
{chrome.i18n.getMessage("incorrectCategory")}
</button>
}
{chrome.i18n.getMessage("incorrectCategory")}
</button>
</td>
</tr>

View File

@@ -260,7 +260,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
}
setTimeToNow(index: number) {
this.setTimeTo(index, this.props.contentContainer().getRoughCurrentTime());
this.setTimeTo(index, this.props.contentContainer().getRealCurrentTime());
}
setTimeToEnd() {

View File

@@ -161,7 +161,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
}
// Check if any non music categories are being used on a music video
if (this.contentContainer().videoInfo.microformat.playerMicroformatRenderer.category === "Music") {
if (this.contentContainer().videoInfo?.microformat?.playerMicroformatRenderer?.category === "Music") {
let sponsorTimesSubmitting = this.props.contentContainer().sponsorTimesSubmitting;
for (const sponsorTime of sponsorTimesSubmitting) {
if (!sponsorTime.category.startsWith("music_")) {

View File

@@ -116,7 +116,7 @@ var skipNoticeContentContainer: ContentContainer = () => ({
changeStartSponsorButton,
previewTime,
videoInfo,
getRoughCurrentTime
getRealCurrentTime: getRealCurrentTime
});
//get messages from the background script and the popup
@@ -180,7 +180,7 @@ function messageListener(request: any, sender: any, sendResponse: (response: any
return
case "getCurrentTime":
sendResponse({
currentTime: getRoughCurrentTime()
currentTime: getRealCurrentTime()
});
break;
@@ -470,7 +470,7 @@ function startSponsorSchedule(includeIntersectingSegments: boolean = false, curr
return;
}
if (incorrectVideoIDCheck()) return;
if (incorrectVideoCheck()) return;
if (currentTime === undefined || currentTime === null) currentTime = video.currentTime;
@@ -490,7 +490,7 @@ function startSponsorSchedule(includeIntersectingSegments: boolean = false, curr
let forcedSkipTime: number = null;
let forcedIncludeIntersectingSegments = false;
if (incorrectVideoIDCheck(videoID)) return;
if (incorrectVideoCheck(videoID, currentSkip)) return;
if (video.currentTime >= skipTime[0] && video.currentTime < skipTime[1]) {
skipToTime(video, skipInfo.endIndex, skipInfo.array, skipInfo.openNotice);
@@ -515,13 +515,11 @@ function startSponsorSchedule(includeIntersectingSegments: boolean = false, curr
}
/**
* This makes sure the videoID is still correct
*
* TODO: Remove this bug catching if statement when the bug is found
* This makes sure the videoID is still correct and if the sponsorTime is included
*/
function incorrectVideoIDCheck(videoID?: string): boolean {
function incorrectVideoCheck(videoID?: string, sponsorTime?: SponsorTime): boolean {
let currentVideoID = getYouTubeVideoID(document.URL);
if (currentVideoID !== (videoID || sponsorVideoID)) {
if (currentVideoID !== (videoID || sponsorVideoID) || (sponsorTime && !sponsorTimes.includes(sponsorTime))) {
// Something has really gone wrong
console.error("[SponsorBlock] The videoID recorded when trying to skip is different than what it should be.");
console.error("[SponsorBlock] VideoID recorded: " + sponsorVideoID + ". Actual VideoID: " + currentVideoID);
@@ -660,7 +658,7 @@ function sponsorsLookup(id: string) {
//check if this video was uploaded recently
utils.wait(() => !!videoInfo).then(() => {
let dateUploaded = videoInfo.microformat.playerMicroformatRenderer.uploadDate;
let dateUploaded = videoInfo?.microformat?.playerMicroformatRenderer?.uploadDate;
//if less than 3 days old
if (Date.now() - new Date(dateUploaded).getTime() < 259200000) {
@@ -812,7 +810,12 @@ function updatePreviewBar() {
//checks if this channel is whitelisted, should be done only after the channelID has been loaded
function whitelistCheck() {
channelID = videoInfo.videoDetails.channelId;
channelID = videoInfo?.videoDetails?.channelId;
if (!channelID) {
channelID = null;
return;
}
//see if this is a whitelisted channel
let whitelistedChannels = Config.config.whitelistedChannels;
@@ -1126,29 +1129,14 @@ async function updateVisibilityOfPlayerControlsButton(): Promise<boolean> {
* current time is out of date while scrubbing or at the end of the video. This is not needed
* for sponsor skipping as the video is not playing during these times.
*/
function getRoughCurrentTime(): number {
let htmlCurrentTimeString = document.querySelector(".ytp-time-current").textContent;
let htmlDurationString = document.querySelector(".ytp-time-duration").textContent;
if (htmlCurrentTimeString == htmlDurationString) {
// At the end of the video
return video.duration;
}
function getRealCurrentTime(): number {
// Used to check if replay button
let playButtonSVGData = document.querySelector("ytp-play-button")?.querySelector("ytp-svg-fill")?.getAttribute("d");
let playButtonSVGData = document.querySelector(".ytp-play-button")?.querySelector(".ytp-svg-fill")?.getAttribute("d");
let replaceSVGData = "M 18,11 V 7 l -5,5 5,5 v -4 c 3.3,0 6,2.7 6,6 0,3.3 -2.7,6 -6,6 -3.3,0 -6,-2.7 -6,-6 h -2 c 0,4.4 3.6,8 8,8 4.4,0 8,-3.6 8,-8 0,-4.4 -3.6,-8 -8,-8 z";
if (playButtonSVGData === replaceSVGData) {
// At the end of the video
return video.duration;
}
let htmlCurrentTimeSections = htmlCurrentTimeString.split(":")[0];
let htmlCurrentTime: number = parseInt(htmlCurrentTimeSections[0]) * 60 + parseInt(htmlCurrentTimeSections[1]);
if (Math.abs(video.currentTime - htmlCurrentTime) > 3) {
return htmlCurrentTime;
} else {
return video.currentTime;
}
@@ -1163,11 +1151,11 @@ function startSponsorClicked() {
//add to sponsorTimes
if (sponsorTimesSubmitting.length > 0 && sponsorTimesSubmitting[sponsorTimesSubmitting.length - 1].segment.length < 2) {
//it is an end time
sponsorTimesSubmitting[sponsorTimesSubmitting.length - 1].segment[1] = getRoughCurrentTime();
sponsorTimesSubmitting[sponsorTimesSubmitting.length - 1].segment[1] = getRealCurrentTime();
} else {
//it is a start time
sponsorTimesSubmitting.push({
segment: [getRoughCurrentTime()],
segment: [getRealCurrentTime()],
UUID: null,
// Default to sponsor
category: "sponsor"
@@ -1545,7 +1533,7 @@ function getSegmentsMessage(segments: number[][]): string {
* Assumes that the the privacy info is available.
*/
function isUnlisted(): boolean {
return videoInfo.microformat.playerMicroformatRenderer.isUnlisted || videoInfo.videoDetails.isPrivate;
return videoInfo?.microformat?.playerMicroformatRenderer?.isUnlisted || videoInfo?.videoDetails?.isPrivate;
}
/**

View File

@@ -103,9 +103,14 @@ class PreviewBar {
categoryTooltip.classList.add("sbHidden");
});
const observer = new MutationObserver(() => {
const observer = new MutationObserver((mutations, observer) => {
if (!mouseOnSeekBar) return;
// See if mutation observed is only this ID (if so, ignore)
if (mutations.length == 1 && (mutations[0].target as HTMLElement).id === "sponsor-block-category-tooltip") {
return;
}
let tooltips = document.querySelectorAll(".ytp-tooltip-text");
for (const tooltip of tooltips) {
let splitData = tooltip.textContent.split(":");
@@ -115,7 +120,7 @@ class PreviewBar {
// Find category at that location
let category = null;
for (let i = 0; i < this.timestamps.length; i++) {
for (let i = 0; i < this.timestamps?.length; i++) {
if (this.timestamps[i][0] < timeInSeconds && this.timestamps[i][1] > timeInSeconds){
category = this.types[i];
}

View File

@@ -18,7 +18,7 @@ interface ContentContainer {
changeStartSponsorButton: (showStartSponsor: any, uploadButtonVisible: any) => Promise<boolean>,
previewTime: (time: number) => void,
videoInfo: any,
getRoughCurrentTime: () => number
getRealCurrentTime: () => number
}
}