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 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        mmmturkeybacon Numbered Google Results (with 10-per-page mod)
// @author      mmmturkeybacon
// @description Numbers Google search results in the format M.N to show the result number.
//              N counts up from 1 to 10, after that M is incremented by 1 and N starts over
//              at 1. Google Instant should be disabled.
// @namespace   http://userscripts.org/users/523367
// @include     http*://www.google.*/search?*
// @grant       none
// @version     1c
// @require     http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==

// modified by clickhappier to add page numbering for 10-result pages


// If you have Google set to return 10 results per page (default), the first
// page usually has 10 results but not sometimes it will have fewer.

// If you change Results per page under Search Settings, Google will return
// more results per page. The number of links on the page might not always be
// the same as the number of results per page you chose. That's because Google
// doesn't count every link it shows you as a result.
// Ads aren't counted
// "More results from ..." are grouped with the link they are under. Google
// counts this as one result.
// "Images for ..." aren't counted. (imagebox_bigimages)
// "News for ..." and all the the links grouped with it are counted as one
// result?? (newsbox)

 (function() {
    // If instant search has enabled
    //if(document.getElementById('misspell')) return;
	
    var p_result = document.getElementById('res');
    if (!p_result) return;

    //Create Array of All HTML Tags
    var allLiTags = p_result.getElementsByTagName("li");

    var i;
    var result_num = 0;
    var page_num = 1;
    var page_str = '';

    // begin mod
    page_num = $('table#nav tbody tr td.cur').text();
    page_str = page_num + '.';
    // end mod

    for (i = 0; i < allLiTags.length; i++)
    {
        if (allLiTags[i].className == 'g' || allLiTags[i].className == 'g w0')
        {
            //if (allLiTags[i].id == 'imagebox_bigimages')
            if (allLiTags[i].id == 'imagebox_bigimages' || allLiTags[i].id == 'newsbox')
            {
                continue;
            }

            var h3 = allLiTags[i].getElementsByTagName('h3');
            if(!h3[0])
            {
                continue;
            }

            result_num++;
            if (result_num > 10)
            {
                page_num++;
                page_str = page_num + '.'
                result_num = result_num - 10;
            }
            
            h3[0].innerHTML = page_str + result_num + '&nbsp;-&nbsp;' + h3[0].innerHTML;
        }
    }

})();