Skip to content

Instantly share code, notes, and snippets.

@iwamot
Forked from yosmoc/cookpad_tukurepo.user.js
Created October 24, 2009 18:39
Show Gist options
  • Save iwamot/217663 to your computer and use it in GitHub Desktop.
Save iwamot/217663 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name cookpad_tukurepo(iwamot)
// @namespace http://github.com/iwamot
// @include http://cookpad.com/*
// origin http://d.hatena.ne.jp/samurai20000/20090715/1247668133
// ==/UserScript==
(function(){
function get_tukurepo(elem) {
if (!elem) {
elem = document;
}
var anchors = Array.slice(elem.getElementsByTagName('a'));
anchors.forEach(function(a) {
if (a.href.match(/^http:\/\/cookpad\.com\/recipe\/\d+$/) && a.getElementsByTagName('img').length == 0) {
GM_xmlhttpRequest({
method: 'get',
url : a.href,
onload: function(res) {
var matches = res.responseText.match(/<span class="tsukurepo_count">(\d+)<\/span>/);
var num = (matches) ? matches[1] : 0;
a.innerHTML += "("+ num + "件)";
}
});
}
});
}
get_tukurepo();
if (window.AutoPagerize) {
if (window.AutoPagerize.addFilter) {
window.AutoPagerize.addFilter(function(docs) {
docs.forEach(get_tukurepo);
});
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment