Skip to content

Instantly share code, notes, and snippets.

@lzcjames
Created September 11, 2020 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lzcjames/be242079337a42a196216c6e6cd8109a to your computer and use it in GitHub Desktop.
Save lzcjames/be242079337a42a196216c6e6cd8109a to your computer and use it in GitHub Desktop.
// ==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