Advertisement
geraldandy

Hide Romanization in Google Translate

Nov 27th, 2024
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Hide Romanization in Google Translate
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Hide the romanization text in Google Translate
  6. // @author You
  7. // @match https://translate.google.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to hide romanization by targeting the element
  15. function hideRomanization() {
  16. const romanizedTextElements = document.querySelectorAll('.kO6q6e'); // Adjust this if needed
  17. romanizedTextElements.forEach((element) => {
  18. element.style.display = 'none'; // Hides the element
  19. });
  20. }
  21.  
  22. // Ensure the page is fully loaded before applying
  23. window.addEventListener('load', function() {
  24. hideRomanization(); // Hide romanization once the page is loaded
  25. });
  26.  
  27. // Set up an observer to handle dynamic content added after the initial load
  28. const observer = new MutationObserver(function() {
  29. hideRomanization(); // Re-run the function if new romanized text appears
  30. });
  31.  
  32. // Observe changes in the entire document body to catch dynamic content
  33. observer.observe(document.body, {
  34. childList: true, // Watch for added/removed child elements
  35. subtree: true // Look deeper in the tree (not just direct children)
  36. });
  37.  
  38. // Run the function on a delayed interval to catch late loading elements
  39. setInterval(hideRomanization, 500); // Check every 500ms for the element
  40. })();
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement