您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在 GitHub 文件页面添加一个按钮,点击可以跳转到对应的 raw 页面
当前为
// ==UserScript== // @name GitHub Toggle to Raw Page // @namespace http://tampermonkey.net/ // @version 1.1 // @description 在 GitHub 文件页面添加一个按钮,点击可以跳转到对应的 raw 页面 // @author Your Name // @match *://github.com/*/*/blob/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // 在页面加载完成后执行 window.addEventListener('load', function() { // 获取当前 URL const currentUrl = window.location.href; // 检查是否为 GitHub 文件页面(包含 /blob/) if (currentUrl.includes('/blob/')) { // 创建跳转按钮 const toggleButton = document.createElement('button'); toggleButton.textContent = 'View Raw'; toggleButton.style.position = 'fixed'; toggleButton.style.top = '10px'; toggleButton.style.right = '10px'; toggleButton.style.zIndex = '1000'; toggleButton.style.padding = '5px 10px'; toggleButton.style.backgroundColor = '#2ea44f'; toggleButton.style.color = '#fff'; toggleButton.style.border = 'none'; toggleButton.style.borderRadius = '5px'; toggleButton.style.cursor = 'pointer'; // 按钮点击事件 toggleButton.addEventListener('click', function() { const rawUrl = currentUrl.replace('github.com', 'raw.githubusercontent.com').replace('/blob/', '/'); window.open(rawUrl, '_blank'); // 在新标签页中打开 raw 页面 }); // 将按钮添加到页面中 document.body.appendChild(toggleButton); } }); })();