您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Typesetting the contents of the clipboard
当前为
// ==UserScript== // @name Latex_Automatic Formatting // @namespace http://tampermonkey.net/ // @version 0.2 // @description Typesetting the contents of the clipboard // @author Mozikiy // @match http://annot.xhanz.cn/project/*/* // @icon https://www.latex-project.org/favicon.ico // @license GNU GPLv3 // @grant none // ==/UserScript== (function() { 'use strict'; // 定义标点转换的函数 function convertPunctuation(text) { return text .replace(/(?<=[^a-zA-Z0-9]) /g, '$\\underline { \\hspace{1cm} }$') .replace(/,/g, ', ') .replace(/\./g, '. ') .replace(/,/g, ', ') .replace(/。/g, '. ') .replace(/>/g, '>') .replace(/</g, '<') .replace(/λ/g, '$\\lambda$') .replace(/α/g, '$\\alpha$') .replace(/β/g, '$\\beta$') .replace(/γ/g, '$\\gamma$') .replace(/ρ/g, '$\\rho$') .replace(/σ/g, '$\\sigma$') .replace(/δ/g, '$\\delta$') .replace(/φ/g, '$\\varphi$') .replace(/:/g, ': ') .replace(/⋯/g, '\\cdots') .replace(/x,/g, '$x$,') .replace(/\|/g, '\\vert') .replace(/(/g, '(') .replace(/)/g, ')') .replace(/[/g, '[') .replace(/]/g, ']') .replace(/C02/g, '$CO_2$') .replace(/H2O/g, '$H_2O$') .replace(/CO2/g, '$CO_2$') .replace(/H20/g, '$H_2O$') .replace(/,,/g, ', ') .replace(/\.\./g, '. ') .replace(/, ,/g, ', ') .replace(/\. \./g, '. '); } // 检测剪贴板复制事件并处理内容 document.addEventListener('copy', async function(event) { try { // 获取剪贴板内容 const clipboardText = await navigator.clipboard.readText(); // 处理剪贴板内容 const processedText = clipboardText .split('\n') .map(line => convertPunctuation(line)) .join('\n'); // 写回剪贴板 await navigator.clipboard.writeText(processedText); console.log("Processed text written back to clipboard!"); } catch (error) { console.error("Error processing clipboard text:", error); } }); console.log("Latex_Automatic Formatting script initialized!"); })();