GitHub 加速 (Gist)

通过代理为 GitHub Gist 的 Raw Assets 提供加速

当前为 2023-07-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GitHub 加速 (Gist)
  3. // @namespace https://mogeko.me
  4. // @version 0.1.4
  5. // @author Zheng Junyi
  6. // @description 通过代理为 GitHub Gist 的 Raw Assets 提供加速
  7. // @license MIT
  8. // @icon https://besticon.herokuapp.com/icon?size=80..120..200&url=github.com
  9. // @homepage https://github.com/mogeko/userscripts/tree/master/packages/ghproxy-gist-raw#readme
  10. // @homepageURL https://github.com/mogeko/userscripts/tree/master/packages/ghproxy-gist-raw#readme
  11. // @source https://github.com/mogeko/userscripts.git
  12. // @supportURL https://github.com/mogeko/userscripts/issues
  13. // @match https://gist.github.com/**
  14. // @grant none
  15. // @run-at document-end
  16. // ==/UserScript==
  17.  
  18. (function () {
  19. 'use strict';
  20.  
  21. const PROXY_URL = "https://ghproxy.com/";
  22. function agentGistRaw(proxy) {
  23. const links = document.querySelectorAll(
  24. ".file-actions a, .ml-2:nth-last-child(1) a"
  25. );
  26. links.forEach((link) => {
  27. link.href = proxy + link.href;
  28. });
  29. }
  30. agentGistRaw(PROXY_URL);
  31. document.addEventListener("pjax:success", () => {
  32. agentGistRaw(PROXY_URL);
  33. });
  34.  
  35. })();