Skip to content

Instantly share code, notes, and snippets.

@banteg
Last active March 30, 2024 22:15
Show Gist options
  • Save banteg/ace08214938dd6cfc948d4c8be6ac2a4 to your computer and use it in GitHub Desktop.
Save banteg/ace08214938dd6cfc948d4c8be6ac2a4 to your computer and use it in GitHub Desktop.
arc boost to report spam on twitter
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('[role="radiogroup"] > div > label');
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-viewportview="true"] [role="button"]:last-of-type')
element.click();
console.log("click submit");
} catch (error) {
console.error(error);
} finally {
actionsInProgress = false;
}
}
document.addEventListener("DOMContentLoaded", () => {
setInterval(performActions, 1000);
});
@banteg
Copy link
Author

banteg commented Sep 6, 2023

@banteg
Copy link
Author

banteg commented Sep 23, 2023

twitter rolled out a short 1-step form today. if you have it, use this version.

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 next_button = await waitForElement(
      '[data-testid="ChoiceSelectionNextButton"]'
    );
    console.log("reporting");

    let spam = await waitForElement('[aria-posinset="6"]');
    spam.click();

    next_button.click();

    let block = await waitForElement('[data-viewportview="true"] [role="button"]:last-of-type')
    block.click();
  } catch (error) {
    console.error(error);
  } finally {
    actionsInProgress = false;
  }
}

document.addEventListener("DOMContentLoaded", () => {
  setInterval(performActions, 200);
});

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