setCssScript

  • /*
     * @title setCssScript
     * @description どのページでもユーザCSSを追記できるブックマークレット cookie記憶復元(保存できる文字数に注意が必要です)
     * @include http://*
     * @license tukihatu
     */
    
    
    //setCssScript V1.0
    //ユーザがCSSを直接書き込めるブックマークレット
    
    
    //scriptリセット
    var setCssScript_cssO = ""
    if(document.getElementById('setCssScript_mainArea')){
    	if(document.getElementById('setCssScript')){document.body.removeChild(document.getElementById('setCssScript'))};
    	document.body.removeChild(document.getElementById('setCssScript_mainArea'));
    	setCssScript_cssO = document.getElementById('setCssScript_cssArea');
    }else{
    	setCssScript_cssO = document.createElement('style');
    	setCssScript_cssO.setAttribute('id','setCssScript_cssArea');
    	setCssScript_cssO.innerHTML = getCookie();
    	document.body.appendChild(setCssScript_cssO);
    }
    
    
    //メイン画面書き込み
    var setCssScript_mainO = document.createElement('div');
    setCssScript_mainO.setAttribute('id','setCssScript_mainArea');
    setCssScript_mainO.setAttribute('style','font-size:10px;position:fixed;bottom:0;width:100%;z-index:10000000001;');
    setCssScript_mainO.innerHTML = '<div style="width:100%;height:125px;border-top:1px solid #666666;background:#BBBBDD;background:linear-gradient(top,#DDDDFF,#BBBBDD);background:-webkit-gradient(linear,center top, center bottom,from(#DDDDFF),to(#BBBBDD));background:-moz-linear-gradient(top,#DDDDFF,#BBBBDD);*background:#BBBBDD;">\
    <div style="width:98%;height:115px;text-align:left;color:#000000;">\
    <div style="padding:5px 5px">\
    <div>ユーザCSS追記 cookie範囲 - <input id="setCssScriptRadio1" type="radio" name="setCssScriptRadio" value="1" checked /><label for="setCssScriptRadio1">サイト全体</label> <input id="setCssScriptRadio2" type="radio" name="setCssScriptRadio" value="2" /><label for="setCssScriptRadio2">ページ単位</label></div>\
    <form method="post" action="" onsubmit="return false;"><div style="width:100%;font-weight:bold;">\
    <textarea id="setCssScriptText" name="setCssScriptText" style="font-size:14px;width:100%;height:50px;">'+getCookie()+'</textarea>\
    <div style="text-align:center;padding-top:10px;"><a href="javascript:;" onclick="setCssScript_submit();" style="color:#000 !important;background:#FFF !important;border:2px solid #333399 !important;padding:5px 10px !important;">送信</a>\
    <span style="display:inline-block;padding-left:10px;"><a href="javascript:;" onclick="setCssScript_reset();" style="color:#000 !important;background:#FFF !important;border:2px solid #333399 !important;padding:5px 10px !important;">クリア</a></span><span style="display:inline-block;padding-left:10px;"><a href="javascript:;" onclick="setCssScript_close();" style="color:#000 !important;background:#FFF !important;border:2px solid #333399 !important;padding:5px 10px !important;">閉じる</a></span><span style="display:inline-block;padding-left:10px;"><a href="javascript:;" onclick="setCssScript_change();" style="color:#000 !important;background:#FFF !important;border:2px solid #333399 !important;padding:5px 10px !important;">表示上下切替</a></span></div>\
    </div></form>\
    </div></div>\
    </div>';
    document.body.appendChild(setCssScript_mainO);
    
    if(document.cookie.indexOf("setCssScriptRadio=2;") != -1){
    	document.getElementById('setCssScriptRadio2').checked = true;
    	document.getElementById('setCssScriptRadio1').checked = false;
    }
    
    
    
    //更新追加
    function setCssScript_submit(){
    	var setCssScript_settext = document.getElementById('setCssScriptText').value;
    	
    	setCssScript_cssO.innerHTML = setCssScript_settext;
    	
    	//クッキーに保存
    	setCookie(setCssScript_settext);
    }
    
    //表示位置上下切替・デフォルトは下
    var setCssScript_setchange = "1";
    function setCssScript_change(){
    	if(setCssScript_setchange == 1){
    		setCssScript_setchange = "2";
    		setCssScript_mainO.setAttribute('style','font-size:10px;position:fixed;top:0;width:100%;z-index:10000000001;');
    	}else{
    		setCssScript_setchange = "1";
    		setCssScript_mainO.setAttribute('style','font-size:10px;position:fixed;bottom:0;width:100%;z-index:10000000001;');
    	}
    }
    //文字消す
    function setCssScript_reset(){
    	document.getElementById('setCssScriptText').value = "";
    }
    //入力画面消す
    function setCssScript_close(){
    	if(document.getElementById('setCssScript')){document.body.removeChild(document.getElementById('setCssScript'))};
    	document.body.removeChild(document.getElementById('setCssScript_mainArea'));
    }
    
    //cookie
    function getCookie(){
    	if(document.cookie.indexOf("setCssScript") != -1){
    		return decodeURIComponent(document.cookie.split("setCssScript=")[1].split(";")[0]);
    	}
    	return "";
    }
    function setCookie(text){
    	var setCssScript_date = new Date();
    	if(text == ""){
    		setCssScript_date.setTime(setCssScript_date.getTime() - 24*60*60*1000);
    		if(document.getElementById('setCssScriptRadio2').checked){//ローカル
    			document.cookie = 'setCssScript=; expires='+setCssScript_date.toGMTString()+'; path='+location.pathname+';';
    			document.cookie = 'setCssScriptRadio=2; expires='+setCssScript_date.toGMTString()+'; path='+location.pathname+';';
    		}else{//ルート
    			document.cookie = 'setCssScript=; expires='+setCssScript_date.toGMTString()+'; path=/;';
    			document.cookie = 'setCssScriptRadio=1; expires='+setCssScript_date.toGMTString()+'; path='+location.pathname+';';
    		}
    	}else{
    		setCssScript_date.setTime(setCssScript_date.getTime() + 30*365*24*60*60*1000);
    		if(document.getElementById('setCssScriptRadio2').checked){//ローカル
    			document.cookie = 'setCssScript='+encodeURIComponent(text)+'; expires='+setCssScript_date.toGMTString()+'; path='+location.pathname+';';
    			document.cookie = 'setCssScriptRadio=2; expires='+setCssScript_date.toGMTString()+'; path='+location.pathname+';';
    		}else{//ルート
    			document.cookie = 'setCssScript='+encodeURIComponent(text)+'; expires='+setCssScript_date.toGMTString()+'; path=/;';
    			document.cookie = 'setCssScriptRadio=1; expires='+setCssScript_date.toGMTString()+'; path='+location.pathname+';';
    		}
    	}
    }
    
    
    /*
    javascript:function%20loadScript(sU)%7Bvar%20sE=document.createElement('SCRIPT');sE.setAttribute('id','setCssScript');sE.setAttribute('src',sU);sE.setAttribute('charset','UTF-8');document.body.appendChild(sE);%7DloadScript('http://www.tci-m.co-site.jp/set.js?x='+Math.floor(Math.random()*10000000));(function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F[i+'NS']&&F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new%20Image;E[r]('src',I+L);})(document,'createElement','setAttribute','getElementsByTagName','FirebugLite','4','firebug-lite.js','releases/lite/latest/skin/xp/sprite.png','https://getfirebug.com/','#startOpened');
    */
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2013/02/07 19:02:46 - 2013-02-07
  2. 2013/02/07 18:24:47 - 2013-02-07
  3. 2013/02/07 18:19:51 - 2013-02-07
  4. 2013/02/07 18:17:09 - 2013-02-07
  5. 2013/02/07 18:14:23 - 2013-02-07
  6. 2013/02/07 18:13:49 - 2013-02-07
  7. 2013/02/07 18:10:15 - 2013-02-07
  8. 2013/02/07 18:03:01 - 2013-02-07
  9. 2013/02/07 18:01:46 - 2013-02-07
  10. 2013/02/07 18:01:05 - 2013-02-07
  11. 2013/02/07 17:38:47 - 2013-02-07
  12. 2013/02/07 17:34:51 - 2013-02-07
  13. 2013/02/07 17:28:46 - 2013-02-07
  14. 2013/02/07 17:21:49 - 2013-02-07
  15. 2013/02/07 17:20:05 - 2013-02-07
  16. 2013/02/07 17:16:20 - 2013-02-07
  17. 2013/02/07 17:14:26 - 2013-02-07
  18. 2013/02/07 17:12:38 - 2013-02-07
  19. 2013/02/07 17:10:07 - 2013-02-07