Skip to content

Instantly share code, notes, and snippets.

@bastsoft
Last active October 5, 2018 14:33
Show Gist options
  • Save bastsoft/71b7cf053e783251b10e5141daea8e9e to your computer and use it in GitHub Desktop.
Save bastsoft/71b7cf053e783251b10e5141daea8e9e to your computer and use it in GitHub Desktop.
btr.loadGist({ url: 'https://gist.github.com/', id: '71b7cf053e783251b10e5141daea8e9e'}, function(){
btr.contextMenu('body', {
showTranslateCode : btr.functionGist('translate.js')
});
alert('done');
});
var i18nWord = {};
function enumNodes(node) {
while (node) {
console.log(i18nWord, node.innerText);
if (i18nWord[node.innerText]) {
node.innerHTML = i18nWord[node.innerText];
};
enumNodes(node.firstChild);
node = node.nextSibling;
};
};
$.getJSON('/js/translation/en.js').then(function (i18nJson) {
Object.keys(i18nJson.messages).forEach((key) => {
i18nWord[i18nJson.messages[key]] = key;
});
console.log(i18nWord);
enumNodes(document.body, i18nWord);
})
@bastsoft
Copy link
Author

bastsoft commented Oct 5, 2018

javascript:(function(){%20%20%20%20var%20el%20=%20document.createElement('script');%20%20%20%20el.onload%20=%20el.onreadystatechange%20=%20function%20()%20{%20%20%20%20%20%20%20%20if%20(el.readyState%20&&%20el.readyState%20!==%20"complete"%20&&%20el.readyState%20!==%20"loaded")%20{%20%20%20%20%20%20%20%20%20%20%20%20return%20false;%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20btr.loadGist({%20id:%20'71b7cf053e783251b10e5141daea8e9e',%20file:%20'main.js'%20});%20%20%20%20};%20%20%20%20document.getElementsByTagName('head')[0].appendChild(el).src%20=%20'https://cdn.rawgit.com/bastsoft/btr/v0.1.0/btr.js';})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment