Created
January 21, 2022 16:19
-
-
Save shinmai/fdbaf0b94174e0caddbe0afbcd9b994e to your computer and use it in GitHub Desktop.
Autoblock cryptobros
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
| 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.