Created
July 17, 2023 21:58
-
-
Save cutiepoka/5ae9f0085160e53b801ade8697083c23 to your computer and use it in GitHub Desktop.
download pictures from reddit
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
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