GitHub原始链接

添加一个按钮来打开GitHub上的原始链接。Add a button to open the GitHub raw link.

  1. // ==UserScript==
  2.  
  3. // @name GitHub原始链接
  4.  
  5. // @namespace Linxi
  6.  
  7. // @version 1.2
  8.  
  9. // @description 添加一个按钮来打开GitHub上的原始链接。Add a button to open the GitHub raw link.
  10.  
  11. // @author 林夕
  12.  
  13. // @match https://github.com/*
  14.  
  15. // @grant none
  16.  
  17. // ==/UserScript==
  18.  
  19. (function() {
  20.  
  21. 'use strict';
  22.  
  23. function openRawLink() {
  24.  
  25. var rawUrl = window.location.href.replace('/blob', '').replace('github.com', 'raw.githubusercontent.com');
  26.  
  27. window.location.href = rawUrl;
  28.  
  29. }
  30.  
  31. var rawButton = document.createElement('button');
  32.  
  33. rawButton.innerHTML = '打开raw';//按钮名字
  34.  
  35. rawButton.style.transform = 'scale(1.5)';//按钮大小
  36.  
  37. rawButton.style.position = 'fixed';
  38.  
  39. rawButton.style.right = '130px';//按钮左右
  40.  
  41. rawButton.style.bottom = '80px';//按钮上下
  42.  
  43. rawButton.addEventListener('click', openRawLink);
  44.  
  45. document.body.appendChild(rawButton);
  46.  
  47. })();

QingJ © 2025

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