Permalink
Browse files

Fixes to gumroad2qr

Stupid JS doesn't support factoring out x.y expressions if y is a
method, so need to create function literals.

Also removed some useless interior spaces.
  • Loading branch information...
1 parent f2962f2 commit 1d6117054c7c43fabe2481b245a4b7f15fbbd4d4 @xenomachina committed Apr 5, 2012
Showing with 13 additions and 12 deletions.
  1. +13 −12 bookmarklets/gumroad2qr.bookmarklet
@@ -2,22 +2,23 @@
// you can print. It removes links and the purchase form, and replaces
// the buy button with a QR code and URL.
-var d = document;
-var I = d.getElementById;
-var R = function(x){x.parentElement.removeChild(x);}
-var b = I('i_want_this_button');
-var p = b.parentElement;
-R(b)
-var img = d.createElement('img');
+var d=document;
+var I=function(x){return d.getElementById(x);};
+var R=function(x){x.parentElement.removeChild(x);};
+var b=I('i_want_this_button');
+var p=b.parentElement;
+R(b);
+var img=d.createElement('img');
img.src='http://chart.googleapis.com/chart?chs=200x200&cht=qr&choe=UTF-8&chld=L|0&chl=' + escape(d.location);
img.style.padding='1em';
-var c = d.createElement('center');
+var c=d.createElement('center');
c.style.fontSize='200%';
c.style.fontFamily='monospace';
-c.appendChild(img);
-c.appendChild(d.createElement('br'));
-c.appendChild(d.createTextNode(d.location));
-p.appendChild(c);
+var A=function(p,c){p.appendChild(c);};
+A(c,img);
+A(c,d.createElement('br'));
+A(c,d.createTextNode(d.location));
+A(p,c);
R(I('buy-form-main'));
R(I('sharing'));
R(d.getElementsByClassName('gumroad-pitch')[0]);

0 comments on commit 1d61170

Please sign in to comment.