// ==UserScript== // @name 公式翻译保留 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 网页翻译时,保留公式 // @author GShang // @require http://cdn.staticfile.org/jquery/1.8.3/jquery.min.js // @grant GM_getResourceURL // @grant unsafeWindow // @grant GM_setClipboard // @include https://www.sciencedirect.com/* // @include https://ieeexplore.ieee.org/* // @grant GM_getResourceURL // @grant GM_xmlhttpRequest // @grant GM_getResourceText // @grant GM_getValue // @grant GM_setValue // @grant GM_download // @grant GM_addStyle // @grant GM_openInTab // @noframes Chrome // @compatible Chrome // @compatible Firefox // @compatible Edge // @compatible Safari // @compatible Opera // @compatible UC // @license GPL3 license // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 带有公式的元素 const mathElement ='math, .math, .MathJax'; // 添加按钮 var mathBtn = ''; $('body').append(mathBtn); // 添加样式 GM_addStyle('#math-btn {background:#ff3500;padding:10px 20px;color:#fff;border-radius:40px 0 0 40px;position:fixed;right:0px;top:50vh;z-index:99999999999999;border:none;height:fit-content;outline:none;cursor:grab}'); // 点击按钮,添加翻译保留属性 $('#math-btn').click(function(){ if($(mathElement).length > 0){ // console.log('该页面存在公式!'); // alert('该页面存在公式!'); $(mathElement).attr('translate','no'); alert('公式已被保留!'); }else{ console.log('未发现公式!'); alert('未发现公式!'); } }) // Your code here... })();