版本比较
一些脚本
正文
增加 161 行删除 103 行
123455678910111112131415161718192021222324252627246 行未改动全部展开27427527627726627827928028128228328428528628736 行未改动324325326327311328329330331332333334335336337120 行未改动全部展开458459460461440441442462463464465466467468469470471472473474445475476447477478479480481482483484485486487488489490491460492493494495496465466497498499500501502469470471472503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553479480554555482556557558559487560561490491562563564493494495496497565566567499500568569570571572573505574575576577509578579580581582583513514515516517518584585586587522588589590591526592593529530531532533534535536594595596597538539598599600601602541542543544545546547548549550551552603604605556557606607559560561562563564565566567568569570608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637573574638639640576577578641642643580644645646647584648586587588589590591592593649650651595652653654655656657658659660661605606607608609662663611664665666667668669670618671672673674675623624625676677678679680681631682683684685686687688689690691179 行未改动全部展开8718728738748758768778788798808818248828838848858861,104 行未改动全部展开审核大大放我一马吧😭
**欢迎关注本人B站账号[开元玩游戏](https://space.bilibili.com/3546719373494519),冲刺100粉!**
*~~大部分js为AI生成,保证本人贡献大于AI,我贡献的提示词比AI生成量还多,所有总量也有个至少1亿token了~~**~~大部分js为AI生成,保证本人贡献大于AI,我贡献的提示词比AI生成量还多,所有总量也有个至少4亿token了~~*# [:===:原创:===:]# 通用---- 前置类- ---### 通用设置中心:::info[展开]:::info[更新日志]>v1.3.0>--->更改版本计数方式>>更改API名字
>v1.2>--->- 新增更新日志::::::success[v1.2]```js// ==UserScript==// @name 通用设置中心// @namespace http://tampermonkey.net/246 行未改动全部展开---- 前置类---### note.ms 内容获取接口:::info[展开]:::info[更新日志]>v1.1>--->- 新增更新日志::::::success[v1.1]```js// ==UserScript==// @name note.ms 内容获取接口// @namespace http://tampermonkey.net/36 行未改动---- 普通类---### note.ms KYVS单页面覆盖 (需设置中心):::info[展开]:::info[更新日志]>v4.3>--->- 新增更新日志::::::success[v4.3]>前置 $\footnotesize\mathbf{\colorbox{#cccccc}{\textcolor{#505050}{通用设置中心}}}$```js// ==UserScript==// @name note.ms KYVS单页面覆盖 (需设置中心)120 行未改动全部展开 });})();```:::### note.ms KYVS批量循环覆盖 (需设置中心):::info[展开]>前置 $\footnotesize\mathbf{\colorbox{#cccccc}{\textcolor{#505050}{通用设置中心}}}$### 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 KYVS批量循环覆盖 (需设置中心)// @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) { let win = (typeof unsafeWindow !== 'undefined') ? unsafeWindow : window; console.log('🔍 检测设置中心,当前 win 对象:', win === window ? 'window' : 'unsafeWindow'); const win = (typeof unsafeWindow !== 'undefined') ? unsafeWindow : window; if (win.NoteMsSettings) { console.log('✅ 立即检测到设置中心'); callback(win.NoteMsSettings); return; } let attempts = 0; const maxAttempts = 50; const interval = setInterval(() => { attempts++; win = (typeof unsafeWindow !== 'undefined') ? unsafeWindow : window; if (win.NoteMsSettings) { const w = (typeof unsafeWindow !== 'undefined') ? unsafeWindow : window; if (w.NoteMsSettings) { clearInterval(interval); console.log(`✅ 第 ${attempts} 次检测到设置中心`); callback(win.NoteMsSettings); return; } if (attempts >= maxAttempts) { callback(w.NoteMsSettings); } else if (attempts >= 50) { clearInterval(interval); console.error('❌ 等待超时,未检测到设置中心'); alert('❌ 错误:未检测到“设置中心”脚本,请先安装并启用 Note.ms 设置中心。'); console.error('❌ 设置中心未检测到'); alert('❌ 请先安装并启用“设置中心”脚本。'); } }, 100); }
waitForSettings(function(settings) { 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;
// ---- 当前索引 ---- let currentIndex = parseInt(GM_getValue(INDEX_KEY, '0'), 10); if (currentIndex >= pages.length) currentIndex = 0;
// ---- 重载配置函数(每轮循环结束时调用) ---- function reloadConfig() { const 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})`); } if (currentIndex >= pages.length) currentIndex = 0; console.log('🔄 配置已刷新:', pages.join(', ')); };
let running = false; let timer = null; // ---- 核心覆盖流程(预热 + POST + 验证) ---- async function postContent() { if (!running || pages.length === 0) return; if (currentIndex >= pages.length) currentIndex = 0;
function postContent() { if (!running) return; if (pages.length === 0) { 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; const { normalDelay, errorDelay, verifyDelay, warmUpDelay } = config;
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 后重试当前页面`); // 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} 其他错误: ${response.status},等待 ${errorDelay}ms 后重试`); scheduleNext(errorDelay); console.warn(`⚠️ ${target} 验证失败,${verifyDelay}ms后重试`); scheduleNext(verifyDelay); } }) .catch(err => { console.error(`❌ ${target} 网络错误:`, err, `,等待 ${errorDelay}ms 后重试`); } catch (err) { console.error(`❌ ${target} 网络错误:`, err); scheduleNext(errorDelay); }); } }
function moveToNext(delay) { // 检查是否完成一轮循环(即下一个索引是 0) const nextIndex = (currentIndex + 1) % pages.length; if (nextIndex === 0) { // 🎯 一轮结束,刷新配置 reloadConfig(); // 刷新后,从新列表的第一个开始 currentIndex = 0; } else { currentIndex = nextIndex; } if (nextIndex === 0) reloadConfig(); currentIndex = nextIndex; GM_setValue(INDEX_KEY, currentIndex); console.log(`⏭️ 移动到下一个: ${pages[currentIndex]}`); console.log(`⏭️ 移动到 ${pages[currentIndex]}`); scheduleNext(delay); }
function scheduleNext(delay) { if (timer) clearTimeout(timer); timer = setTimeout(postContent, delay); }
function start() { if (running) return; if (pages.length === 0) { console.warn('⚠️ 页面列表为空,无法启动'); return; } if (running || pages.length === 0) return; running = true; console.log('▶️ 批量循环覆盖开始'); console.log('▶️ 批量覆盖开始'); postContent(); }
function stop() { running = false; if (timer) { clearTimeout(timer); timer = null; } console.log('⏹️ 批量循环覆盖停止'); console.log('⏹️ 批量覆盖停止'); }
GM_registerMenuCommand('▶️ 批量覆盖开始', start); GM_registerMenuCommand('⏹️ 批量覆盖停止', stop);
console.log('📋 批量循环覆盖已就绪,每轮循环结束后会自动刷新配置。'); console.log(`📌 当前配置: 页面列表 [${pages.join(', ')}], 延迟 ${config.normalDelay}ms`); console.log(`📋 已就绪,延迟 ${config.normalDelay}ms`); });})();```:::### note.ms 轮回查询器 (需设置中心&内容接口):::info[展开]:::info[更新日志]>v1.2>--->- 新增更新日志::::::success[v1.2]>前置 $\footnotesize\mathbf{\colorbox{#cccccc}{\textcolor{#505050}{通用设置中心}}}\mathbf{\colorbox{#555555}{\textcolor{#cccccc}{note.ms 内容获取接口}}}$```js// ==UserScript==179 行未改动全部展开})();```:::
# [:===:收藏:===:]# 单一网站## luogu.com & luogu.com.cn---- 普通类---### 洛谷随机跳题:::info[展开]:::success[v1.0]**仅收藏,[原位置见此](https://www.luogu.me/article/0v7tv27r),此为在线版**```js/*MIT License1,104 行未改动全部展开