-
-
Save apoorvlathey/bcc49f84e8f092d7e5d660c55129d13a to your computer and use it in GitHub Desktop.
Tampermonkey userscript: arc boost to report spam on twitter
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 Twitter Report | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description arc boost to report spam on twitter | |
// @author banteg | |
// @match *://twitter.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com | |
// @grant none | |
// ==/UserScript== | |
let actionsInProgress = false; | |
function waitForElement(selector) { | |
return new Promise((resolve) => { | |
const checkInterval = setInterval(() => { | |
const element = document.querySelector(selector); | |
if (element) { | |
clearInterval(checkInterval); | |
resolve(element); | |
} | |
}, 100); | |
}); | |
} | |
async function performActions() { | |
if (actionsInProgress) return; | |
try { | |
actionsInProgress = true; | |
let element = await waitForElement( | |
'[data-testid="OCF_CallToAction_Button"]' | |
); | |
console.log("reporting"); | |
element.click(); | |
element = await waitForElement('[aria-posinset="3"]'); | |
element.click(); | |
element = await waitForElement('[data-testid="ChoiceSelectionNextButton"]'); | |
element.click(); | |
element = await waitForElement('[aria-posinset="3"]'); | |
element.click(); | |
element = await waitForElement('[data-testid="ChoiceSelectionNextButton"]'); | |
element.click(); | |
element = await waitForElement('[aria-posinset="1"]'); | |
element.click(); | |
element = await waitForElement('[data-testid="ChoiceSelectionNextButton"]'); | |
element.click(); | |
element = await waitForElement('[data-testid="ocfSettingsListNextButton"]'); | |
element.click(); | |
element = await waitForElement('[data-testid="ocfSettingsListNextButton"]'); | |
element.click(); | |
element = await waitForElement('[data-testid="ocfSettingsListNextButton"]'); | |
element.click(); | |
console.log("click submit"); | |
} catch (error) { | |
console.error(error); | |
} finally { | |
actionsInProgress = false; | |
} | |
} | |
(function() { | |
'use strict'; | |
if (document.readyState == "complete" || document.readyState == "loaded" || document.readyState == "interactive") { | |
// already loaded | |
setInterval(performActions, 1000); | |
} else { | |
document.addEventListener("DOMContentLoaded", function(event) { | |
// just loaded | |
setInterval(performActions, 1000); | |
}); | |
} | |
})(); |
Could you please create a browser extension?
@jimthereaper Browser extension is live: https://chrome.google.com/webstore/detail/rapidreport-for-twitter/hnkkbipapeklejjcaikkmobgiiilgedp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you please create a browser extension?