Skip to content

Instantly share code, notes, and snippets.

View jweir's full-sized avatar
🌴
On vacation - foreva

John Weir jweir

🌴
On vacation - foreva
View GitHub Profile
@jweir
jweir / fixYou.js
Created September 10, 2024 19:54
// 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 });
(function() {
// fixYou disables the "For Your" button
// Occassionally it has gotten into a state where for you can be renabled.
function fixYou() {
let defaultMatch = "For you";
let firstSelected = document.querySelectorAll('[href="/home"][aria-selected="true"]')[0];
let text = firstSelected.textContent;
if(text == defaultMatch){
document.querySelectorAll('[href="/home"][aria-selected="false"]')[0].click();