您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Click to copy equation in Wikipedia and Zhihu
// ==UserScript== // @name CSND latex公式复制 // @namespace http://tampermonkey.net/ // @version 0.2 // @description Click to copy equation in Wikipedia and Zhihu // @author curious // @match https://blog.csdn.net/*/article/* // @grant none // @license MIT // ==/UserScript== const reverseMatchUntilNewline = function(inputString) { let i = inputString.length - 1; for (; i >= 0; i--) { if (inputString[i] === '\n') { // 遇到换行符时停止匹配 break; } } return inputString.substring(i).trim(); }; function edit_latex() { let eqs = document.querySelectorAll(".katex"); // console.log(eqs); for (let i = 0; i < eqs.length; i++) { let latex = ''; // 检查是否存在 <annotation> 标签 let annotation = eqs[i].querySelector('annotation'); if (annotation) { console.log('latex:annotation'); latex = '$' + annotation.textContent.trim() + '$'; annotation.textContent = latex; } else { // 如果没有找到 <annotation>,可能需要更复杂的处理来从 HTML 转换回 LaTeX let kmathml = eqs[i].querySelector('.katex-mathml') latex = '$ ' + reverseMatchUntilNewline(kmathml.textContent.trim()) + ' $' kmathml.textContent = latex; } eqs[i].textContent = latex; } } document.addEventListener('scroll', edit_latex); (window.onload = function () { 'use strict'; setTimeout(function () { edit_latex(); }, 3000); })
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址