自动提取番茄小说ID并复制,方便粘贴使用
// ==UserScript==
// @name 小说ID自动复制(番茄小说专用)
// @namespace http://tampermonkey.net/
// @version 1.02
// @description 自动提取番茄小说ID并复制,方便粘贴使用
// @author YourName
// @match *://*.fanqienovel.com/*
// @grant GM_setClipboard
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// 提取小说ID,路径中包含 book/ 或 novel/ 后跟6位以上数字
const match = location.href.match(/\/(?:book|novel|reader)?\/?(\d{6,})/i);
if (!match) return;
const novelId = match[1];
// 复制ID到剪贴板
if (typeof GM_setClipboard !== "undefined") {
GM_setClipboard(novelId);
} else {
const input = document.createElement("textarea");
input.value = novelId;
document.body.appendChild(input);
input.select();
document.execCommand("copy");
document.body.removeChild(input);
}
// 显示提示信息
const msg = document.createElement("div");
msg.innerText = `小说ID ${novelId} 已复制到剪贴板`;
Object.assign(msg.style, {
position: "fixed",
top: "20px",
right: "20px",
background: "#28a745",
color: "white",
padding: "10px 15px",
borderRadius: "10px",
zIndex: 9999,
fontSize: "14px",
boxShadow: "0 2px 8px rgba(0,0,0,0.2)"
});
document.body.appendChild(msg);
setTimeout(() => msg.remove(), 3000);
})();