User:JoeSmack/welcometab.js

if(wgAction == 'edit' || wgAction == 'view') addOnloadHook(refbuttons) function refbuttons { var yesref='/wiki/Special:Random'; if(wgAction == 'edit') { var noref='javascript:reftag;'; } else { var noref='javascript:edreftag;'; } mw.util.addPortletLink('p-cactions',yesref,'y ref','ca-yesref','Go to random article'); mw.util.addPortletLink('p-cactions',noref,'n ref','ca-noref','tag with '); }

function reftag { if(document.getElementById('wpTextbox1').value.indexOf('{'+'{references}}') != -1) { alert('Warning: There is already a references tag present. \nNo action taken.'); return; } document.getElementById('wpTextbox1').value = '{'+'{references}}\n' + document.getElementById('wpTextbox1').value; var saveme = confirm('A {'+'{references}} tag has been added to the top of this section.\nDo you want to save this page automatically?\n\nClick cancel/escape to abort, to move the tag, or to save manually.'); document.getElementById('wpSummary').value = ' - this article or section does not cite any references or sources. Please help improve this article by adding citations to reliable sources.'; document.getElementById('wpMinoredit').checked = true; // if(saveme) document.getElementById('wpPreview').click if(saveme) document.getElementById('wpSave').click }

function edreftag { var url = document.getElementById('ca-edit').firstChild.href; document.location.href = url + '&addreftag=true'; } if(queryString("addreftag") == "true") addOnloadHook(reftag);

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { }       }        return null; }