Hatelabo::Copieでそのまま保存できないわけではないけど

  • /*
     * @title Hatelabo::Copieでそのまま保存できないわけではないけど
     * @description 「描いてる途中で保存する用の保存を作ってみた」って意味
     * @include http://copie.hatelabo.jp/mafucode/banner.creat*
     * @include http://copie.hatelabo.jp/api/banner.imag*
     * @license MIT License
     * @require 
     */
    
    if(location.pathname.match(/api\/banner\.image/)!=undefined){
    	// http://let.hatelabo.jp/mafucode/let/gYC-x8jmyuDfIQ/rev/hJmcuIuyrbN1
    	// func.xhr.get
    	(function(uri, success, error) {
    		var xhr = new XMLHttpRequest();
    		xhr.open("GET", uri);
    		xhr.addEventListener('readystatechange', function(event) {
    			if (event.target.readyState == 4) {
    				if (event.target.status == 200) {
    					success(event.target);
    				} else {
    					error(event.target);
    				}
    			}
    		}, false);
    		xhr.send();
    		return xhr;
    	})(location.origin,(function(e){
    		location.href=(location.origin
    			//+'/'
    			+e.responseText.match(/li\>\<a\ href\=\"(.+)\"\>\新\規\コ\ピ\ィ\<\/a\>\<\/li/)[1]
    			//+'/'
    			+location.href.match(/\?.+$/)
    			+'&advanced=y');
    		}),(function(e){
    			return alert("not logged in");
    		}));
    }
    
    
    
    
    if(location.pathname.match(/[\d\w]+\/banner\.create/)!=null)setTimeout(function(){
    	var d=null;
    	if(location.href.match(/\?.+/)!=null){
    		d=(function(a){
    			var i=0;
    			var b={"text[]":[],"x[]":[],"y[]":[],"size[]":[],};
    			
    			while(i<a.length){
    				var c=decodeURIComponent(a[i].split("=")[0]);
    				if(c==""||c==undefined){
    				}else if(c=="text[]"||c=="x[]"||c=="y[]"||c=="size[]"){
    					b[c].push(decodeURIComponent(a[i].split("=")[1]));
    				}else{
    					b[c]=decodeURIComponent(a[i].split("=")[1]);
    				}
    				i+=1;
    			}
    			return b;
    		})(location.href.match(/\?(.+)/)[1].split('&'));
    		if(d["background"]!=null){
    			document.querySelectorAll('#form div.main dl dd input.background[name="background"]')[0].value=d["background"];
    		}
    
    		var p=document.querySelector('#form div.advanced dl dd.copies div.copy').cloneNode()
    		document.querySelector('#form div.advanced dl dd.copies').innerHTML=""
    		var i=0;
    		while(i<d["text[]"].length){
    			var pp=p.cloneNode();
    			pp.querySelector('.text').value=d["text[]"][i];
    			pp.querySelector('.x').value=d["x[]"][i]
    			pp.querySelector('.y').value=d["y[]"][i]
    			pp.querySelector('.size').value=d["size[]"][i]
    			document.querySelector('#form div.advanced dl dd.copies').appendChild(pp);
    			i+=1;
    		}
    		document.querySelector('.updatePreview').click()
    	}
    	hatebu=document.createElement('i')
    	hatebu.appendChild(document.createTextNode('B!'))
    	
    	hatebu.addEventListener('click',
    			(function(){
    				window.open(
    					"http://b.hatena.ne.jp/add?mode=confirm&url="
    					+encodeURIComponent(
    						document.querySelectorAll(
    							'#form div.main p img.previewImage'
    							)[0].src.split(/\&cache\=[\%\w]*/)
    								.split(/\&cache\=[\%\w]*/).join("")
    								.split(/\&\=[\%\w]*/).join("")
    								.split(/\&rkm\=[\%\w]*/).join("")
    								.replace(/\?\=[\%\w]*/,'?')
    						)
    					);
    				return 0;
    			}),false);
    	
    	document.querySelectorAll('#form div.main p.advanced')[0].appendChild(hatebu);
    },4000);
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2013/12/30 16:34:19 - 2013-12-30
  2. 2013/12/30 16:31:01 - 2013-12-30
  3. 2013/12/30 16:19:35 - 2013-12-30
  4. 2013/12/30 15:25:42 - 2013-12-30
  5. 2013/12/29 19:57:43 - 2013-12-29
  6. 2013/12/29 19:37:20 - 2013-12-29
  7. 2013/12/29 18:26:56 - 2013-12-29
  8. 2013/12/29 18:11:11 - 2013-12-29