Last active
March 7, 2022 03:34
-
-
Save abel533/5839d3eca4686646baba113fc47e9b22 to your computer and use it in GitHub Desktop.
浏览器翻译时排除代码片段
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name notranslate | |
// @namespace https://gist.github.com/abel533/5839d3eca4686646baba113fc47e9b22 | |
// @version 1.0 | |
// @description 浏览器翻译时排除代码片段 | |
// @author isea533 | |
// @match *://**/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.addEventListener('load', function() { | |
noTranslate(document.getElementsByTagName('pre')); | |
noTranslate(document.getElementsByClassName('gist')); | |
noTranslate(document.getElementsByClassName('CodeMirror-code')); | |
}, false); | |
function noTranslate(items) { | |
if(items && items.length > 0) { | |
for(var i = 0; i < items.length; i++) { | |
items[i].classList.add('notranslate'); | |
} | |
} | |
} | |
})(); |
vace
commented
Dec 21, 2021
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment