Google Auto Navigate to Next Page

Infinite scrolling for Google Search with site icons displayed and 2-second delay before loading next page.

  1. // ==UserScript==
  2. // @name Google Auto Navigate to Next Page
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Infinite scrolling for Google Search with site icons displayed and 2-second delay before loading next page.
  6. // @author tofuine
  7. // @match https://www.google.com/search*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. // Observer for infinite scroll
  16. const observer = new IntersectionObserver((entries) => {
  17. entries.forEach((entry) => {
  18. if (entry.isIntersecting) {
  19. // Trigger Google's infinite scroll with a delay of 2 seconds
  20. const moreButton = document.querySelector("#pnnext");
  21. if (moreButton) {
  22. setTimeout(() => {
  23. moreButton.click();
  24. }, 2000); // Wait for 2 seconds before navigating
  25. }
  26. }
  27. });
  28. });
  29.  
  30. // Add observer to the footer or a scrolling sentinel
  31. function addObserver() {
  32. const sentinel = document.querySelector("#foot") || document.createElement("div");
  33. sentinel.style.height = "1px";
  34. sentinel.id = "scroll-sentinel";
  35. document.body.appendChild(sentinel);
  36. observer.observe(sentinel);
  37. }
  38.  
  39.  
  40.  
  41.  
  42. // Initialize script
  43. function init() {
  44.  
  45. addObserver();
  46.  
  47. }
  48.  
  49. window.addEventListener("load", init);
  50. })();