Created
January 31, 2012 02:32
-
-
Save yesmeck/1708345 to your computer and use it in GitHub Desktop.
Douban Rating
This file contains hidden or 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== | |
// @version 1.0 | |
// @name Douban Rating | |
// @author Zhou Meng | |
// @description Show Douban Rating in Douban List | |
// @include http://*.douban.com/doulist/* | |
// ==/UserScript== | |
if ('undefined' == typeof __PAGE_SCOPE_RUN__) { | |
//把当前脚本注入到页面 | |
//http://wiki.greasespot.net/Content_Scope_Runner | |
(function page_scope_runner() { | |
var my_src = "(" + page_scope_runner.caller.toString() + ")();"; | |
var script = document.createElement('script'); | |
script.setAttribute("type", "text/javascript"); | |
script.textContent = "var __PAGE_SCOPE_RUN__ = true;\n" + my_src; | |
setTimeout(function() { | |
document.body.appendChild(script); | |
document.body.removeChild(script); | |
}, 0); | |
})(); | |
return; | |
} else { | |
Do(function() { | |
$("div.article table").each(function(i, table) { | |
var url = $(table).find("a").attr("href"); | |
$.get(url, function(data) { | |
var rating = $(data).find("strong.rating_num").text(); | |
if (rating) { | |
$(table).find("p.pl").append("<br />" + "评分 : " + rating); | |
} | |
}); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment