GitHub 加速 (Gist)

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

当前为 2022-10-10 提交的版本,查看 最新版本

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