Skip to content

Instantly share code, notes, and snippets.

@jweir
Created September 10, 2024 19:54
Show Gist options
  • Save jweir/6568db55222c9a01dc4a4d9d3255f876 to your computer and use it in GitHub Desktop.
Save jweir/6568db55222c9a01dc4a4d9d3255f876 to your computer and use it in GitHub Desktop.
// prevent the browser on x.com for ever enabling the "For you" tab
function fixYou() {
if(document.querySelectorAll('[aria-selected="true"] div div span')[0].textContent == "For you"){
document.querySelectorAll('[href="/home"][aria-selected="false"]')[0].click()
}
}
const observer = new MutationObserver((mutations) => { fixYou() });
observer.observe(document.body, { childList: true, subtree: true });
window.addEventListener('load', () => { fixYou(); });
@jweir
Copy link
Author

jweir commented Sep 10, 2024

The above is the JS necessary to monitor the page for changes and track when the "For you" tab is selected.

You could just paste this into the browser, but it won't survive full page reloads.

So this would be best inside of an extension. Building that is beyond the scope of this – but an "AI" or a blog post will help you do that for your browser. Maybe Grok could even help you.

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