はてなフォトライフの画像を一括DLするためのgreasemonkeyスクリプト
20100407 スクリプトを更新。AutoPagerize対応。userscripts.orgにアップ。
需要なさそうだけど書いてしまった。
なにこれ?
はてなフォトライフの画像一覧ページにオリジナルサイズへのリンクを付加するgreasemonkeyスクリプト
使い方
AutoPagerizeがあると便利。
greasemonkeyにhatenafoto_link_orig_img.user.jsをインストールしたら
はてなフォトライフのアルバムのページにいく。例えばココ。
ORIGとかかれた赤いものが画像へのリンクなのでflashgetなどにぶっこんで一括DLする。
ソースコード
20100407に直したもの。
// ==UserScript== // @name HatenaFotolife link orig img // @namespace http://d.hatena.ne.jp/Cherenkov/ // @include http://f.hatena.ne.jp/* // @version 0.0.3 // ==/UserScript== function addLink(doc) { Array.forEach(doc.querySelectorAll('.fotolist li a'), function(e) { GM_xmlhttpRequest({ method: "GET", url: e.href, onload: function(res) { var div = document.createElement('div'); div.innerHTML = res.responseText; var orig = div.querySelector('.fotoinfo>.edit img[src*="original.gif"]'); var fotoSrc = orig ? orig.parentNode.href : div.querySelector('img.foto').src.replace(/\?\d+/,""); var link = document.createElement("a"); link.href = fotoSrc; link.appendChild(document.createTextNode("ORIG")); link.style.backgroundColor = 'pink'; e.parentNode.insertBefore(link, e); } }); }); } addLink(document); document.body.addEventListener('AutoPagerize_DOMNodeInserted', function(evt) { addLink(evt.target); }, false);
以前の
// ==UserScript== // @name hatenafoto_link_orig_img // @namespace http://cherenkov.vox.com/ // @include http://f.hatena.ne.jp/* // @description Add link to original image on top of hatena fotolife thumbnails. // ==/UserScript== (function(){ var a = document.evaluate('//a[../../@class="fotolist"][parent::li]', document, null, 7, null); console.log(a.snapshotLength) for(var i=0;i<a.snapshotLength;i++){ (function(i){ GM_xmlhttpRequest({ method:"GET", url: a.snapshotItem(i).href, headers:{ "User-Agent":"Mozilla/5.0", "Accept":"text/xml" }, onload:function(res) { var foto = res.responseText.match(/<img src="(.+?)".+?class="foto"/) console.log(foto[1]); var link = document.createElement("a"); link.setAttribute("href",foto[1]); link.appendChild(document.createTextNode("ORIG")); link.style.backgroundColor = 'red'; a.snapshotItem(i).parentNode.insertBefore(link,a.snapshotItem(i).parentNode.firstChild); } }); })(i); } })();