Kawiesh

Instant Google Translate

Jun 5th, 2021 (edited)
750
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let script= document.createElement("script");
  2. script.type= "text/javascript";
  3. script.src= "https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit";
  4. document.body.append(script);
  5.  
  6. let exists= document.querySelector("#kdtranslatekd");
  7. let div=document.createElement("div");
  8. div.id= "kdtranslatekd";
  9. div.style.display= "none";
  10.  
  11. if(exists){
  12. exists.remove();
  13. document.body.firstChild.before(div);
  14. }
  15. else{
  16. document.body.firstChild.before(div);
  17. }
  18.  
  19. let translate= document.createElement("script");
  20. translate.type= "text/javascript";
  21. translate.innerHTML=`
  22. function googleTranslateElementInit(){
  23. new google.translate.TranslateElement(
  24. {pageLanguage:""},"kdtranslatekd");}`;
  25.  
  26. document.body.append(translate);
RAW Paste Data