Skip to content

Instantly share code, notes, and snippets.

@bert9946
Last active March 1, 2025 04:15
Show Gist options
  • Save bert9946/27e00f4fac175630c4da0fe1f5bbd19a to your computer and use it in GitHub Desktop.
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
// ==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);
})();
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment