Created
March 30, 2011 03:49
-
-
Save code404/893828 to your computer and use it in GitHub Desktop.
Google Result Numbers: Adds a number in turn to web search results of Google.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Google Result Numbers | |
// @description Adds a number in turn to web search results of Google. | |
// @version 2.1.0 | |
// @author Shinya <code404sk@gmail.com> | |
// @contributor | |
// @namespace http://code404.org/ | |
// @homepage http://userscripts.org/scripts/show/11213 | |
// @id Google-Result-Numbers@code404.org | |
// @run-at document-end | |
// @license | |
// @include http://www.google.*/search* | |
// ==/UserScript== | |
(function(){ | |
function ResultNumber(){ | |
this.PATH = "h3.r > a.l"; | |
var start = document.location.href.match(/start=(\d+)/); | |
this._number = start ? ++start[1] : 1; | |
} | |
ResultNumber.prototype.add = function(doc){ | |
var node = doc || document; | |
var results = node.querySelectorAll(this.PATH); | |
for(var i = 0, l = results.length; i < l; i++, this._number++){ | |
var suffix = document.createTextNode(this._number + ". "); | |
results[i].parentNode.insertBefore(suffix, results[i].parentNode.firstChild); | |
} | |
}; | |
var number = new ResultNumber(); | |
number.add(); | |
// Autopagerize and more | |
var boot = function(aEvent){ | |
number.add(aEvent.target); | |
}; | |
window.addEventListener("AutoPatchWork.DOMNodeInserted", boot, false); | |
window.addEventListener("AutoPagerize_DOMNodeInserted", boot, false); | |
window.addEventListener("AutoPagerAfterInsert", boot, false); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment