amebaフォトアルバムを一括DLするためのgreasemonkeyスクリプト

なにこれ?

画像一覧のページで実行するとオリジナルサイズへのリンクを付加する。

サンプル

高校講座「物理」にでてた山本薫さんのページで実行した様子。

ソースコード

// ==UserScript==
// @name           ameba_photo_orig_link
// @namespace      http://cherenkov.vox.com
// @include        http://photo.ameba.jp/user/*
// ==/UserScript==

(function(){
var item = document.evaluate('//a[../../../../../@class="item"]', document, null, 7, null);

for(var i=0;i<item.snapshotLength;i++){
    (function(i){
        GM_xmlhttpRequest({
            method:"GET",
            url: item.snapshotItem(i).href,
            headers:{"User-Agent":"Mozilla/5.0","Accept":"text/xml"},
            onload:function(res) {
                var foto = /<a href="\/preview\/photo.do\?url=(.+?)">/.exec(res.responseText)[1];
                var link = document.createElement("a");
                link.setAttribute("href",foto);
                link.appendChild(document.createTextNode("ORIG"));
                link.style.backgroundColor = 'pink';
                item.snapshotItem(i).parentNode.parentNode.parentNode.insertBefore(link,item.snapshotItem(i).parentNode.parentNode.parentNode.firstChild);
            }
        });
    })(i);
}
})();

インストール

ameba_photo_orig_link.user.js

紹介

山本薫さんのブログ「薫風 -kaorikaze-」もよろしく。