Amazon img + asin

    @@ -8,12 +8,12 @@ // c.f. http://space.hatena.ne.jp/~/14217943783080751724#14217943783080751726+34 (function () { - var asin, img; - if (!/^www\.amazon\.(?:co\.jp|com)/.test(location.hostname) || - !(asin = (/\/(?:dp|ASIN)\/\w+/.exec(location.pathname) || [])[0]) || - !(img = (document.querySelector('#prodImageContainer img') || {}).src)) { + var tld, asin; + if (!(tld = (/^www\.amazon\.([a-z\.]+)/.exec(location.hostname) || [])[1]) || + !(asin = (document.querySelector('#ASIN') || {}).value)) { return; } + var img = (document.querySelector('#prodImageContainer img, #main-image, #kib-ma-container-0 img') || {}).src; - prompt('copy me', img + '\n' + 'http://www.amazon.co.jp' + asin); -})(); + prompt('copy me', (img + '\n' || '') + 'http://www.amazon.' + tld + '/dp/' + asin); +})();
  • /*
     * @title Amazon img + asin
     * @description prompt Amazon link with img; LGTM for Hatena Space
     * @include http://www.amazon.tld/*
     * @license MIT License http://nrm.mit-license.org/2013
     * @require 
     */
    
    // c.f. http://space.hatena.ne.jp/~/14217943783080751724#14217943783080751726+34
    (function () {
        var tld, asin;
        if (!(tld = (/^www\.amazon\.([a-z\.]+)/.exec(location.hostname) || [])[1]) ||
            !(asin = (document.querySelector('#ASIN') || {}).value)) { 
            return;
        }
        var img = (document.querySelector('#prodImageContainer img, #main-image, #kib-ma-container-0 img') || {}).src;
    
        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