mmmturkeybacon Numbered Google Results and Easy Copy

Numbers results in the format M.N to show the result number. If you are on the first page it divides the results up into groups of 10 and after every 10 results M is increased by 1. This allows you to quickly see which page a result would be on if there were 10 results per page. For any page after the first, M is the page number and N is the result number. Hold the pointer over a button for instructions on copying. Disable Google Instant (Gear>Search settings>Never show Instant results).

目前為 2015-03-13 提交的版本,檢視 最新版本

// ==UserScript==
// @name        mmmturkeybacon Numbered Google Results and Easy Copy
// @author      mmmturkeybacon
// @description Numbers results in the format M.N to show the result number. If you are on the first page it divides the results up into groups of 10 and after every 10 results M is increased by 1. This allows you to quickly see which page a result would be on if there were 10 results per page. For any page after the first, M is the page number and N is the result number. Hold the pointer over a button for instructions on copying. Disable Google Instant (Gear>Search settings>Never show Instant results).
// Click button to copy link URL, Ctrl-click to copy link title, Shift-click to copy link title and URL.
// @namespace   http://userscripts.org/users/523367
// @include     http*://www.google.*/search?*
// @version     1.02
// @grant       GM_setClipboard
// ==/UserScript==

// 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 been 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 = Number(document.evaluate('//td[@class="cur"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent);
    var page_str = page_num + '.';
    var is_first_page = (page_num == 1);

    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 && is_first_page)
            {
                page_num++;
                page_str = page_num + '.'
                result_num = result_num - 10;
            }
            h3[0].innerHTML = '<button title="click to copy URL.\nCtrl-click to copy title.\nShift-click to copy title and URL." id=btn'+page_str+result_num+'>'+page_str + result_num+'</button>' + '&nbsp;' + h3[0].innerHTML;
            var btn = document.getElementById('btn'+page_str+result_num);
            var link = h3[0].getElementsByTagName('a')[0];
            (function(title, URL){btn.onclick = function(event)
            {
                if (event.ctrlKey)
                {
                    GM_setClipboard(title)
                }
                else if (event.shiftKey)
                {
                    GM_setClipboard(title +' '+ URL)
                }
                else
                {
                    GM_setClipboard(URL)
                }
            }})(link.innerHTML, link.href);
        }
    }
})();

QingJ © 2025

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