版本比较
军火库说是
正文
增加 128 行删除 7 行
596 行未改动全部展开59759859960060160260360160260360460560682 行未改动68969069169269469569669369469569669769842 行未改动741742743744747745746747748749263 行未改动全部展开10131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143138 行未改动全部展开596 行未改动全部展开```:::::::::::success[插件]:::info[1]不是我写的。统计洛谷 IDE 中代码的码量。```java:::info[code]```js// ==UserScript==// @name 洛谷 IDE 代码全量统计 (注入底层版)// @namespace http://tampermonkey.net/// @version 2.082 行未改动
})();```::::::info[2]搞 `anti-ai[]` 的。```java:::info[anti-ai]```js// ==UserScript==// @name Luogu 反隐藏内容高亮显示// @namespace http://tampermonkey.net/// @version 1.042 行未改动```::::::info[3]放烟花。```java```js// ==UserScript==// @name Firework Confetti Click & Drag Effect// @namespace http://tampermonkey.net/// @version 1.5.0263 行未改动全部展开 }})();```::::::info[验证码]```js// ==UserScript==// @name 洛谷验证码自动识别并填写 (优化版)// @namespace https://github.com/mayoi-Akira// @version 0.2.1// @description 使用卷积神经网络训练的验证码识别模型,自动识别填写洛谷提交时的验证码// @match *://www.luogu.com.cn/*// @icon https://www.luogu.com.cn/favicon.ico// @grant GM_xmlhttpRequest// @author Akira// @license MIT// ==/UserScript==
(() => { const server = "http://8.130.64.15:3636";
const canvas = document.createElement("canvas"); const ctx = canvas.getContext("2d");
function recognize(img, callback) { canvas.width = img.naturalWidth; canvas.height = img.naturalHeight; ctx.drawImage(img, 0, 0); const data = canvas.toDataURL("image/jpeg").split(",")[1];
GM_xmlhttpRequest({ method: "POST", url: server, headers: { "Content-Type": "application/json" }, data: JSON.stringify({ image: data }), onload: (resp) => { try { const { prediction } = JSON.parse(resp.responseText); callback(prediction); } catch (e) { console.error("OCR 获取失败", e); callback(""); } }, onerror: (err) => { console.error("OCR 请求失败", err); callback(""); }, timeout: 5000, }); }
const handleImage = (img) => { // 检查是否正在识别或已识别当前 src,避免高频/重复发包 if (img.dataset.ocrSrc === img.src || img.dataset.ocrProcessing === "true") { return; }
const input = document.querySelector('input[placeholder*="验证码"]'); if (!input) { console.warn("未找到输入框"); return; }
// 设置状态锁 img.dataset.ocrProcessing = "true";
const run = () => { recognize(img, (text) => { // 标记该 src 已成功识别 img.dataset.ocrSrc = img.src; delete img.dataset.ocrProcessing;
if (text) { input.value = text; input.dispatchEvent(new Event("input", { bubbles: true })); input.dispatchEvent(new Event("change", { bubbles: true })); } }); };
if (img.complete && img.naturalWidth > 0) { run(); } else { img.onload = run; } };
const observer = new MutationObserver((mutations) => { for (const m of mutations) { if (m.type === "childList") { m.addedNodes.forEach((node) => { if (node.nodeType === Node.ELEMENT_NODE) { if (node.nodeName === "IMG" && node.src && node.src.includes("captcha")) { handleImage(node); } const imgs = node.querySelectorAll('img[src*="captcha"]'); imgs.forEach(handleImage); } }); } else if ( m.type === "attributes" && m.target.nodeName === "IMG" && m.target.src.includes("captcha") ) { handleImage(m.target); } } });
const root = document.querySelector("#captcha-container") || document.body;
// 关键优化:指定 attributeFilter 为 ['src'],仅在图片地址更新时触发 observer.observe(root, { childList: true, subtree: true, attributes: true, attributeFilter: ["src"] });
const existingImg = document.querySelector('img[src*="captcha"]'); if (existingImg) { handleImage(existingImg); }})();```:::::::::::success[工具]:::info[文本加密&解密]```cpp138 行未改动全部展开