您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
显示当前页面ID,并允许通过快捷键增减ID来跳转页面
当前为
// ==UserScript== // @name 页面ID快速跳转 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 显示当前页面ID,并允许通过快捷键增减ID来跳转页面 // @author Your Name // @match *://*/* // @license LGPL // @grant none // ==/UserScript== (function() { 'use strict'; // 存储解析后的URL部分 let baseUrl = ''; let pageId = ''; let extension = ''; // 解析URL的函数 function parseUrl() { const url = window.location.href; const regex = /([^/]*\/?)([^/\.]*?)(\.(html|jsp|htm|php))$/i; const match = url.match(regex); if (match) { baseUrl = match[1]; pageId = match[2]; extension = match[3]; // 检查pageId是否全为数字 if (!/^\d+$/.test(pageId)) { pageId = ''; } } updateDisplay(); } // 更新页面ID显示 function updateDisplay() { const displayDiv = document.getElementById('pageIdDisplay'); if (!displayDiv) { const newDiv = document.createElement('div'); newDiv.id = 'pageIdDisplay'; newDiv.style.position = 'fixed'; newDiv.style.bottom = '20px'; newDiv.style.right = '20px'; newDiv.style.fontSize = '36px'; newDiv.style.color = 'orange'; newDiv.style.zIndex = '10000'; newDiv.style.padding = '5px 10px'; newDiv.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'; newDiv.style.borderRadius = '10px'; document.body.appendChild(newDiv); } displayDiv.textContent = 'Page ID: ' + (pageId || 'Not Found'); } // 处理键盘快捷键 document.addEventListener('keydown', function(event) { if (!pageId) return; const currentId = parseInt(pageId, 10); let newId = ''; if (event.ctrlKey && event.key === 'ArrowRight') { newId = (currentId + 1).toString(); } else if (event.ctrlKey && event.key === 'ArrowLeft') { newId = (currentId - 1).toString(); } if (newId) { const newUrl = baseUrl + newId + extension; window.location.href = newUrl; } }); // 页面加载完成后解析URL window.onload = parseUrl; })();