Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cocoabox/8ec3aa25a8a49a98a60dffe7a6594e13 to your computer and use it in GitHub Desktop.
Save cocoabox/8ec3aa25a8a49a98a60dffe7a6594e13 to your computer and use it in GitHub Desktop.
twitter-not-interested-bookmarklet.js
javascript: void((function() { function disableInterests(doc) { function findSpanText(checkbox) { let elem = checkbox.parentElement; let levels = 0; while (elem && levels < 10) { let span = elem.querySelector('span'); if (span) { return span.textContent; } elem = elem.parentElement; levels++; } } let wait_ms = 100; let checkboxes = doc.querySelectorAll("div > input[type='checkbox']:checked"); let len = checkboxes.length; let done = 0; let inc = 50; checkboxes.forEach((interest) => { console.log(interest); let text = findSpanText(interest); setTimeout(function() { done++; let msg = `(${done}/${len}) ` + (text ? text : '(unknown)'); console.log(msg); doc.title = msg; interest.scrollIntoView({behavior:'smooth'}); interest.click(); }, wait_ms); wait_ms += 2000 + inc; inc += 25; }); } const EXPECTED_URL = 'https://twitter.com/settings/your_twitter_data/twitter_interests'; if (document.location.href === EXPECTED_URL) { disableInterests(document); } else { alert('%E8%88%88%E5%91%B3%E9%96%A2%E5%BF%83%E3%83%9A%E3%83%BC%E3%82%B8%E3%82%92%E9%96%8B%E3%81%8D%E3%81%BE%E3%81%99%E3%80%82%E9%96%8B%E3%81%84%E3%81%9F%E3%82%89%E3%81%BE%E3%81%9F%E5%91%BC%E3%82%93%E3%81%A7%E3%81%AD'); window.open(EXPECTED_URL); } })());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment