Skip to content

Commit

Permalink
bookmarklet working in Firefox - negate_iife option added to the ugli…
Browse files Browse the repository at this point in the history
…fy task
  • Loading branch information
anami committed Oct 28, 2014
1 parent f59820b commit a317ffe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
compress: {
negate_iife: false
}
},
normal: {
src: '<%= pkg.name %>.js',
dest: '<%= pkg.name %>.min.js'
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1>Stylist</h1>
<p>Add and edit live CSS to any page in any modern browser.. and have the changes persist everytime you run the bookmarklet on the page.</p>
<p>You may want a different look to a page that you regularly visit or help you style a page that you are developing.</p>
<p>Simply copy the link below as a bookmark - click the bookmark on the page you wish to change...</p>
<p><a href='javascript:!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){for(var c,d=b.split(";"),e=0,f=d.length;f>e;e++)c=d[e].split(":"),a.style.setProperty(c[0],c[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(){o.innerHTML=p.value,t()}if(b.getElementById("stylist:panel"))return void alert("Stylist is already running - CTRL+M to open panel");var g=b.getElementsByTagName("head")[0],n=b.body,o=b.createElement("style"),p=b.createElement("textarea"),q=b.createElement("div"),r=b.createElement("h1"),s=b.createElement("ul");q.style.display="block",p.spellcheck=!1,p.id="stylist:input",q.id="stylist:panel",e(q,"position:fixed;top:0;right:0;width:300px;height:100%;z-index:2147483647;overflow:auto;outline:none;padding:10px 20px;borderTop:0;borderBottom:0;borderRight:0;borderLeft:1px solid #ccc;color:#222;background:#fcfcfc"),e(p,"font:13px Inconsolata, Consolas, Menlo, Monaco, Lucida Console, Courier New, Courier, monospace;width:100%;height:calc(100% - 120px);direction:ltr;textAlign:left;background:#fcfcfc"),r.innerHTML="Stylist",e(r,"color:#555;background-color:#fcfcfc;width:150px;height:1.5em;margin:4px 0 4px 0;font-family:monospace"),e(s,"font:12px monospace;list-style:none;margin-left:-30px"),f(s,"CTRL+M: toggle this panel"),f(s,"ALT+click: target element"),q.appendChild(r),q.appendChild(s),q.appendChild(p),g.appendChild(o),n.appendChild(q),o.innerHTML=localStorage.siteStyle||"",p.value=o.innerHTML,p.placeholder="/* Enter your styles here. */",n.addEventListener("click",function(a){if(-1===p.style.display.indexOf("none")&&a.target.id!==p.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++)l.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(m).join(" ").trim(),l.test(b)||(h+=j+b.toLowerCase()+";\n");i&&(h=h?"{\n"+h+"}":"{\n\n}",c="\n"+i+" "+h,p.value+=c,p.focus(),p.setSelectionRange(p.value.length-c.length,p.value.length)),a.preventDefault()}});var t=d(function(){localStorage.siteStyle=o.innerHTML},500);p.addEventListener("keyup",c),p.addEventListener("change",c),p.addEventListener("keydown",function(a){var b=p.value,c=p.selectionStart;a.keyCode===h&&(p.value=b.substring(0,c)+j+b.substring(c),p.setSelectionRange(c+k,c+k),a.preventDefault())}),a.addEventListener("keydown",function(a){a.ctrlKey&&a.keyCode===i&&(q.style.display="none"==q.style.display?"block":"none")})}var h=9,i=77,j=" ",k=j.length,l=/^\s*$/,m=/\s+$/g;String.prototype.trim=function(){return this.replace(/(^\s+|\s+$)/g,"")},g()}(this,this.document);'>Run Stylist</a></p>
<p><a href='javascript:(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){for(var c,d=b.split(";"),e=0,f=d.length;f>e;e++)c=d[e].split(":"),a.style.setProperty(c[0],c[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(){o.innerHTML=p.value,t()}if(b.getElementById("stylist:panel"))return void alert("Stylist is already running - CTRL+M to open panel");var g=b.getElementsByTagName("head")[0],n=b.body,o=b.createElement("style"),p=b.createElement("textarea"),q=b.createElement("div"),r=b.createElement("h1"),s=b.createElement("ul");q.style.display="block",p.spellcheck=!1,p.id="stylist:input",q.id="stylist:panel",e(q,"position:fixed;top:0;right:0;width:300px;height:100%;z-index:2147483647;overflow:auto;outline:none;padding:10px 20px;borderTop:0;borderBottom:0;borderRight:0;borderLeft:1px solid #ccc;color:#222;background:#fcfcfc"),e(p,"font:13px Inconsolata, Consolas, Menlo, Monaco, Lucida Console, Courier New, Courier, monospace;width:100%;height:calc(100% - 120px);direction:ltr;textAlign:left;background:#fcfcfc"),r.innerHTML="Stylist",e(r,"color:#555;background-color:#fcfcfc;width:150px;height:1.5em;margin:4px 0 4px 0;font-family:monospace"),e(s,"font:12px monospace;list-style:none;margin-left:-30px"),f(s,"CTRL+M: toggle this panel"),f(s,"ALT+click: target element"),q.appendChild(r),q.appendChild(s),q.appendChild(p),g.appendChild(o),n.appendChild(q),o.innerHTML=localStorage.siteStyle||"",p.value=o.innerHTML,p.placeholder="/* Enter your styles here. */",n.addEventListener("click",function(a){if(-1===p.style.display.indexOf("none")&&a.target.id!==p.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++)l.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(m).join(" ").trim(),l.test(b)||(h+=j+b.toLowerCase()+";\n");i&&(h=h?"{\n"+h+"}":"{\n\n}",c="\n"+i+" "+h,p.value+=c,p.focus(),p.setSelectionRange(p.value.length-c.length,p.value.length)),a.preventDefault()}});var t=d(function(){localStorage.siteStyle=o.innerHTML},500);p.addEventListener("keyup",c),p.addEventListener("change",c),p.addEventListener("keydown",function(a){var b=p.value,c=p.selectionStart;a.keyCode===h&&(p.value=b.substring(0,c)+j+b.substring(c),p.setSelectionRange(c+k,c+k),a.preventDefault())}),a.addEventListener("keydown",function(a){a.ctrlKey&&a.keyCode===i&&(q.style.display="none"==q.style.display?"block":"none")})}var h=9,i=77,j=" ",k=j.length,l=/^\s*$/,m=/\s+$/g;String.prototype.trim=function(){return this.replace(/(^\s+|\s+$)/g,"")},g()})(this,this.document);'>Run Stylist</a></p>
<p>Once you have clicked the bookmarklet - the panel should open and you're good to go..</p>
<h2>Rationale</h2>
<p>I wasn't aware of any live CSS editors at the time. However upon finding them, they seem to live as extensions for those browsers. You'd need to download and install the extension on each browser. </p>
Expand Down
2 changes: 1 addition & 1 deletion stylist.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a317ffe

Please sign in to comment.