Last active
June 30, 2023 19:12
-
-
Save ivan/ce2e721defccb4f64df5da967dab0d41 to your computer and use it in GitHub Desktop.
Sort-of archiving a bunch of Twitter accounts' profile tabs
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
// ==UserScript= | |
// @name Click to show tweets from blocked and muted users | |
// @version 1.0 | |
// @match https://twitter.com/* | |
// @match https://mobile.twitter.com/* | |
// @grant none | |
// ==/UserScript== | |
(() => { | |
dispatchEvent(new CustomEvent("single-file-user-script-init")); | |
addEventListener("single-file-on-before-capture-request", async event => { | |
event.preventDefault(); | |
// Remove the bottom bar with "Did someone say … cookies?" | |
Array.from(document.querySelectorAll('div[data-testid=BottomBar]')).forEach(el => el.parentNode.removeChild(el)); | |
try { | |
// Click the buttons to expand blocked and muted tweets | |
document.querySelectorAll('div.css-18t94o4.css-1dbjc4n.r-1niwhzg.r-42olwf.r-sdzlij.r-1phboty.r-rs99b7.r-15ysp7h.r-4wgw6l.r-1ny4l3l.r-ymttw5.r-f727ji.r-j2kj52.r-o7ynqc.r-6416eg.r-lrvibr').forEach(el => el.click()); | |
// Wait a bit for Twitter's animations to change box geometries before saving | |
await new Promise(r => setTimeout(r, 2000)); | |
} finally { | |
dispatchEvent(new CustomEvent("single-file-on-before-capture-response")); | |
} | |
}); | |
})(); |
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
sf() { | |
ionice -c 3 nice -n 19 ~/opt/single-file-cli/single-file \ | |
--max-parallel-workers 1 \ | |
--user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" \ | |
--browser-script ~/expand-blocked-and-muted-tweets.js \ | |
--browser-executable-path google-chrome-unstable \ | |
--browser-wait-delay 2000 \ | |
--filename-template '{page-title} - {url-href-flat}.html' \ | |
--filename-max-length 240 \ | |
--browser-cookies-file ~/.cache/your-twitter-cookies.txt \ | |
--browser-width 1920 \ | |
--browser-height 32767 \ | |
"$@" | |
} | |
for i in `cat ~/username-list`; do | |
echo $i | |
sf "https://twitter.com/$i" | |
sf "https://twitter.com/$i/with_replies" | |
sf "https://twitter.com/$i/media" | |
sf "https://twitter.com/$i/likes" | |
sf "https://twitter.com/$i/following" | |
sf "https://twitter.com/$i/followers" | |
done |
--browser-height 32767
seemed to work best (I didn't try 1 higher, but >= 40000 resulted in small output files.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/ivan/f8a0f4acd31fd9e55716c12a98dbc3fe SingleFile on NixOS
https://github.com/ludios/scrape-things for scraping your list of Twitter follows and followers