-
-
Save iwamot/217663 to your computer and use it in GitHub Desktop.
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 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