Skip to content

Instantly share code, notes, and snippets.

@shinmai
Created January 21, 2022 16:19
Show Gist options
  • Select an option

  • Save shinmai/fdbaf0b94174e0caddbe0afbcd9b994e to your computer and use it in GitHub Desktop.

Select an option

Save shinmai/fdbaf0b94174e0caddbe0afbcd9b994e to your computer and use it in GitHub Desktop.
Autoblock cryptobros
const delay = ms => {return new Promise(resolve => {setTimeout(() => {resolve(2)}, ms)})},
process = async () => {
cryptobro = document.evaluate("//article[@data-testid='tweet']//div[contains(@style ,'#hex-hw-shapeclip-clipconfig')]/../../../../../../../..//*[@role ='button']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue
while(null != cryptobro) {
try {
cryptobro.click()
console.log("clicked")
var d = await delay(150)
bmi=document.evaluate("//*[@id='layers']//div[@role='menu']//div[@data-testid='block']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue
if(!bmi.outerText.startsWith("Block ")) continue
await bmi.click()
console.log("menu")
d = await delay(150)
await document.evaluate("//*[@data-testid='confirmationSheetConfirm']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue.click()
console.log("blocked")
d = await delay(150)
} catch(e) { }
cryptobro = document.evaluate("//article[@data-testid='tweet']//div[contains(@style ,'#hex-hw-shapeclip-clipconfig')]/../../../../../../../..//*[@role ='button']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue
var d = await delay(250)
}
},
timeline = document.evaluate("//section[contains(@aria-labelledby,'accessible-list')]//div[contains(@style, 'min-height')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,
observer = new MutationObserver(process)
// observer.observe(timeline, {childList: true}) // uncomment to possibly break twitter ToS
@shinmai
Copy link
Copy Markdown
Author

shinmai commented Jan 21, 2022

This is not a ready-made script, userscript or extension code but just a dumb PoC of how one COULD possibly automagically block all users with heaxagonal NFT pfps on their Twitter timeline.

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