Skip to content

Instantly share code, notes, and snippets.

@cutiepoka
Created July 17, 2023 21:58
Show Gist options
  • Save cutiepoka/5ae9f0085160e53b801ade8697083c23 to your computer and use it in GitHub Desktop.
Save cutiepoka/5ae9f0085160e53b801ade8697083c23 to your computer and use it in GitHub Desktop.
download pictures from reddit
async function start() {
await dosomething(".expando-button");
console.log('next step')
await wait(20000)
await loopWheel();
console.log('next step')
await wait(20000)
await dosomething("button.res-media-controls-download.res-icon");
console.log('next step')
await wait(20000)
await dosomething("li.link-unsave-button.save-button > a");
}
async function dosomething(selector){
const todo= [...document
.querySelectorAll(selector)]
.map(functionMaker);
for (const func of todo) {
await wait(100)
func()
}
}
async function loopWheel() {
let list = document.querySelectorAll(
"div.res-step-container[last-piece=false] > div.res-step.res-step-next"
);
while (list.length > 0) {
await wait(100)
list.forEach(clickIt);
list = document.querySelectorAll(
"div.res-step-container[last-piece=false] > div.res-step.res-step-next"
);
}
}
function functionMaker(bttn) {
return () => {
clickIt(bttn);
};
}
function clickIt(bttn) {
bttn.click();
}
async function unsave() {
document
.querySelectorAll("li.link-unsave-button.save-button > a")
.forEach(clickIt);
}
function wait(milliseconds) {
return new Promise((resolve) => {
setTimeout(resolve, milliseconds);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment