Skip to content

Instantly share code, notes, and snippets.

@harukaeru
Last active January 23, 2023 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harukaeru/03d78a468f67034787868af26f82933a to your computer and use it in GitHub Desktop.
Save harukaeru/03d78a468f67034787868af26f82933a to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Change Default To "Following" Tab, Not "For You" Tab
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://twitter.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
const waitingTime = 200;
let clicked = false;
const findFollowingTab = () => {
if (clicked) {
return;
}
const tabs = document.querySelectorAll('[role="presentation"] a[href="/home"]');
if (tabs.length > 0) {
tabs[1].click();
clicked = true;
} else {
setTimeout(findFollowingTab, waitingTime);
}
}
window.onload = () => {
console.log('Fired');
setTimeout(findFollowingTab, waitingTime);
};
})();
@harukaeru
Copy link
Author

harukaeru commented Jan 23, 2023

History

2023/01/23 fixed the bug of not switching the tab when the landing page is not Home.
2023/01/23 @match is more sophisticated. @include was deprecated.

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