替换<code>让谷歌翻译更准确

try to take over the world!

目前為 2022-10-24 提交的版本,檢視 最新版本

// ==UserScript==
// @name         替换<code>让谷歌翻译更准确
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  try to take over the world!
// @author       You
// @match        http://*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
     'use strict';
             setTimeout(()=>{
   Array.from(document.getElementsByTagName('code')).forEach(code=>{
                    const isLongCode = code.offsetWidth > 200
                    //document.documentElement.offsetWidth/3
                    if (!isLongCode) {
                        const span = document.createElement('span')
                        span.textContent = code.textContent
                        span.style.cssText = "background-color: #f1f1f1;";
                        code.parentNode.insertBefore(span, code)
                        code.parentElement.removeChild(code)
                    }
                }
                )

    console.log('替换<code>完成')

},1000)
                // Your code here...
})();
// @license MIT

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址