Skip to content

Instantly share code, notes, and snippets.

@sacrifs
Last active December 24, 2015 15:49
Show Gist options
  • Save sacrifs/6823348 to your computer and use it in GitHub Desktop.
Save sacrifs/6823348 to your computer and use it in GitHub Desktop.
表示しているWebサイトの2次元バーコードを生成するブックマークレット
javascript: (function(){
var d = window.document;
function loaded(){
var b = d.createElement('div');
var q = d.createElement('div');
$(b).css({position:'fixed',width:'100%',height:'100%',background:'#FFFFFF',zIndex:0x7FFFFFFF,top:0,left:0}).on('click', hide);
$(q).qrcode(location.href).css({zIndex:0x7FFFFFFF,position:'fixed',left:'50%',top:'50%',marginLeft:'-128px',marginTop:'-128px'}).on('click', hide);
d.body.appendChild(b);
d.body.appendChild(q);
function hide(){$(b).hide();$(q).hide();}
}
var sjq = d.createElement('script');
var sqr = d.createElement('script');
sjq.src = '/\/code.jquery.com/jquery-1.10.2.min.js';
sqr.src = '/\/cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js';
d.body.appendChild(sjq);
sqr.onload = loaded;
sqr.onreadystatechange=function(){if(this.readyState=='loaded'||this.readyState=='complete'){loaded();}};
d.body.appendChild(sqr);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment