-
Notifications
You must be signed in to change notification settings - Fork 2
/
stylist_ie9.min.js
1 lines (1 loc) · 4.51 KB
/
stylist_ie9.min.js
1
(function(a,b,c){function d(a,b){return function d(){if(!d.timer){var e=arguments,f=this;d.timer=setTimeout(function(){a.apply(f,e),d.timer=c},b)}}}function e(a,b,c){for(var d,e=b.split(";"),f=0,g=e.length;f<g;f++)""!=e[f]&&(d=e[f].split(":"),c?a.style.removeProperty(d[0]):a.style.setProperty(d[0],d[1],"important"))}function f(a,c){var d=b.createElement("li");e(d,"color:#555;display:block"),d.appendChild(b.createTextNode(c)),a.appendChild(d)}function g(){function c(){switch(A){case"B":e(t,"top:0;right:0;height:100%;width:300px",!0),e(t,"bottom:0;left:0;height:300px;width:98%",!1),A="L";break;case"L":e(t,"bottom:0;left:0;height:300px;width:98%",!0),e(t,"top:0;left:0;height:100%;width:300px",!1),A="T";break;case"T":e(t,"top:0;left:0;height:100%;width:300px",!0),e(t,"top:0;left:0;height:300px;width:98%",!1),A="R";break;case"R":e(t,"top:0;left:0;height:300px;width:98%",!0),e(t,"top:0;right:0;height:100%;width:300px",!1),A="B";break;default:alert("Unrecognized position")}}function g(){r.innerHTML=B.checked?s.value:"",C()}function p(a){var c=t||b.getElementById("__panel");c&&(c.style.display=a?"block":"none")}if(b.getElementById("stylist:panel"))return void p(!0);var q=(b.getElementsByTagName("head")[0],b.body),r=b.createElement("style"),s=b.createElement("textarea"),t=b.createElement("div"),u=b.createElement("h1"),v=b.createElement("ul"),w=b.createElement("label"),x=b.createElement("a"),y=b.createElement("version"),z=b.createElement("button"),A=(b.createElement("button"),"B");a.chrome;t.style.display="block",s.spellcheck=!1,s.id="__input",t.id="__panel";var B=b.createElement("input");B.setAttribute("type","checkbox"),w.appendChild(B),w.appendChild(b.createTextNode("Apply CSS")),e(w,"font:12px monospace;vertical-align:middle;text-align:left"),e(B,"vertical-align:middle"),e(t,"position:fixed;top:0;right:0;width:300px;height:100%;z-index:2147483647;overflow:auto;outline:solid 1px #333;padding:0 20px;borderTop:0;borderBottom:0;borderRight:0;borderLeft:1px solid #ccc;color:#222;background:#fcfcfc"),e(s,"font:13px Inconsolata, Consolas, Menlo, Monaco, Lucida Console, Courier New, Courier, monospace;width:100%;height:calc(100% - 140px);direction:ltr;textAlign:left;background:#fcfcfc"),e(x,"display:none"),e(y,"font:9px monospace;color:#aaa;position:absolute;top:10px;right:40px"),y.innerHTML="v"+o,z.id="__close",z.setAttribute("title","Close this panel"),z.appendChild(b.createTextNode("X")),e(z,"position:absolute;top:10px;right:10px;cursor:pointer;transform:scale(0.8)"),r.setAttribute("type","text/css"),u.innerHTML="Stylist",e(u,"color:#555;background-color:#fcfcfc;width:150px;height:1.5em;margin:4px 0 4px 0;font-family:serif;font-size:20px;font-style:oblique;line-height:1.5em;box-shadow:none;text-shadow:none;text-align:left"),e(v,"font:12px monospace;list-style:none;margin-top:0px"),f(v,"CTRL+M: toggle this panel"),f(v,"CTRL+Y: change dock position"),f(v,"ALT+click: target element"),t.appendChild(u),t.appendChild(v),t.appendChild(w),t.appendChild(s),t.appendChild(y),t.appendChild(z),q.appendChild(t),q.appendChild(r),B.checked="true"===(localStorage.applyStyles||"true"),s.value=localStorage.siteStyle||"",s.placeholder="/* Enter your styles here. */",r.innerHTML=B.checked?s.value:"",q.addEventListener("click",function(a){if(-1===s.style.display.indexOf("none")&&a.target.id!==s.id&&a.altKey){var b,c,d=0,e=a.target,f=e.className.split(" ")||"",g=[],h="",i="";for(i+=e.tagName.toLowerCase(),e.id&&(i+="#"+e.id),d=0;d<f.length;d++)m.test(f[d])||(i+="."+f[d]);if(e.getAttribute("style"))for(g=e.getAttribute("style").split(";"),d=0;d<g.length;d++)b=g[d].split(n).join(" ").trim(),m.test(b)||(h+=k+b.toLowerCase()+";\n");i&&(h=h?"{\n"+h+"}":"{\n\n}",c="\n"+i+" "+h,s.value+=c,s.focus(),s.setSelectionRange(s.value.length-c.length,s.value.length)),a.preventDefault()}});var C=d(function(){localStorage.siteStyle=s.value,localStorage.applyStyles=B.checked?"true":"false",console.log("applyStyles :"+localStorage.applyStyles)},500);B.addEventListener("click",function(a){g()}),z.addEventListener("click",function(a){p(!1)}),s.addEventListener("keyup",g),s.addEventListener("change",g),s.addEventListener("keydown",function(a){var b=s.value,c=s.selectionStart;a.keyCode===h&&(s.value=b.substring(0,c)+k+b.substring(c),s.setSelectionRange(c+l,c+l),a.preventDefault())}),a.addEventListener("keydown",function(a){if(a.ctrlKey)switch(console.log(a.keyCode),a.keyCode){case j:p("none"===t.style.display);break;case i:c()}})}var h=9,i=89,j=77,k=" ",l=k.length,m=/^\s*$/,n=/\s+$/g,o="1.7";String.prototype.trim=function(){return this.replace(/(^\s+|\s+$)/g,"")},g()})(this,this.document);