修改 GitHub 图标

将 GitHub 的网站图标改为亮色透明背景,改善暗色标签页背景等环境下图标的对比度,适合使用暗色主题的 Firefox 浏览器。内置 亮、暗、黑 三种颜色,亮、暗、黑、透明 四种背景可供直接修改。浏览器需支持 SVG 图标。

目前为 2019-11-19 提交的版本。查看 最新版本

// ==UserScript==
// @name              Tweak GitHub Icon
// @name:zh-CN        修改 GitHub 图标
// @description       Tweak the icon of GitHub's website into white color & transparent background for better contrast on dark tab backgrounds etc. , especially for dark-themed Firefox. White, dark and black colors as well as white, dark, black and transparent backgrounds are all predifined in case of you need to modify them. Require SVG icon support.
// @description:zh-CN 将 GitHub 的网站图标改为亮色透明背景,改善暗色标签页背景等环境下图标的对比度,适合使用暗色主题的 Firefox 浏览器。内置 亮、暗、黑 三种颜色,亮、暗、黑、透明 四种背景可供直接修改。浏览器需支持 SVG 图标。
// @namespace         RainSlide
// @match             https://github.com/*
// @version           1.0
// @grant             none
// ==/UserScript==

if (
  document.head.querySelector('[rel="icon"]') &&
  document.head.querySelector('[rel="icon"]').href
) {

  function getSVGDataURL (color, background) {
    // SVG source code based on https://github.githubassets.com/pinned-octocat.svg , all the rights belong to GitHub.Inc .
    return "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 36'" + background + "%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd'" + color + " d='M18 1.4C9 1.4 1.7 8.7 1.7 17.7c0 7.2 4.7 13.3 11.1 15.5.8.1 1.1-.4 1.1-.8v-2.8c-4.5 1-5.5-2.2-5.5-2.2-.7-1.9-1.8-2.4-1.8-2.4-1.5-1 .1-1 .1-1 1.6.1 2.5 1.7 2.5 1.7 1.5 2.5 3.8 1.8 4.7 1.4.1-1.1.6-1.8 1-2.2-3.6-.4-7.4-1.8-7.4-8.1 0-1.8.6-3.2 1.7-4.4-.2-.4-.7-2.1.2-4.3 0 0 1.4-.4 4.5 1.7 1.3-.4 2.7-.5 4.1-.5 1.4 0 2.8.2 4.1.5 3.1-2.1 4.5-1.7 4.5-1.7.9 2.2.3 3.9.2 4.3 1 1.1 1.7 2.6 1.7 4.4 0 6.3-3.8 7.6-7.4 8 .6.5 1.1 1.5 1.1 3v4.5c0 .4.3.9 1.1.8 6.5-2.2 11.1-8.3 11.1-15.5C34.3 8.7 27 1.4 18 1.4z'/%3E%3C/svg%3E";
  }

  function c(color) { return " fill='%23" + color + "'"; }; // color
  function b(color) { return " style='background-color:%23" + color + "'"; }; // background

  var white_color = c("fff"),   white_background = b("fff"),
       dark_color = c("191717"), dark_background = b("191717"),
      black_color = c("000"),   black_background = b("000"),
  transparent_background = "";

  document.head.querySelector('[rel="icon"]').href = getSVGDataURL( white_color, transparent_background );

}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址