Google 2014 Part 5

Changes height: 70px; to height: 50px; in the category .form-cont on the node <div class="noticebar"><div class="nbpr"></div></div>

  1. // ==UserScript==
  2. // @name Google 2014 Part 5
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Changes height: 70px; to height: 50px; in the category .form-cont on the node <div class="noticebar"><div class="nbpr"></div></div>
  6. // @author You
  7. // @match https://vanced-youtube.neocities.org/2013*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to find and change the height property
  15. function changeHeight() {
  16. const targetNode = document.querySelector('div.noticebar > div.nbpr > .form-cont');
  17. if (targetNode) {
  18. targetNode.style.height = '50px';
  19. }
  20. }
  21.  
  22. // MutationObserver to wait for the target element to be available
  23. const observer = new MutationObserver((mutationsList, observer) => {
  24. for (const mutation of mutationsList) {
  25. if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
  26. changeHeight();
  27. observer.disconnect();
  28. }
  29. }
  30. });
  31.  
  32. // Observe the body for changes to find the target element
  33. observer.observe(document.body, { childList: true, subtree: true });
  34. })();