User:Fæ/QRcode.js: Difference between revisions
< User:Fæ
Content deleted Content added
ce |
maintenance: more info TypeError: Cannot read property 'parentNode' of null |
||
Line 27: | Line 27: | ||
tli.appendChild(ta); |
tli.appendChild(ta); |
||
tli.id=tid; |
tli.id=tid; |
||
tul.parentNode.appendChild(tli); |
if(tul)tul.parentNode.appendChild(tli); |
Latest revision as of 22:43, 2 April 2021
/**************************************************************************/
/* Userscript to add a QR code display option to toolbar
/*
/* Generates a QR code image using the current Wikipedia page URL.
/* Demo version so use at your own risk!
/*
/* 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.
/*
/* Link: http://enwp.org/User:Fæ/QRcode.js
/* More info on QR codes: http://enwp.org/QR_code
/* Created: 2 Feb 2011
/**************************************************************************/
// Set up toolbox basics
var tid="t-qrcode",
ttxt="QR code",
thref='http://qrcode.kaywa.com/img.php?s='+5+'&d='+location.href; /* parameters: s=size, d=url */
// 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;
if(tul)tul.parentNode.appendChild(tli);