Last active
March 1, 2025 04:15
-
-
Save bert9946/27e00f4fac175630c4da0fe1f5bbd19a to your computer and use it in GitHub Desktop.
Replace the logo on the GitHub logo with a "P-hub" style one
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 GitHub logo replace | |
// @description Replace the logo on the GitHub logo with a "P-hub" style one. | |
// @run-at document-body | |
// @version 3.1.0 | |
// @match *://github.com/* | |
// @match *://gist.github.com/* | |
// @exclude *://training.github.com/* | |
// @exclude *://docs.github.com/* | |
// @author Bert Chen | |
// ==/UserScript== | |
(function () { | |
if (window.location.hostname === "github.com") { | |
var oldLogo = document.getElementsByClassName('octicon-mark-github')[1]; | |
var a = document.getElementsByClassName('AppHeader-logo')[1]; | |
a.setAttribute("style", "width: 86.6px; border-radius: 3px"); | |
} | |
else if (window.location.hostname === "gist.github.com") { | |
var oldLogo = document.getElementsByClassName('octicon-logo-github')[0]; | |
} | |
//"P hub" style logo | |
var img = document.createElement("img"); | |
const src_dark = "https://gist.githubusercontent.com/bert9946/27e00f4fac175630c4da0fe1f5bbd19a/raw/23d43dd3c661582a1bb8e067b61e2b14cd725eb0/Logo_dark.svg"; | |
const src_light = "https://gist.githubusercontent.com/bert9946/27e00f4fac175630c4da0fe1f5bbd19a/raw/23d43dd3c661582a1bb8e067b61e2b14cd725eb0/Logo_light.svg"; | |
if (window.location.hostname === "github.com") { | |
const updateLogo = (isDarkMode) => { | |
img.src = isDarkMode ? src_dark : src_light; | |
}; | |
const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches; | |
updateLogo(isDarkMode); | |
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => { | |
updateLogo(event.matches); | |
}); | |
} | |
else { | |
img.src = src_dark; | |
} | |
img.setAttribute("style", "width: 86.6px; height: 32px;"); | |
img.classList = 'octicon octicon-logo-github octicon-mark-github v-align-middle'; | |
oldLogo.replaceWith(img); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment