Greasy Fork镜像 支持简体中文。

Return Google Search Counter

Brings back the Google search counter

  1. // ==UserScript==
  2. // @name Return Google Search Counter
  3. // @author NWP
  4. // @description Brings back the Google search counter
  5. // @namespace https://gf.qytechs.cn/users/877912
  6. // @version 0.1
  7. // @license MIT
  8. // @include https://www.google.*/search*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const debug = false;
  16.  
  17. function log(message, data) {
  18. if (debug) {
  19. if (data !== undefined && data !== null) {
  20. console.log(message, data);
  21. } else {
  22. console.log(message);
  23. }
  24. }
  25. }
  26.  
  27. function relocateResultStats(observer) {
  28. const resultStats = document.getElementById('result-stats');
  29. const appbar = document.getElementById('appbar');
  30.  
  31. log(resultStats ? "Found resultStats:" : "resultStats not found.", resultStats);
  32. log(appbar ? "Found appbar:" : "appbar not found.", appbar);
  33.  
  34. if (!resultStats || !appbar) {
  35. log("One or both elements (resultStats, appbar) not found. Stopping observer.");
  36. observer.disconnect();
  37. return;
  38. }
  39.  
  40. if (!appbar.contains(resultStats)) {
  41. log("Appending resultStats to appbar.");
  42. try {
  43. appbar.appendChild(resultStats);
  44. log("Stopping observer as the task is complete.");
  45. observer.disconnect();
  46. } catch (e) {
  47. console.error("Error appending resultStats to appbar:", e);
  48. }
  49. } else {
  50. log("resultStats is already in the appbar, stopping observer.");
  51. observer.disconnect();
  52. }
  53. }
  54.  
  55. const observer = new MutationObserver(() => {
  56. log("MutationObserver detected changes in the DOM.");
  57. relocateResultStats(observer);
  58. });
  59.  
  60. log("Starting MutationObserver.");
  61. observer.observe(document.body, {
  62. childList: true,
  63. subtree: true
  64. });
  65.  
  66. log("Performing initial check.");
  67. relocateResultStats(observer);
  68.  
  69. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址