StartPage - Move ads to the sidebar bottom

It moves ads to the sidebar, avoiding unwanted clicks on them. In mobile, they dissapear out of bounds.

当前为 2024-06-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name StartPage - Move ads to the sidebar bottom
  3. // @namespace https://startpage.com/
  4. // @match *://*startpage.com/*
  5. // @icon https://www.startpage.com/sp/cdn/favicons/favicon-32x32-gradient.png
  6. // @version 20240603
  7. // @author Lukas ThyWalls
  8. // @license CC0
  9. // @description It moves ads to the sidebar, avoiding unwanted clicks on them. In mobile, they dissapear out of bounds.
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. // Run Check Function at every DOM change.
  14. (new MutationObserver(check)).observe(document, {childList: true, subtree: true});
  15.  
  16. function check(changes, observer) {
  17. // If all Sidebar Block AND both Ads Block (top and bottom) are found/loaded...
  18. if(document.querySelector('#sidebar') &&
  19. (document.querySelector('#gcsa-top > iframe') && document.querySelector('#gcsa-bottom > iframe')) ||
  20. document.querySelector('.css-mtj8kd'))
  21. {
  22. // ... then stop checking ...
  23. observer.disconnect();
  24. // ... and move both Ads Blocks to the bottom of the sidebar.
  25. document.querySelector("#sidebar").appendChild(document.querySelector("#gcsa-top"));
  26. document.querySelector("#sidebar").appendChild(document.querySelector("#gcsa-bottom"));
  27. document.querySelector("#sidebar").appendChild(document.querySelector('div > .css-mtj8kd'));
  28. }
  29. }