Amazon img + asin

  • /*
     * @title Amazon img + asin
     * @description prompt minified Amazon link with img; LGTM for Hatena Space
     * @include http://www.amazon.tld/*
     * @license MIT License http://nrm.mit-license.org/2013
     * @require 
     */
    
    // pair-script
    // http://let.hatelabo.jp/noromanba/let/gYC-y8DN9c28Rw
    
    // c.f. http://space.hatena.ne.jp/~/14217943783080751724#14217943783080751726+45
    //      http://space.hatena.ne.jp/~/14217943783080751724/14290001378108728700/3
    (function () {
        var tld, asin;
        //*
        if (!(tld = (location.hostname.match(/^www\.amazon\.([a-z\.]+)/) || [])[1]) ||
            !(asin = (location.pathname.match(/dp\/(\w+)/) || [])[1])) {
            return;
        }
        /*/
        var meta = (location.href.match(/^https?:\/\/www\.amazon\.([a-z\.]+).*\/dp\/(\w+)/) || []).slice(1);
        if (meta.length < 2) return;
    
        tld = meta[0], asin = meta[1];
        //*/
    
        var query = {
                'normal': '#prodImageContainer img',
                'other' : '#main-image',
                'kindle': '#kib-ma-container-0 img'
        };
        query = Object.keys(query).map(function (k) { return query[k]; });
        var img = (document.querySelector(query) || {}).src;
    
        // TODO display to textarea
        // Firefox can't use linebreak within a prompt, so redandunt space ' \n' for avoid no-sep
        prompt('copy me', (img + ' \n' || '') + 'http://www.amazon.' + tld + '/dp/' + asin);
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2013/07/26 07:19:46 - 2013-07-26
  2. 2013/07/26 06:06:24 - 2013-07-26
  3. 2013/04/14 04:56:29 - 2013-04-14
  4. 2013/04/14 03:53:53 - 2013-04-14
  5. 2013/04/14 03:43:39 - 2013-04-14
  6. 2013/04/14 01:52:05 - 2013-04-14
  7. 2013/04/14 01:45:10 - 2013-04-14
  8. 2013/04/13 11:00:35 - 2013-04-13