Skip to content

Instantly share code, notes, and snippets.

@tnorthcutt
Created September 26, 2024 15:38
Show Gist options
  • Save tnorthcutt/75e8d928890e3d1e4769c6962fa7fb97 to your computer and use it in GitHub Desktop.
Save tnorthcutt/75e8d928890e3d1e4769c6962fa7fb97 to your computer and use it in GitHub Desktop.
Uncheck twitter interests – paste into devtools console
// go to https://x.com/settings/your_twitter_data/twitter_interests
// open devtools, console tab
// paste in
// Uses dynamic delay to try to get around twitter's rate limiting
// You may need to run this more than once, waiting a while between runs to let the rate limiting reset
const uncheckWithDynamicDelay = async (checkbox, index, total, currentDelay, consecutiveUnchecks) => {
console.log(`Processing interest ${index + 1} of ${total}. Current delay: ${currentDelay}ms`);
if (checkbox.checked) {
checkbox.click(); // Simulate a click to uncheck
console.log(`Unchecked interest ${index + 1} of ${total}`);
return [Math.min(currentDelay + 500, 3500), consecutiveUnchecks + 1];
} else {
console.log(`Interest ${index + 1} of ${total} already unchecked`);
return [Math.max(currentDelay - 100, 100), 0];
}
};
// Find all input elements with aria-describedby attribute matching the pattern
const checkboxes = document.querySelectorAll('input[aria-describedby^="CHECKBOX_"][aria-describedby$="_LABEL"]');
// Uncheck all found checkboxes with dynamic delay
(async () => {
let currentDelay = 100;
let consecutiveUnchecks = 0;
for (let i = 0; i < checkboxes.length; i++) {
[currentDelay, consecutiveUnchecks] = await uncheckWithDynamicDelay(checkboxes[i], i, checkboxes.length, currentDelay, consecutiveUnchecks);
await new Promise(resolve => setTimeout(resolve, currentDelay));
}
console.log(`Finished processing ${checkboxes.length} interests.`);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment