Last active
April 7, 2021 03:10
-
-
Save pedropedruzzi/f25a010f8a787352575d8f312433979b to your computer and use it in GitHub Desktop.
Greasemonkey script que permite download de legendas a partir dos resultados de busca do site legendas.tv. Instruções: 1. Instale o Greasemonkey (Firefox) ou Tampermonkey (Chrome ou Firefox). 2. Clique em https://gist.githubusercontent.com/pedropedruzzi/f25a010f8a787352575d8f312433979b/raw/download-na-busca-do-legendas-tv.user.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Download na busca do legendas.tv | |
// @namespace http://tampermonkey.net/ | |
// @version 0.4 | |
// @description Permite download de legendas a partir dos resultados de busca do site legendas.tv | |
// @author Pedro Pedruzzi | |
// @match http://legendas.tv/busca/* | |
// @match https://legendas.tv/busca/* | |
// @grant none | |
// @downloadURL https://gist.githubusercontent.com/pedropedruzzi/f25a010f8a787352575d8f312433979b/raw/download-na-busca-do-legendas-tv.user.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.addEventListener('load', tryInstallObserver, false); | |
function tryInstallObserver() { | |
console.debug('tryInstallObserver()'); | |
if (document.querySelector("a[href^='/login']")) { | |
console.debug("download won't work until the user is signed in. aborting"); | |
return; | |
} | |
const targetElement = document.getElementById('resultado_busca'); | |
if (targetElement == null) { | |
console.debug('no #resultado_busca element yet'); | |
window.requestAnimationFrame(tryInstallObserver); | |
return; | |
} | |
console.debug('tryInstallObserver: ready to install observer'); | |
const observer = new MutationObserver(function(mutationsList, observer) { | |
for (let mutation of mutationsList) { | |
if (mutation.addedNodes.length > 0) { | |
console.debug("mutation detected"); | |
addDownloadLinks(); | |
} | |
} | |
}); | |
observer.observe(targetElement, { childList: true }); | |
addDownloadLinks(); // ensure initial set of links are displayed | |
} | |
function addDownloadLinks() { | |
var links = document.querySelectorAll("a[href^='/download/']"); | |
console.debug('found links:', links.length); | |
for (var i = 0; i < links.length; i++) { | |
var link = links[i]; | |
if (link.parentNode.querySelector("a.seta") == null) { // do nothing when there's already a download link there | |
var downloadId = link.getAttribute('href').match(/\/download\/([^\/]*)\//)[1]; | |
link.parentNode.appendChild(createDownloadLink(downloadId)); | |
} | |
} | |
return links.length; | |
} | |
function createDownloadLink(downloadId) { | |
var el = document.createElement("a"); | |
el.setAttribute('href', '/downloadarquivo/' + downloadId); | |
el.setAttribute('title', 'Baixar esta legenda agora'); | |
el.setAttribute('style', 'float:right; position:static'); | |
el.setAttribute('class', 'seta'); | |
// old text style | |
//el.appendChild(document.createTextNode("download")); | |
//el.setAttribute('style', 'float:right; background: #4885c4; padding: 0px 12px 0px; color: white; font-weight: normal; font-size: 13px'); | |
return el; | |
} | |
})(); |
Obrigado por reportar. Abre uma issue pf.
Em dom, 23 de fev de 2020 11:03, rgponce <[email protected]>
escreveu:
… Oi, em alguns momentos o script falha em colocar o botão de download nos
resultados de busca.
Os principais são:
- Quando você filtra a busca ao clicar no cartaz do filme ou temporada
de série que deseja.
- Quando você aperta o botão para carregar mais resultados de legendas.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/f25a010f8a787352575d8f312433979b?email_source=notifications&email_token=AAB2ZFZ5AA552O72DB47YLDREJ63HA5CNFSM4KZ225I2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAGCPKK#gistcomment-3186341>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB2ZF6NDWFNFEYVD42QA33REJ63HANCNFSM4KZ225IQ>
.
Desculpe, mas não aparece esta opção para mim nas abas. Aparecem apenas as abas: Code e Revisions
Tem razão. Esta opção não existe para Gist, somente para projetos. Eu
atualizei a script com a correção. Pode validar?
Perfeito, muito obrigado :)
Seu userscript é um dos melhores que já vi, economiza muitíssimo do tempo ao baixar legendas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oi, em alguns momentos o script falha em colocar o botão de download nos resultados de busca.
Os principais são: