Created
March 12, 2012 14:24
-
-
Save cyroxx/2022237 to your computer and use it in GitHub Desktop.
Userscript: Show a QR code in order to easily open up the same page on your mobile device.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Google Play QR Code | |
// @namespace Google Play | |
// @description Show a QR code in order to easily open up the same page on your mobile device. | |
// @include https://play.google.com/store/apps/details?id=* | |
// ==/UserScript== | |
(function() { | |
findxpath = function(root, xpath) { | |
return document.evaluate(xpath, root, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
} | |
findxpath_singleNode = function(root, xpath) { | |
return document.evaluate(xpath, root, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
}; | |
let path = findxpath_singleNode(document, "//link[@rel='canonical']").href; | |
let blocks = findxpath(document, "//td[contains(@class, 'doc-banner-title-container')]"); | |
var newImg = document.createElement("img"); | |
newImg.src = "http://chart.googleapis.com/chart?chs=100x100&cht=qr&chld=L|1&chl=" + encodeURIComponent(path); | |
newImg.alt = "QR code link to this page"; | |
for (i = 0; block = blocks.snapshotItem(i); i++) { | |
// insert QR code as first child | |
block.insertBefore(newImg, block.firstChild); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment