GitHub 加速 (Gist)

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

目前為 2021-05-31 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name GitHub 加速 (Gist)
  3. // @namespace https://mogeko.me
  4. // @version 0.1
  5. // @description 通过代理为 GitHub Gist 的 Raw Assets 提供加速
  6. // @author Mogeko
  7. // @supportURL https://github.com/Mogeko/user-script-ghproxy/issues
  8. // @match https://gist.github.com/*
  9. // @icon https://github.githubassets.com/pinned-octocat.svg
  10. // @updataURL https://cdn.jsdelivr.net/gh/Mogeko/user-script-ghproxy@master/agentGistRaw/agentGistRaw.user.js
  11. // @run-at document-end
  12. // @grant none
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16. const PROXY_URL = 'https://ghproxy.com/';
  17.  
  18. const agentGistRaw = proxy => {
  19. const links = document
  20. .querySelectorAll('.file-actions a, .ml-2:nth-last-child(1) a');
  21. links.forEach(link => {
  22. link.href = proxy + link.href
  23. });
  24. }
  25.  
  26. (function() {
  27. 'use strict';
  28. agentGistRaw(PROXY_URL);
  29. document.addEventListener('pjax:success', () => {
  30. agentGistRaw(PROXY_URL);
  31. });
  32. })();