Last active
January 23, 2025 11:42
-
-
Save s-nt-s/fe7a583c629b59afc8bff75ddd170937 to your computer and use it in GitHub Desktop.
Pulsar 'No recomendarme este canal' en todos los canales
This file contains 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
setInterval(async () => { | |
const isVisible = (el) => { | |
if (!el) return false; | |
const style = getComputedStyle(el); | |
const rect = el.getBoundingClientRect(); | |
return style.display !== "none" && | |
style.visibility !== "hidden" && | |
parseFloat(style.opacity) > 0 && | |
rect.width > 0 && rect.height > 0 && | |
rect.bottom > 0 && rect.right > 0 && | |
rect.top < window.innerHeight && | |
rect.left < window.innerWidth; | |
} | |
const doScrool = () => { | |
const scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); | |
if (window.__scrollHeight == scrollHeight) { | |
console.log("#logo span click"); | |
document.querySelector("#logo span").click(); | |
return; | |
} | |
window.__scrollHeight = scrollHeight; | |
console.log("window.scrollTo(0, "+scrollHeight+")"); | |
window.scrollTo(0, scrollHeight); | |
} | |
const querySelector = (slc) => { | |
const n = Array.from(document.querySelectorAll(slc)) | |
.filter(n=>isVisible(n)) | |
[0]; | |
console.log(slc, n); | |
return n; | |
} | |
const getByText = (tag, txt) => { | |
const n = Array.from(document.querySelectorAll(tag)) | |
.filter(n=>isVisible(n) && txt == n.textContent.replace(/\s+/g, " ").trim()) | |
[0]; | |
console.log(tag+"[txt()='"+txt+"']", n); | |
return n; | |
} | |
const b = querySelector("button[aria-label='Menú de acciones'],div.yt-lockup-view-model-wiz__metadata div.yt-spec-touch-feedback-shape"); | |
if (b == null) return doScrool(); | |
b.click(); | |
await new Promise(r => setTimeout(r, 1000)); | |
const i = getByText("yt-formatted-string", 'No recomendarme este canal') || | |
getByText("span.yt-core-attributed-string", 'No me interesa'); | |
if (i == null) return doScrool(); | |
i.click(); | |
b.remove(); | |
}, 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment