// ==UserScript== // @name 批改网解除粘贴限制 // @namespace http://tampermonkey.net/ // @version 9.1 // @description 解锁禁用的作文文本框,自动填充并提交(回车) // @author Rito // @match *://*.pigai.org/* // @match *://pigai.org/* // @grant none // ==/UserScript== (function () { 'use strict'; // 在此粘贴你的作文文本 const MY_TEXT = `Chinese Consumers and the Transforming Luxury Market The graph illustrates that Chinese consumers' share of the global luxury market rose from 12% in 2008 to 46% in 2025, while the total market value expanded from 1,263 to 4,700 billion RMB. This demonstrates that Chinese buyers have become the main driving force behind the growth of the luxury market. Many youngsters prefer "quiet luxury," which refers to high quality without evident logos. Yet others still choose famous brands like LV or Gucci to display their status. On Xiaohongshu, both styles are prevalent. For instance, a post about a minimalist handbag from a Chinese designer once received more than 100,000 likes, while logo bags continue to attract attention. Some brands, such as Dior, even launch special editions for Chinese festivals, showing their respect for local culture. In the end, Chinese consumers are not only purchasing more but also reshaping the meaning of luxury. Their preferences, tastes, and even disagreements are influencing the future direction of fashion.`; // 可能的提交按钮选择器(按页面实际改动) const SUBMIT_SELECTORS = [ '#submit', // 常见 id 'button[type="submit"]', '.btn-submit', 'input[type="submit"]', 'a.submit' ]; // 解除页面全局复制/粘贴/选择限制(保险) const freeGlobal = () => { const props = ['oncopy', 'onpaste', 'oncut', 'onselectstart', 'oncontextmenu', 'ondragstart']; props.forEach(p => { document[p] = null; document.body && (document.body[p] = null); }); document.body && (document.body.style.userSelect = 'text'); }; // 尝试找到 textarea(考虑 iframe 或动态渲染) const findTextarea = (root = document) => { return root.querySelector('#contents.from_contents, #contents, textarea#from_contents, textarea[name="contents"]'); }; // 解除禁用并填充 const unlockAndFill = (ta, text) => { // 移除禁用与阻断属性 ['disabled', 'readonly', 'onpaste', 'oncopy', 'oncut', 'onselectstart'].forEach(attr => ta.removeAttribute(attr)); ta.disabled = false; ta.readOnly = false; // 允许选择与输入 ta.style.userSelect = 'text'; ta.style.pointerEvents = 'auto'; // 写入文本 ta.value = text; // 触发事件,让页面识别变更 ta.dispatchEvent(new Event('input', { bubbles: true })); ta.dispatchEvent(new Event('change', { bubbles: true })); // 模拟按键(Enter) const keydownEnter = new KeyboardEvent('keydown', { bubbles: true, cancelable: true, key: 'Enter', code: 'Enter', keyCode: 13, which: 13 }); ta.dispatchEvent(keydownEnter); const keyupEnter = new KeyboardEvent('keyup', { bubbles: true, cancelable: true, key: 'Enter', code: 'Enter', keyCode: 13, which: 13 }); ta.dispatchEvent(keyupEnter); }; // 尝试点击提交按钮 const trySubmit = () => { for (const sel of SUBMIT_SELECTORS) { const btn = document.querySelector(sel); if (btn) { btn.click(); return true; } } return false; }; // 处理可能存在的 iframe const forAllFrames = (fn) => { try { fn(document); const iframes = document.querySelectorAll('iframe'); iframes.forEach(iframe => { try { const doc = iframe.contentDocument || iframe.contentWindow?.document; if (doc) fn(doc); } catch (e) { /* 跨域忽略 */ } }); } catch (e) { /* 忽略 */ } }; // 核心流程:解锁、填充、提交 const run = () => { freeGlobal(); forAllFrames((root) => { let ta = findTextarea(root); if (!ta) return; unlockAndFill(ta, MY_TEXT); // 若页面监听 form 提交,尝试找到所在表单并提交 const form = ta.closest('form'); if (form) { // 触发 submit 事件 const ok = form.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true })); if (ok) { form.submit?.(); } } else { // 尝试点击页面提交按钮 trySubmit(); } }); }; // 页面就绪后执行,多次重试应对异步渲染 const start = () => { let tries = 0; const maxTries = 20; const timer = setInterval(() => { tries++; run(); // 如果找到了并填充,或者达到最大尝试次数就停 const ta = findTextarea(document); if ((ta && ta.value && ta.value.trim().length > 0) || tries >= maxTries) { clearInterval(timer); } }, 500); }; // MutationObserver:如果页面后续替换/重绘 textarea,自动再次填充 const observe = () => { const mo = new MutationObserver(() => { const ta = findTextarea(document); if (ta && (!ta.value || ta.value.trim().length === 0)) { unlockAndFill(ta, MY_TEXT); } }); mo.observe(document.documentElement, { childList: true, subtree: true }); }; // 提供一个快捷键:Ctrl+Shift+Enter 手动触发一次(可选) const hotkey = () => { document.addEventListener('keydown', (e) => { if (e.ctrlKey && e.shiftKey && e.key === 'Enter') { e.preventDefault(); run(); } }, true); }; // 初始化 window.addEventListener('load', () => { start(); observe(); hotkey(); console.log('Ready: auto-fill engine initialized.'); }); })();