Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==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