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

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

目前为 2014-09-05 提交的版本,查看 最新版本

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