mmmturkeybacon Numbered Google Results (with 10-per-page mod)

Numbers Google search results in the format M.N to show the result number.

目前為 2014-11-02 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name mmmturkeybacon Numbered Google Results (with 10-per-page mod)
  3. // @author mmmturkeybacon
  4. // @description Numbers Google search results in the format M.N to show the result number.
  5. // N counts up from 1 to 10, after that M is incremented by 1 and N starts over
  6. // at 1. Google Instant should be disabled.
  7. // @namespace http://userscripts.org/users/523367
  8. // @include http*://www.google.*/search?*
  9. // @grant none
  10. // @version 1c
  11. // @require http://code.jquery.com/jquery-latest.min.js
  12. // ==/UserScript==
  13.  
  14. // modified by clickhappier to add page numbering for 10-result pages
  15.  
  16.  
  17. // If you have Google set to return 10 results per page (default), the first
  18. // page usually has 10 results but not sometimes it will have fewer.
  19.  
  20. // If you change Results per page under Search Settings, Google will return
  21. // more results per page. The number of links on the page might not always be
  22. // the same as the number of results per page you chose. That's because Google
  23. // doesn't count every link it shows you as a result.
  24. // Ads aren't counted
  25. // "More results from ..." are grouped with the link they are under. Google
  26. // counts this as one result.
  27. // "Images for ..." aren't counted. (imagebox_bigimages)
  28. // "News for ..." and all the the links grouped with it are counted as one
  29. // result?? (newsbox)
  30.  
  31. (function() {
  32. // If instant search has enabled
  33. //if(document.getElementById('misspell')) return;
  34. var p_result = document.getElementById('res');
  35. if (!p_result) return;
  36.  
  37. //Create Array of All HTML Tags
  38. var allLiTags = p_result.getElementsByTagName("li");
  39.  
  40. var i;
  41. var result_num = 0;
  42. var page_num = 1;
  43. var page_str = '';
  44.  
  45. // begin mod
  46. page_num = $('table#nav tbody tr td.cur').text();
  47. page_str = page_num + '.';
  48. // end mod
  49.  
  50. for (i = 0; i < allLiTags.length; i++)
  51. {
  52. if (allLiTags[i].className == 'g' || allLiTags[i].className == 'g w0')
  53. {
  54. //if (allLiTags[i].id == 'imagebox_bigimages')
  55. if (allLiTags[i].id == 'imagebox_bigimages' || allLiTags[i].id == 'newsbox')
  56. {
  57. continue;
  58. }
  59.  
  60. var h3 = allLiTags[i].getElementsByTagName('h3');
  61. if(!h3[0])
  62. {
  63. continue;
  64. }
  65.  
  66. result_num++;
  67. if (result_num > 10)
  68. {
  69. page_num++;
  70. page_str = page_num + '.'
  71. result_num = result_num - 10;
  72. }
  73. h3[0].innerHTML = page_str + result_num + '&nbsp;-&nbsp;' + h3[0].innerHTML;
  74. }
  75. }
  76.  
  77. })();