Skip to content

Instantly share code, notes, and snippets.

@johnrees
Last active December 17, 2022 18:21
Show Gist options
  • Save johnrees/0d4098f748ef0be40e08cfef1950ad42 to your computer and use it in GitHub Desktop.
Save johnrees/0d4098f748ef0be40e08cfef1950ad42 to your computer and use it in GitHub Desktop.
// go to following or followers page
let values = new Set([]);
let height = 0;
function scroll() {
if (height < document.body.scrollHeight) {
height = document.body.scrollHeight;
window.scrollTo(0, height);
setTimeout(scroll, 2000);
[
...document.querySelectorAll(
"[aria-label^='Timeline: Follow'] a>div>div.css-1hf3ou5>span"
),
].forEach(({ innerText }) => {
values.add(innerText.replace("@", ""));
});
} else {
const result = [...values].join("\n");
console.log(result);
// const popup = window.open("about:blank", "", "_blank");
// popup.document.write(`<pre>${result}</pre>`);
}
}
scroll();
// go to likes or bookmarks page
let values = new Set([]);
let height = 0;
function scroll() {
if (height < document.body.scrollHeight) {
height = document.body.scrollHeight;
window.scrollTo(0, height);
setTimeout(scroll, 2000);
[
...document.querySelectorAll(
`[aria-label$='${
document.title.includes("liked by") ? "liked Tweets" : "Bookmarks"
}'] a:has(time)`
),
].forEach(({ href }) => {
values.add(href);
});
} else {
const result = [...values].join("\n");
console.log(result);
}
}
scroll();
@johnrees
Copy link
Author

paste copy([...values].join("\n")) in a separate command afterwards if you want them on your clipboard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment