short url for amazon

    
      
  • /*
     * @title short url for amazon
     * @description AmazonのURLを短くします
     * @license MIT License
     */
    
    (function(_d,_a,_b,_c,asinElm,isbnID,winAsin,df,box){
    function c(t){return _d.createElement(t)}
    function e(id){return _d.getElementById(id)}
    function addCSS(cssText,r,s){
    	s=_d.createElement('style');
    	s.type='text/css';
    	r=_d.getElementsByTagName('head')[0]||_d.documentElement;
    	s.textContent=cssText;
    	return r.appendChild(s).s
    }
    function closeBtn(p){
    	p=this.parentNode;
    	p.parentNode.removeChild(p);
    }
    function makeBtn(elm,formText,f,g,h){
    	f=c('form');
    	f.id=_c;
    	elm.appendChild(f);
    	g=c('textarea');
    	g.value=formText;
    	g.id=_a;
    	f.appendChild(g);
    	h=c('button');
    	f.appendChild(h);
    	h.appendChild(_d.createTextNode('\u00D7'));
    	h.setAttribute('type','button');
    	h.addEventListener('click',closeBtn,false);
    	h.title='close';
    }
    
    asinElm = _d.getElementById('ASIN');
    winAsin = window.sitbAsin;
    if(!asinElm && !winAsin)return;
    isbnID = (asinElm)?asinElm.value : winAsin;
    textElm = document.getElementById('btAsinTitle').textContent + ' ' + 'http://amazon.jp/dp/' + isbnID;
    df=_d.createDocumentFragment();
    if(e(_b)){
    	if(e(_c))e(_c).parentNode.removeChild(e(_c));
    	makeBtn(df,textElm);
    	e(_b).appendChild(df);
    }else{
    	addCSS('#'+_a+'{top:30px;right:25px;width:400px;height:60px;z-index:9998;position:fixed;padding:8px;border:5px solid #888;padding:5px;opacity:0.7;}#'+_c+' button{top:20px;right:16px;z-index:9999;position:fixed;background-color:#FF514C;border:3px solid #fff;color:#fff;font-size:15px;height:23px;width:23px;padding:0;opacity:1;cursor:pointer;border-radius:15px;box-shadow:-1px 2px 6px #777;}');
    	box=c('div');
    	box.id=_b;
    	df.appendChild(box);
    	makeBtn(box,textElm);
    	_d.body.appendChild(df);
    }
    e(_a).focus();
    })(document,'rko_amzn_textarea','rko_amzn','rko_amzn_form');
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2016/03/15 20:38:06 - 2016-03-15
  2. 2015/03/27 19:34:36 - 2015-03-27
  3. 2015/03/26 13:06:57 - 2015-03-26
  4. 2014/06/08 22:47:33 - 2014-06-08
  5. 2012/11/29 21:40:08 - 2012-11-29