Skip to content

Instantly share code, notes, and snippets.

@imkarimkarim
Last active April 7, 2024 21:05
Show Gist options
  • Save imkarimkarim/a1a4242720c2ec23d74fca978321eec3 to your computer and use it in GitHub Desktop.
Save imkarimkarim/a1a4242720c2ec23d74fca978321eec3 to your computer and use it in GitHub Desktop.
click on reddits "RECENT", "CUSTOME FEED" and "Clear(history)" buttons with js.
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
const t = 50;
(async () => {
let f1 = false;
while (!f1) {
let jsPath;
try {
jsPath = document
.querySelector('#left-sidebar > nav > reddit-recent-pages')
.shadowRoot.querySelector(
'faceplate-expandable-section-helper > details > summary > faceplate-tracker > li > div'
);
} catch {}
if (jsPath) {
jsPath.click();
f1 = true;
}
console.log('mmd');
await sleep(t);
}
let f2 = false;
while (!f2) {
let jsPath;
try {
jsPath = document.querySelector(
'#left-sidebar > nav > faceplate-expandable-section-helper:nth-child(5) > details > summary > faceplate-tracker > li > div'
);
} catch {}
if (jsPath) {
jsPath.click();
f2 = true;
}
console.log('mmd2');
await sleep(t);
}
let t3 = 0;
while (t3 < 100) {
let jsPath;
try {
jsPath = document
.querySelector('#right-sidebar-container > aside > recent-posts')
.shadowRoot.querySelector('aside > div.flex.justify-between.items-center > faceplate-tracker > button');
} catch {}
if (jsPath) {
jsPath.click();
}
console.log('mmd3');
t3++;
await sleep(t);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment