版本比较
一些脚本
正文
增加 399 行删除 95 行
123455678910781112131415161718192021222324252627240 行未改动全部展开268269270271272273274275276257258277278279280281282283284285261286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342115 行未改动全部展开45845946046138638746246346446546646746846947047147247347439047547639247747847948048148248348448548648748848949049140549249349449549641041149749849950050150241441541641750350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373420 行未改动7557567577584527597604547617627637647654584594607667677684627697707717727734677747757767774717787794744754764774784794807807817827837847857867877884867897907917927937947957967977987998008018028038048058068078088098108118128138144898158168178184934944954964974984995005015025035045055065075085095105115125135145155165175185198198208218228238248258268275215225235245255265275285295305315325335345355365378285395405418298308318328338348358368378388398405445455465475488418428438448458468478485565578498508518528538548558568575625638588598608618628638645665678658668675695708688698708718728738748758768778788798808815788828838848858861,104 行未改动全部展开审核大大放我一马吧😭
**欢迎关注本人B站账号[开元玩游戏](https://space.bilibili.com/3546719373494519),冲刺100粉!**
*~~大部分js为AI生成,保证本人贡献大于AI,我贡献的提示词比AI生成量还多,所有总量也有个至少1亿token了~~**~~大部分js为AI生成,保证本人贡献大于AI,我贡献的提示词比AI生成量还多,所有总量也有个至少4亿token了~~*# [:===:原创:===:]# 通用---- 前置类- ---### 设置中心:::info[code]### 通用设置中心:::info[更新日志]>v1.3.0>--->更改版本计数方式>>更改API名字
>v1.2>--->- 新增更新日志::::::success[v1.2]```js// ==UserScript==// @name 通用设置中心// @namespace http://tampermonkey.net/240 行未改动全部展开:::
# 单一网站## note.ms**注意note.ms工具大部分都要在控制台查看输出,不知道控制台的就别搞了**
---- 前置类---### note.ms 单页面覆盖 (需设置中心):::info[code]### note.ms 内容获取接口:::info[更新日志]>v1.1>--->- 新增更新日志::::::success[v1.1]```js// ==UserScript==// @name note.ms 单页面覆盖 (需设置中心)// @name note.ms 内容获取接口// @namespace http://tampermonkey.net/// @version 1.1// @author B站开元玩游戏// @match https://note.ms/*// @run-at document-start// @grant unsafeWindow// ==/UserScript==
(function() { 'use strict';
// 使用 unsafeWindow 暴露,确保其他脚本(包括沙箱内)能访问 unsafeWindow.getPageContent = async function(path) { if (!path.startsWith('/')) path = '/' + path; const url = location.origin + path;
try { const resp = await fetch(url, { cache: 'no-store' }); if (!resp.ok) throw new Error(`HTTP ${resp.status}`); const html = await resp.text();
const match = html.match(/<textarea[^>]*class\s*=\s*["']content["'][^>]*>([\s\S]*?)<\/textarea>/i); if (match) { return match[1]; } else { throw new Error('未找到 content textarea'); } } catch (e) { console.error('❌ 获取页面内容失败:', e); return null; } };
console.log('📋 内容获取接口已加载,可用: unsafeWindow.getPageContent("/0")');})();```:::---- 普通类---### note.ms KYVS单页面覆盖 (需设置中心):::info[更新日志]>v4.3>--->- 新增更新日志::::::success[v4.3]>前置 $\footnotesize\mathbf{\colorbox{#cccccc}{\textcolor{#505050}{通用设置中心}}}$```js// ==UserScript==// @name note.ms KYVS单页面覆盖 (需设置中心)// @namespace http://tampermonkey.net/// @version 4.3// @author B站开元玩游戏// @match https://note.ms/*// @run-at document-end115 行未改动全部展开 });})();```:::### note.ms 批量循环覆盖 (需设置中心):::info[code]### note.ms KYVS批量循环覆盖 (需设置中心&内容接口):::info[更新日志]>v3.5>--->- 新增更新日志>- 根据新防火墙修复大部分区域覆盖失效的BUG>- 新增校验功能::::::success[v3.5]>前置 $\footnotesize\mathbf{\colorbox{#cccccc}{\textcolor{#505050}{通用设置中心}}}\mathbf{\colorbox{#555555}{\textcolor{#cccccc}{note.ms 内容获取接口}}}$```js// ==UserScript==// @name note.ms 批量循环覆盖 (需设置中心)// @name note.ms KYVS批量循环覆盖 (需设置中心&内容接口)// @namespace http://tampermonkey.net/// @version 2.3// @version 3.5// @author B站开元玩游戏// @match https://note.ms/*// @run-at document-end// @grant GM_setValue// @grant GM_getValue// @grant GM_registerMenuCommand// @grant GM_xmlhttpRequest// @grant unsafeWindow// ==/UserScript==
(function() { 'use strict';
// ---- 配置 ---- const scriptId = 'batch_cover'; const scriptId = 'batch_cover_verify'; const scriptName = '批量循环覆盖'; const defaultConfig = { pages: ['/0', '/1', '/2', '/3', '/4', '/5'], fillText: '关注B站开元玩游戏', normalDelay: 200, errorDelay: 10000 normalDelay: 500, errorDelay: 10000, verifyDelay: 1000, warmUpDelay: 300 }; const schema = { pages: { label: '页面列表 (逗号分隔)', type: 'array', default: ['/0', '/1', '/2', '/3', '/4', '/5'] }, fillText: { label: '填充内容', type: 'textarea', default: '关注B站开元玩游戏', rows: 4 }, normalDelay: { label: '成功延迟 (毫秒)', type: 'number', default: 200 }, errorDelay: { label: '错误延迟 (毫秒)', type: 'number', default: 10000 } pages: { label: '页面列表 (逗号分隔)', type: 'array', default: defaultConfig.pages }, fillText: { label: '填充内容', type: 'textarea', default: defaultConfig.fillText, rows: 4 }, normalDelay: { label: '成功延迟 (毫秒)', type: 'number', default: defaultConfig.normalDelay }, errorDelay: { label: '错误延迟 (毫秒)', type: 'number', default: defaultConfig.errorDelay }, verifyDelay: { label: '验证延迟 (毫秒)', type: 'number', default: defaultConfig.verifyDelay }, warmUpDelay: { label: '预热延迟 (毫秒)', type: 'number', default: defaultConfig.warmUpDelay } };
const INDEX_KEY = 'batch_cover_index';
// ---- 工具:GM_xmlhttpRequest 封装为 Promise ---- function gmRequest(method, url, data = null, headers = {}) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: method, url: url, headers: Object.assign({ 'Referer': url, 'Origin': location.origin, 'User-Agent': navigator.userAgent, 'X-Requested-With': 'XMLHttpRequest' }, headers), data: data, onload: (resp) => resolve(resp), onerror: (err) => reject(err) }); }); }
// ---- 获取页面内容(验证用) ---- async function getContent(path) { if (!path.startsWith('/')) path = '/' + path; const url = location.origin + path; try { const resp = await gmRequest('GET', url); if (resp.status !== 200) return null; const html = resp.responseText; const match = html.match(/<textarea[^>]*class\s*=\s*["']content["'][^>]*>([\s\S]*?)<\/textarea>/i); return match ? match[1] : null; } catch (_) { return null; } }
// ---- 预热(GET 建立会话) ---- async function warmUp(url) { try { await gmRequest('GET', url); } catch (_) {} }
// ---- 等待设置中心 ---- function waitForSettings(callback) { const win = (typeof unsafeWindow !== 'undefined') ? unsafeWindow : window; if (win.NoteMsSettings) { callback(win.NoteMsSettings); return; } let attempts = 0; const interval = setInterval(() => { attempts++; const w = (typeof unsafeWindow !== 'undefined') ? unsafeWindow : window; if (w.NoteMsSettings) { clearInterval(interval); callback(w.NoteMsSettings); } else if (attempts >= 50) { clearInterval(interval); console.error('❌ 设置中心未检测到'); alert('❌ 请先安装并启用“设置中心”脚本。'); } }, 100); }
waitForSettings((settings) => { settings.registerScript(scriptId, scriptName, defaultConfig, schema); console.log('✅ 批量循环覆盖注册成功');
let config = settings.getConfig(scriptId) || defaultConfig; let pages = config.pages || []; let currentIndex = parseInt(GM_getValue(INDEX_KEY, '0'), 10) % pages.length || 0; let running = false; let timer = null;
const reloadConfig = () => { const newConfig = settings.getConfig(scriptId) || defaultConfig; const newPages = newConfig.pages || []; if (newPages.length === 0) { console.warn('⚠️ 页面列表为空,停止'); stop(); return; } config = newConfig; pages = newPages; if (currentIndex >= pages.length) currentIndex = 0; console.log('🔄 配置已刷新:', pages.join(', ')); };
// ---- 核心覆盖流程(预热 + POST + 验证) ---- async function postContent() { if (!running || pages.length === 0) return; if (currentIndex >= pages.length) currentIndex = 0;
const target = pages[currentIndex]; const url = location.origin + target; const fillText = config.fillText || ''; const { normalDelay, errorDelay, verifyDelay, warmUpDelay } = config;
// 1. 预热 console.log(`🌐 预热 ${target} ...`); await warmUp(url); await new Promise(r => setTimeout(r, warmUpDelay));
// 2. POST 保存 console.log(`📤 覆盖 ${target} ...`); try { const postResp = await gmRequest('POST', url, '&t=' + encodeURIComponent(fillText), { 'Content-Type': 'application/x-www-form-urlencoded' }); if (postResp.status !== 200) { console.warn(`⚠️ ${target} HTTP ${postResp.status}`); scheduleNext(errorDelay); return; } console.log(`✅ ${target} HTTP 200`);
// 3. 验证 await new Promise(r => setTimeout(r, verifyDelay)); const currentContent = await getContent(target); if (currentContent === null) { console.warn(`⚠️ ${target} 读取失败,跳过验证`); moveToNext(normalDelay); return; } if (currentContent.trim() === fillText.trim()) { console.log(`✅ ${target} 验证通过`); moveToNext(normalDelay); } else { console.warn(`⚠️ ${target} 验证失败,${verifyDelay}ms后重试`); scheduleNext(verifyDelay); } } catch (err) { console.error(`❌ ${target} 网络错误:`, err); scheduleNext(errorDelay); } }
function moveToNext(delay) { const nextIndex = (currentIndex + 1) % pages.length; if (nextIndex === 0) reloadConfig(); currentIndex = nextIndex; GM_setValue(INDEX_KEY, currentIndex); console.log(`⏭️ 移动到 ${pages[currentIndex]}`); scheduleNext(delay); }
function scheduleNext(delay) { if (timer) clearTimeout(timer); timer = setTimeout(postContent, delay); }
function start() { if (running || pages.length === 0) return; running = true; console.log('▶️ 批量覆盖开始'); postContent(); }
function stop() { running = false; if (timer) { clearTimeout(timer); timer = null; } console.log('⏹️ 批量覆盖停止'); }
GM_registerMenuCommand('▶️ 批量覆盖开始', start); GM_registerMenuCommand('⏹️ 批量覆盖停止', stop); console.log(`📋 已就绪,延迟 ${config.normalDelay}ms`); });})();```:::### note.ms 轮回查询器 (需设置中心&内容接口):::info[更新日志]>v1.2>--->- 新增更新日志::::::success[v1.2]>前置 $\footnotesize\mathbf{\colorbox{#cccccc}{\textcolor{#505050}{通用设置中心}}}\mathbf{\colorbox{#555555}{\textcolor{#cccccc}{note.ms 内容获取接口}}}$```js// ==UserScript==// @name note.ms 轮回查询器 (需设置中心&内容接口)// @namespace http://tampermonkey.net/// @version 1.2// @author B站开元玩游戏// @match https://note.ms/*// @run-at document-end// @grant GM_setValue// @grant GM_getValue// @grant GM_registerMenuCommand// @grant unsafeWindow// ==/UserScript==
(function() { 'use strict';
const scriptId = 'round_query'; const scriptName = '轮回查询器'; const defaultConfig = { pages: ['/0', '/1', '/2', '/3', '/4', '/5'], interval: 3000, // 每轮之间的间隔(毫秒) requestDelay: 300 // 每个请求之间的间隔(毫秒) }; const schema = { pages: { label: '页面列表 (逗号分隔)', type: 'array', default: ['/0', '/1', '/2', '/3', '/4', '/5'] }, interval: { label: '轮询间隔 (毫秒)', type: 'number', default: 3000 }, requestDelay: { label: '请求间隔 (毫秒)', type: 'number', default: 300 } };
// ---- 获取内容接口 ---- function getPageContentInterface() { const win = (typeof unsafeWindow !== 'undefined') ? unsafeWindow : window; if (typeof win.getPageContent === 'function') { return win.getPageContent; } return null; }
// ---- 等待设置中心(同覆盖脚本) ---- function waitForSettings(callback) { let win = (typeof unsafeWindow !== 'undefined') ? unsafeWindow : window; console.log('🔍 检测设置中心,当前 win 对象:', win === window ? 'window' : 'unsafeWindow'); if (win.NoteMsSettings) { console.log('✅ 立即检测到设置中心');20 行未改动 }
waitForSettings(function(settings) { settings.registerScript(scriptId, scriptName, defaultConfig, schema); console.log('✅ 批量循环覆盖注册成功'); console.log('✅ 轮回查询器注册成功');
// ---- 配置变量(可动态刷新) ---- let config = settings.getConfig(scriptId) || defaultConfig; let pages = config.pages || []; let interval = config.interval || 3000; let requestDelay = config.requestDelay || 300;
// ---- 当前索引 ---- let currentIndex = parseInt(GM_getValue(INDEX_KEY, '0'), 10); if (currentIndex >= pages.length) currentIndex = 0; // 存储上次内容,用于检测变化 let lastContent = new Map();
// ---- 重载配置函数(每轮循环结束时调用) ---- // ---- 重载配置(每轮结束刷新) ---- function reloadConfig() { const newConfig = settings.getConfig(scriptId) || defaultConfig; const newPages = newConfig.pages || []; if (newPages.length === 0) { console.warn('⚠️ 新配置页面列表为空,停止运行'); console.warn('⚠️ 页面列表为空,停止查询'); stop(); return; } // 更新配置和页面列表 config = newConfig; pages = newPages; // 如果当前索引超出新列表长度,重置为0 if (currentIndex >= pages.length) { currentIndex = 0; GM_setValue(INDEX_KEY, currentIndex); } console.log('🔄 配置已刷新,当前页面列表:', pages.join(', ')); console.log(`📍 当前进度: ${pages[currentIndex]} (索引 ${currentIndex})`); interval = config.interval || 3000; requestDelay = config.requestDelay || 300; console.log('🔄 配置已刷新,页面列表:', pages.join(', ')); }
let running = false; let timer = null; let currentIndex = 0; // 当前轮次的位置
function postContent() { // ---- 查询单个页面 ---- async function queryPage(path) { const getPageContent = getPageContentInterface(); if (!getPageContent) { console.error('❌ getPageContent 接口未找到,请安装“内容获取接口”脚本'); return; } const content = await getPageContent(path); if (content === null) { console.warn(`⚠️ ${path} 获取失败`); return; } const previous = lastContent.get(path); if (previous !== content) { console.log(`🔄 ${path} 内容已变化`); console.log(`📄 ${path} 内容:\n${content}`); lastContent.set(path, content); } else { console.log(`✅ ${path} 无变化`); } }
// ---- 执行一轮查询(串行,带间隔) ---- async function roundQuery() { if (!running) return; if (pages.length === 0) { console.warn('⚠️ 页面列表为空,暂停'); console.warn('⚠️ 页面列表为空,停止'); stop(); return; } // 确保索引有效 if (currentIndex >= pages.length) { currentIndex = 0; GM_setValue(INDEX_KEY, currentIndex); } const target = pages[currentIndex]; const url = location.origin + target; const fillText = config.fillText || ''; const normalDelay = config.normalDelay || 200; const errorDelay = config.errorDelay || 10000;
console.log(`📤 正在覆盖 ${target} ...`); fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: '&t=' + encodeURIComponent(fillText) }) .then(response => { if (response.ok) { console.log(`✅ ${target} 保存成功,状态: ${response.status}`); moveToNext(normalDelay); } else if (response.status === 403) { console.warn(`⚠️ ${target} 限流 403,等待 ${errorDelay}ms 后重试当前页面`); scheduleNext(errorDelay); } else { console.warn(`⚠️ ${target} 其他错误: ${response.status},等待 ${errorDelay}ms 后重试`); scheduleNext(errorDelay); console.log(`⏳ 开始一轮查询,共 ${pages.length} 个页面,请求间隔 ${requestDelay}ms`); const startTime = Date.now(); for (let i = 0; i < pages.length; i++) { const path = pages[i]; await queryPage(path); // 如果不是最后一个,等待 requestDelay if (i < pages.length - 1) { await new Promise(r => setTimeout(r, requestDelay)); } }) .catch(err => { console.error(`❌ ${target} 网络错误:`, err, `,等待 ${errorDelay}ms 后重试`); scheduleNext(errorDelay); }); }
function moveToNext(delay) { // 检查是否完成一轮循环(即下一个索引是 0) const nextIndex = (currentIndex + 1) % pages.length; if (nextIndex === 0) { // 🎯 一轮结束,刷新配置 reloadConfig(); // 刷新后,从新列表的第一个开始 currentIndex = 0; } else { currentIndex = nextIndex; } GM_setValue(INDEX_KEY, currentIndex); console.log(`⏭️ 移动到下一个: ${pages[currentIndex]}`); scheduleNext(delay); const elapsed = Date.now() - startTime; console.log(`✅ 本轮查询完成,耗时 ${elapsed}ms`); // 一轮结束,刷新配置(轮询时配置可能改变) reloadConfig(); // 安排下一轮 if (running) { timer = setTimeout(() => { roundQuery(); }, interval); } }
function scheduleNext(delay) { if (timer) clearTimeout(timer); timer = setTimeout(postContent, delay); }
// ---- 启动/停止 ---- function start() { if (running) return; if (pages.length === 0) { console.warn('⚠️ 页面列表为空,无法启动'); return; } running = true; console.log('▶️ 批量循环覆盖开始'); postContent(); console.log(`▶️ 轮回查询器启动,轮询间隔 ${interval}ms,请求间隔 ${requestDelay}ms`); // 清空上次内容缓存,以便重新检测变化 lastContent.clear(); // 立即执行第一轮 roundQuery(); }
function stop() { running = false; if (timer) { clearTimeout(timer); timer = null; } console.log('⏹️ 批量循环覆盖停止'); if (timer) { clearTimeout(timer); timer = null; } console.log('⏹️ 轮回查询器停止'); }
GM_registerMenuCommand('▶️ 批量覆盖开始', start); GM_registerMenuCommand('⏹️ 批量覆盖停止', stop); GM_registerMenuCommand('▶️ 轮回查询开始', start); GM_registerMenuCommand('⏹️ 轮回查询停止', stop);
console.log('📋 批量循环覆盖已就绪,每轮循环结束后会自动刷新配置。'); console.log(`📌 当前配置: 页面列表 [${pages.join(', ')}], 延迟 ${config.normalDelay}ms`); console.log('📋 轮回查询器已就绪,每轮结束后自动刷新配置。'); console.log(`📌 当前配置: 页面 [${pages.join(', ')}], 轮询间隔 ${interval}ms, 请求间隔 ${requestDelay}ms`); });})();```:::
# [:===:收藏:===:]# 单一网站## luogu.com & luogu.com.cn---- 普通类---### 洛谷随机跳题:::info[code]:::success[v1.0]**仅收藏,[原位置见此](https://www.luogu.me/article/0v7tv27r),此为在线版**```js/*MIT License1,104 行未改动全部展开