Created
September 11, 2020 21:30
-
-
Save lzcjames/be242079337a42a196216c6e6cd8109a to your computer and use it in GitHub Desktop.
This file contains 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 Translation | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match */* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function textNodesUnder(el){ | |
var n, a=[], walk=document.createTreeWalker(el,NodeFilter.SHOW_TEXT,null,false); | |
while(n=walk.nextNode()) { | |
var newNode = document.createElement("p"); | |
newNode.setAttribute("class","notranslate"); | |
newNode.textContent = n.textContent; | |
n.parentNode.insertBefore(newNode, n); | |
//a.push(n); | |
} | |
//return (a); | |
} | |
var body = document.getElementsByTagName('body')[0]; | |
textNodesUnder(body); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment