Last active
January 23, 2023 06:50
-
-
Save harukaeru/03d78a468f67034787868af26f82933a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.