GitHub原始链接

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==

// @name         GitHub原始链接

// @namespace    Linxi

// @version      1.2

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

// @author       林夕

// @match        https://github.com/*

// @grant        none

// ==/UserScript==

(function() {

    'use strict';

    function openRawLink() {

        var rawUrl = window.location.href.replace('/blob', '').replace('github.com', 'raw.githubusercontent.com');

        window.location.href = rawUrl;

    }

    var rawButton = document.createElement('button');

    rawButton.innerHTML = '打开raw';//按钮名字

    rawButton.style.transform = 'scale(1.5)';//按钮大小

    rawButton.style.position = 'fixed';

    rawButton.style.right = '130px';//按钮左右

    rawButton.style.bottom = '80px';//按钮上下

    rawButton.addEventListener('click', openRawLink);

    document.body.appendChild(rawButton);

})();