Last active
July 30, 2023 05:07
-
-
Save qatoqat/01bb6bf5233d13f8ee4c71ac0bfe3bc4 to your computer and use it in GitHub Desktop.
x favicon and title to tw
This file contains 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 favicon and title | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Change favicon and title | |
// @author You | |
// @match https://*.twitter.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
// edit here | |
const iconUrl = 'https://abs.twimg.com/favicons/favicon.ico'; | |
const title = 'Twitter'; | |
const intervalMilliseconds = 100; | |
// process | |
var link = document.querySelector("link[rel~='icon']"); | |
if (!link) { | |
link = document.createElement('link'); | |
link.rel = 'icon'; | |
document.head.appendChild(link); | |
} | |
link.href = iconUrl; | |
function setTitle() { | |
if (document.title.endsWith('X')) { | |
document.title = document.title.slice(0, -1) + title; | |
} | |
} | |
setInterval(setTitle, intervalMilliseconds); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment