Created
June 2, 2022 11:10
-
-
Save kitze/76cc5b8bf4c8016916ee7ebaae1e7954 to your computer and use it in GitHub Desktop.
A TamperMonkey script that will set the favicon of the page to the page icon of coda
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 coda favicon | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author Kitze | |
// @match https://coda.io/* | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function onDocReady(fn) { | |
// see if DOM is already available | |
if (document.readyState === "complete" || document.readyState === "interactive") { | |
// call on next available tick | |
setTimeout(fn, 1000); | |
} else { | |
document.addEventListener("DOMContentLoaded", fn); | |
} | |
} | |
const changeFavicon = () => { | |
var link = document.querySelector("link[rel~='icon']"); | |
const head = document.getElementsByTagName('head')[0]; | |
if (!link) { | |
link = document.createElement('link'); | |
} | |
const icon = document.querySelector("[data-scroll-id=\"canvasScrollContainer\"] .UeEE5Inb"); | |
if (icon) { | |
link.href = icon.src; | |
link.rel = 'icon'; | |
head.appendChild(link); | |
} | |
} | |
onDocReady(changeFavicon); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment