跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
MediaWiki帮助
根类
所有页面
统计信息
分类树
特殊页面
FC
搜索
搜索
外观
登录
个人工具
登录
查看“︁Chrome浏览器翻译规避代码”︁的源代码
页面
讨论
简体中文
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
页面信息
外观
移至侧栏
隐藏
←
Chrome浏览器翻译规避代码
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
使用油猴新建一个脚本输入以下内容保存<syntaxhighlight lang="js"> // ==UserScript== // @name 谷歌翻译绕过代码块 // @namespace http://tampermonkey.net/ // @version 0.4 // @description 让谷歌翻译插件翻译网页的时候,绕过代码块和一些无需翻译的元素 // @author xiandan // @homeurl https://github.com/xiandanin/LardMonkeyScripts // @match https://github.com/* // @match https://npmjs.com/* // @match https://stackoverflow.com/* // @match https://*.google.com/* // @match https://jmespath.org/* // @license MIT // @grant none // ==/UserScript== /*jshint esversion: 6 */ (function () { 'use strict' function noTranslate (array) { array.forEach((name) => { [...document.querySelectorAll(name)].forEach(node => { if (node.className.indexOf('notranslate') === -1) { node.classList.add('notranslate') } }) }) } const bypassSelectorArray = [ 'pre' ] if (window.location.hostname.indexOf("github") !== -1) { // 如果是github 还需要处理一些别的元素 const githubSelector = [ '#repository-container-header > div:nth-child(1)', 'summary.btn.css-truncate', '.commit-author', '.js-navigation-open.link-gray-dark', '.Box-title', '.BorderGrid-cell > div.mt-3 > a.Link--muted', '.BorderGrid-cell > a[data-pjax="#repo-content-pjax-container"] > div > div:first-child', '.BorderGrid-cell > ul.list-style-none', 'div[role="rowheader"]' ] bypassSelectorArray.push.apply(bypassSelectorArray, githubSelector) //如果还有github的插件 还需要延迟追加一些 setTimeout(function () { const githubPluginSelector = [ '.github-repo-size-div', '.octotree-tree-view' ] noTranslate(githubPluginSelector) }, 3000) } noTranslate(bypassSelectorArray) })() </syntaxhighlight>脚本 match 内添加需要生效的网站,然后点击文件,保存。 刷新网页,即可体验。 [[分类:Chrome]]
返回
Chrome浏览器翻译规避代码
。
搜索
搜索
查看“︁Chrome浏览器翻译规避代码”︁的源代码
添加话题