您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
防止自动翻译数学公式、表格、图表等复杂内容
当前为
- // ==UserScript==
- // @name Disable Auto Translation for Specific Elements
- // @namespace http://1998x-stack.github.io
- // @version 1.0
- // @description 防止自动翻译数学公式、表格、图表等复杂内容
- // @author XM
- // @match *://*/*
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- /**
- * 给指定的元素及其子元素添加translate属性
- * @param {NodeListOf<Element>} elements - 需要处理的元素列表
- */
- function addTranslateNoToElements(elements) {
- elements.forEach(element => {
- element.setAttribute('translate', 'no');
- // 获取该元素的所有子元素并添加translate属性
- const childTags = element.getElementsByTagName('*');
- Array.from(childTags).forEach(tag => {
- tag.setAttribute('translate', 'no');
- });
- });
- }
- // 获取所有需要添加translate属性的元素
- const mathElems = document.querySelectorAll('.ltx_Math, .ltx_equationgroup, .ltx_equation, .ltx_figure, .ltx_table');
- const captionElems = document.querySelectorAll('.ltx_caption.ltx_centering');
- // 给这些元素及其子元素添加translate="no"属性
- addTranslateNoToElements(mathElems);
- addTranslateNoToElements(captionElems);
- })();