I'm Pro:在 Github 頁面添加 Pro 標識

在自己的 Github 頁面個人資料頁上添加 Github Pro 標識(僅本地有效)

  1. // ==UserScript==
  2. // @name I'm Pro:在 Github 页面添加 Pro 标识
  3. // @name:zh-TW I'm Pro:在 Github 頁面添加 Pro 標識
  4. // @name:en I'm Pro: Add a Github Pro badge to your Github profile
  5. // @namespace http://tampermonkey.net/
  6. // @version 1.0
  7. // @description 在自己的 Github 页面个人资料页上添加 Github Pro 标识(仅本地有效)
  8. // @description:zh-TW 在自己的 Github 頁面個人資料頁上添加 Github Pro 標識(僅本地有效)
  9. // @description:en Add a Github Pro badge to your Github profile page (local display only)
  10. // @author GamerNoTitle
  11. // @match https://github.com/*
  12. // @icon https://github.githubassets.com/favicons/favicon-dark.png
  13. // @license GPLv3
  14. // @grant none
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. // 检测是否是个人资料页
  21. function isProfilePage() {
  22. return document.querySelector('button.js-profile-editable-edit-button') !== null;
  23. }
  24.  
  25. // 创建Highlights模块
  26. function createHighlightsSection() {
  27. const div = document.createElement('div');
  28. div.className = 'border-top color-border-muted pt-3 mt-3 d-none d-md-block';
  29.  
  30. div.innerHTML = `
  31. <h2 class="h4 mb-2">Highlights</h2>
  32. <ul class="list-style-none">
  33. <li class="mt-2">
  34. <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star color-fg-muted">
  35. <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"/>
  36. </svg>
  37. <span title="Label: Pro" data-view-component="true" class="Label Label--purple text-uppercase">Pro</span>
  38. </li>
  39. </ul>
  40. `;
  41. return div;
  42. }
  43.  
  44. // 主逻辑
  45. function main() {
  46. if (!isProfilePage()) return;
  47.  
  48. // 检查Highlights是否存在
  49. const highlights = document.querySelector('div.border-top.color-border-muted.pt-3.mt-3.d-none.d-md-block');
  50. if (!highlights) {
  51. const container = document.querySelector('.Layout-sidebar');
  52. if (container) {
  53. const newSection = createHighlightsSection();
  54. container.appendChild(newSection);
  55. }
  56. } else {
  57. // 确保Pro标识存在
  58. const proBadge = highlights.querySelector('.Label--purple');
  59. if (!proBadge) {
  60. const proItem = document.createElement('li');
  61. proItem.className = 'mt-2';
  62. proItem.innerHTML = `
  63. <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star color-fg-muted">
  64. <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"/>
  65. </svg>
  66. <span title="Label: Pro" data-view-component="true" class="Label Label--purple text-uppercase">Pro</span>
  67. `;
  68. highlights.querySelector('ul').appendChild(proItem);
  69. }
  70. }
  71. }
  72.  
  73. // 页面加载后执行
  74. window.addEventListener('load', main);
  75. // 处理GitHub的异步加载
  76. document.addEventListener('pjax:end', main);
  77. })();

QingJ © 2025

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