Chrome - No Google Translate Popup

Remove the original text popup when using Chrome's built in translation feature

  1. // ==UserScript==
  2. // @name Chrome - No Google Translate Popup
  3. // @version 0.2a
  4. // @namespace pk.qwerty12
  5. // @description Remove the original text popup when using Chrome's built in translation feature
  6. // @include http*
  7. // @grant GM_addStyle
  8. // ==/UserScript==
  9.  
  10. function injectCSS() {
  11. // CSS taken from OBender: http://stackoverflow.com/a/8531408
  12. const css = ".goog-tooltip { display: none !important; } .goog-tooltip:hover { display: none !important; } .goog-text-highlight { background-color: transparent !important; border: none !important; box-shadow: none !important; }";
  13. GM_addStyle(css);
  14. }
  15.  
  16. var observer = new MutationObserver(function(mutations) {
  17. mutations.forEach(function(mutation) {
  18. for (var i = 0; i < mutation.addedNodes.length; ++i) {
  19. if (mutation.addedNodes[i].nodeType == 1 && mutation.addedNodes[i].id === "goog-gt-tt") {
  20. injectCSS();
  21. break;
  22. }
  23. }
  24. });
  25. });
  26. setTimeout(function() {
  27. observer.observe(document.body, {
  28. childList: true
  29. })
  30. }, 100);