Ryan's Blog

Like Twitter, but longer


Add a QR code to every webpage

This is a greasemonkey script that encodes the URL of the page you're viewing in a QR code. You can then use the QR code to open the same page in your mobile device. It uses Google Charts to generate a png which it puts unobtrusively in the bottom left hand corner of the browser viewport. Click on the image to pull it into view (and again to hide it). // ==UserScript== // @name Add QR code // @namespace all // @include http://* // ==/UserScript== GM_addStyle(().toString()); function toggleCode() { code = document.getElementById(codeID); if(code.className == "gm-qr-show") { code.className=""; } else { code.className ="gm-qr-show"; } } codeID = "gm-qr-code"; img_src = "http://chart.apis.google.com/chart?choe=ISO-8859-1&chs=100x100&cht=qr&chl="; if(window.top == window.self) { page_url = window.location; img_src += encodeURI(page_url); i = document.createElement("img"); i.src=img_src; i.id = codeID; i.addEventListener("click", toggleCode, false); body = document.getElementsByTagName("body")[0]; body.appendChild(i); } Edit: Updated to ignore iframes.