Jump to content

User:Ansumang/qr.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/**************************************************************************/
/* Userscript to add a qrpedia.org code display option to toolbar
/*
/* Generates a QRWP.org code image using the current Wikipedia page URL.
/* Demo version so use at your own risk!
/*
/* importScript('User:Victuallers/QRcode.js');
/* Initial failure to display in the Toolbox may be due to:
/* . needing to purge the page cache
/* . or you may be on a page without "What links here"
/* . the order of javascript changes might stop the link being added. If you 
/*   have 'addOnloadHook', it may need to run there rather than earlier.
/*
/*  rhref=rhref.replace("wikipedia.org/wiki/", "qrwp.org/"); // Keep language. Change domain name. Correct path
/*  thref='http://chart.apis.google.com/chart?cht=qr&chs=400x400&chld=q&chl='+rhref; // Google Chart API
/*
/*  rhref=rhref.replace("en.wikipedia.org/wiki/", "EnWp.Org/"); /* change domain name and lose /wiki */
/*  thref='http://qrcode.kaywa.com/img.php?s='+5+'&d='+rhref; /* parameters: s=size, d=url */
/*
/* Link: http://enwp.org/User:Fæ/QRcode.js
/* More info on QR codes: http://qrwp.org/QR_code
/* More info on QRWP codes: http://qrpedia.org
/* Created by edent: 3 April 2011 
/**************************************************************************/
 
// Set up toolbox basics
var tid="t-qrcode",
 ttxt="Create QR code",
 rhref=location.href
 rhref=rhref.replace("en.wikipedia.org/wiki/", "qrwp.org/"); // Keep language. Change domain name. Correct path
 thref='http://chart.apis.google.com/chart?cht=qr&chs=400x400&chld=q&chl='+rhref; // Google Chart API
 
// Create link
var tul=document.getElementById("t-whatlinkshere"),ta=document.createElement("a"),tli=document.createElement("li");
ta.appendChild(document.createTextNode(ttxt));
ta.href=thref;
tli.appendChild(ta);
tli.id=tid;
tul.parentNode.appendChild(tli);