Sort baidu Search Result

给百度搜索结果加上序号

Version vom 30.05.2015. Aktuellste Version

// ==UserScript==
// @name Sort baidu Search Result
// @author	burningall
// @description	给百度搜索结果加上序号
// @version     2015.5.30
// @include		*www.baidu.com*
// @supportURL		http://www.burningall.com
// @contributionURL	[email protected]|alipay.com
// @namespace https://greasyfork.org/zh-CN/users/3400-axetroy
// ==/UserScript==

(function(){
	function addEvent(obj, event, fn) {
		return obj.addEventListener ? obj.addEventListener(event, fn, false) : obj.attachEventListener('on' + event, fn);
	};
	var cssText="display:inline-block;background:#303030;color:#fff;font-family:'微软雅黑';font-size:16px;text-align:center;width:25px;line-height:25px;border-radius:50%;"
	var div = document.createElement('div');
	function show(){
		//var list=document.getElementById('content_left').children;
		var list=document.querySelectorAll('#content_left>div[srcid] *[class~=t]')
		for(var i=0;i<list.length;i++){
			console.log(list[i])
			div.innerHTML='<div style=' + cssText + '>' + (i+1) + '</div>';
			list[i].innerHTML=div.innerHTML+list[i].innerHTML;
		}
	}
	show();
	addEvent(document,'DOMContentLoaded',function(){
		addEvent(document,'DOMNodeInserted',function(){
			show();		
		});
	});
})()