您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在 GitHub 项目页面和 raw 页面之间切换
当前为
// ==UserScript== // @name GitHub Toggle Project and Raw Page // @namespace http://tampermonkey.net/ // @version 1.0 // @description 在 GitHub 项目页面和 raw 页面之间切换 // @author Your Name // @match *://github.com/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // 在页面加载完成后执行 window.addEventListener('load', function() { // 确保只在文件页面上运行 if (!/\/blob\//.test(window.location.href)) return; // 创建切换按钮 const toggleButton = document.createElement('button'); toggleButton.textContent = 'Toggle 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 currentUrl = window.location.href; if (currentUrl.includes('/blob/')) { const rawUrl = currentUrl.replace('/blob/', '/raw/'); window.location.href = rawUrl; } else if (currentUrl.includes('/raw/')) { const projectUrl = currentUrl.replace('/raw/', '/blob/'); window.location.href = projectUrl; } }); // 将按钮添加到页面中 document.body.appendChild(toggleButton); }); })();