Amazon hi-res

    @@ -19,25 +19,69 @@ // http://parasiteeve2.blog65.fc2.com/blog-entry-392.html // - ASIN: B00OK93Z0E e.g. // http://z-ecx.images-amazon.com/images/P/B00OK93Z0E.09-A2KAVP39WOVYMY.MAIN._V20141203013700-PE2HO-goo-gl-R8MyJ_SY6000_SCRMZZZZZZ_.jpg +// +// shrink by hand // http://z-ecx.images-amazon.com/images/P/B00OK93Z0E.09-A2KAVP39WOVYMY.MAIN._SY6000_SCRMZZZZZZ_.jpg // http://z-ecx.images-amazon.com/images/P/B00OK93Z0E.09-A2KAVP39WOVYMY.MAIN._SCRMZZZZZZ_.jpg -// TODO -// - [ ] book w/ lightbox -// - #imgBlkFront data:image/jpeg;base64,/... -// - http://www.amazon.co.jp/dp/4861523516 -// - [ ] digital contents -// - #prodImage w/ pop-up -// + http://www.amazon.co.jp/dp/B00OK93Z0E -// + http://www.amazon.co.jp/gp/product/images/B00OK93Z0E/ -// + http://z2-ec2.images-amazon.com/R/1/a=B00OK93Z0E+c=A2KAVP39WOVYMY+d=_SCR(0,0,0)_+o=01+s=RMTILE+va=MAIN+ve=323866015+e=.jpg -// - SCR(0,0,0) tiled .gif matrix, 0 or 1 - -// TODO change to build url syntax +// TODO - [ ] Kindle Store +// - [ ] non expandable image +// - http://www.amazon.co.jp/dp/B00MBH33LI +// - http://www.amazon.co.jp/dp/B000TKDFN0 +// - http://ecx.images-amazon.com/images/I/51Pil0Wa-mL.jpg +// - [ ] MERCHANT_ID +// - http://www.amazon.co.jp/dp/B00OVDZZEI +// - A8UGI2UDC0XXN +// - http://z-ecx.images-amazon.com/images/P/B00OVDZZEI.09-A2KAVP39WOVYMY.MAIN._SCRMZZZZZZ_.jpg (function () { - var img = document.querySelector('#landingImage'); - if (!img) return; + if (!/^www\.amazon\.([a-z\.]+)/.test(location.hostname)) return; + + var q = function (sel) { + return document.querySelector(sel); + }; + + // #ASIN e.g. Android App Store + // http://let.hatelabo.jp/noromanba/let/gYC-y8DN9c28Rw + // http://let.hatelabo.jp/noromanba/let/gYC-y8CR-5yPEw + /*/ + var asin = (q('input#ASIN[value]') || {}).value || + (location.pathname.match(/(?:dp|product)\/(\w+)/) || [])[1]; + /*/ + var asin = (function () { + var canon = q('head link[rel="canonical"][href^="http:"]').href; + if (!canon) return; + + //return new URL(canon).pathname.split('/').pop(); + return canon.split('/').pop(); + })(); + //*/ + if (!asin) return; + + // e.g. http://www.amazon.co.jp/dp/B00ITLX5JU/ + // http://www.amazon.co.jp/dp/4861523516 + var src = (q([ + 'img#main-image[src]', + '#imageBlockThumbs img[src]' + ]) || {}).src; + var artwork; + if (src) { + // http://ecx.images-amazon.com/images/I/<IMG_ID>.png + artwork = src.replace(/\._\w{2}\d+_.*(\.\w+)$/, '$1'); + } else { + var merchantID = (q('input#merchantID[value]') || {}).value; + if (!merchantID) return; + + // http://z2-ec2.images-amazon.com/images/P/<ASIN>.09-<MERCHANT_ID>.MAIN_SCRMZZZZZZ_.jpg + artwork = [ + //'http://z2-ec2.images-amazon.com/images/P/', + 'http://z-ecx.images-amazon.com/images/P/', + asin, + '.09-', + merchantID, + '.MAIN_SCRMZZZZZZ_.jpg' + ].join(''); + } - window.open(img.dataset.oldHires || img.src); -})(); + window.open(artwork); +})();
  • /*
     * @title Amazon hi-res
     * @description open largest image in new tab/window on Amazon
     * @include http://www.amazon.tld/*
     * @license MIT http://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // OBSOLETE
    // http://let.hatelabo.jp/noromanba/let/hJmc1aHrisB0
    // http://z2-ec2.images-amazon.com/images/P/<ASIN>.09.MAIN._SCRMZZZZZZ_.jpg
    
    
    // c.f. how to get large image
    // http://anond.hatelabo.jp/20100625062056
    // http://anond.hatelabo.jp/20140101104854
    
    // c.f. works well, but depends outer webservice
    // http://parasiteeve2.blog65.fc2.com/blog-entry-392.html
    //  - ASIN: B00OK93Z0E e.g.
    //   http://z-ecx.images-amazon.com/images/P/B00OK93Z0E.09-A2KAVP39WOVYMY.MAIN._V20141203013700-PE2HO-goo-gl-R8MyJ_SY6000_SCRMZZZZZZ_.jpg
    //
    // shrink by hand
    //   http://z-ecx.images-amazon.com/images/P/B00OK93Z0E.09-A2KAVP39WOVYMY.MAIN._SY6000_SCRMZZZZZZ_.jpg
    //   http://z-ecx.images-amazon.com/images/P/B00OK93Z0E.09-A2KAVP39WOVYMY.MAIN._SCRMZZZZZZ_.jpg
    
    
    // TODO - [ ] Kindle Store
    //      - [ ] non expandable image
    //       - http://www.amazon.co.jp/dp/B00MBH33LI
    //       - http://www.amazon.co.jp/dp/B000TKDFN0
    //        - http://ecx.images-amazon.com/images/I/51Pil0Wa-mL.jpg
    //      - [ ] MERCHANT_ID
    //       - http://www.amazon.co.jp/dp/B00OVDZZEI
    //        - A8UGI2UDC0XXN
    //        - http://z-ecx.images-amazon.com/images/P/B00OVDZZEI.09-A2KAVP39WOVYMY.MAIN._SCRMZZZZZZ_.jpg
    (function () {
        if (!/^www\.amazon\.([a-z\.]+)/.test(location.hostname)) return;
    
        var q = function (sel) {
            return document.querySelector(sel);
        };
    
        // #ASIN e.g. Android App Store
        // http://let.hatelabo.jp/noromanba/let/gYC-y8DN9c28Rw
        // http://let.hatelabo.jp/noromanba/let/gYC-y8CR-5yPEw
        /*/
        var asin = (q('input#ASIN[value]') || {}).value ||
            (location.pathname.match(/(?:dp|product)\/(\w+)/) || [])[1];
        /*/
        var asin = (function () {
            var canon = q('head link[rel="canonical"][href^="http:"]').href;
            if (!canon) return;
    
            //return new URL(canon).pathname.split('/').pop();
            return canon.split('/').pop();
        })();
        //*/
        if (!asin) return;
    
        // e.g. http://www.amazon.co.jp/dp/B00ITLX5JU/
        //      http://www.amazon.co.jp/dp/4861523516
        var src = (q([
                'img#main-image[src]',
                '#imageBlockThumbs img[src]'
        ]) || {}).src;
        var artwork;
        if (src) {
            // http://ecx.images-amazon.com/images/I/<IMG_ID>.png
            artwork = src.replace(/\._\w{2}\d+_.*(\.\w+)$/, '$1');
        } else {
            var merchantID = (q('input#merchantID[value]') || {}).value;
            if (!merchantID) return;
    
            // http://z2-ec2.images-amazon.com/images/P/<ASIN>.09-<MERCHANT_ID>.MAIN_SCRMZZZZZZ_.jpg
            artwork = [
                //'http://z2-ec2.images-amazon.com/images/P/',
                'http://z-ecx.images-amazon.com/images/P/',
                asin,
                '.09-',
                merchantID,
                '.MAIN_SCRMZZZZZZ_.jpg'
            ].join('');
        }
    
        window.open(artwork);
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2014/12/03 06:34:46 - 2014-12-03
  2. 2014/12/03 06:23:43 - 2014-12-03
  3. 2014/12/03 02:01:05 - 2014-12-03
  4. 2014/12/02 08:41:16 - 2014-12-02