Created
August 24, 2021 09:56
-
-
Save almgwary/213d130b505fabbefd271ce37168ad42 to your computer and use it in GitHub Desktop.
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
let prevent; | |
const stop = () => { | |
prevent = true; | |
chrome.runtime.sendMessage({ | |
type: "msg", | |
msg: "start again", | |
running: false | |
}); | |
}; | |
const start = () => { | |
const subs = document.querySelectorAll('#subscribe-button > ytd-subscribe-button-renderer > tp-yt-paper-button'); | |
if (typeof subs === "undefined" || subs.length === 0) { | |
chrome.runtime.sendMessage({ | |
type: "msg", | |
msg: "you dont have any subs", | |
running: false | |
}); | |
return; | |
} | |
prevent = false; | |
chrome.runtime.sendMessage({ | |
type: "msg", | |
msg: "click to stop", | |
running: true | |
}); | |
const unSubscribe = (counter) => { | |
if (prevent) return; | |
if (counter < subs.length) { | |
setTimeout(() => { | |
subs[counter].scrollIntoView({ | |
behavior: 'smooth', | |
block: 'start' | |
}); | |
subs[counter].click(); | |
setTimeout(() => { | |
const button = document.getElementById('confirm-button'); | |
button.click(); | |
unSubscribe(counter + 1); | |
}, 150 + counter); | |
}, 300 + counter); | |
return; | |
} | |
}; | |
unSubscribe(0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment