Skip to content

Instantly share code, notes, and snippets.

@apoorvlathey
Forked from banteg/twitter-report.js
Last active March 14, 2024 17:08
Show Gist options
  • Save apoorvlathey/bcc49f84e8f092d7e5d660c55129d13a to your computer and use it in GitHub Desktop.
Save apoorvlathey/bcc49f84e8f092d7e5d660c55129d13a to your computer and use it in GitHub Desktop.
Tampermonkey userscript: arc boost to report spam on twitter
// ==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);
});
}
})();
@jimthereaper
Copy link

Could you please create a browser extension?

@apoorvlathey
Copy link
Author

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