Jump to content

User:AndyZ/monobook.js/footnote.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.
winc('User:Omegatron/monobook.js/addlink.js');

function convertToFootnote(){
var usure = confirm("Are you sure you wish to convert all of the external links into footnotes? Remember that this script converts external links underneath =External links= section into footnotes also if run.")
if (usure) convertingnow()
}

function convertingnow(){
var memory = document.editform.wpTextbox1.value
theText = document.editform.wpTextbox1.value

//the first line converts the beginning of an external link, the second converts the end
theText = theText.replace(/\[htt/g,"<ref>[htt")
theText = theText.replace(/([^\]])\]([^\]])/g,"$1]</ref>$2")
 
if(memory==theText){
alert("Matched!")	
}
document.editform.wpTextbox1.value = theText
}

addOnloadHook(function () {
    if(document.forms.editform) {
        addLink('p-cactions', 'javascript:convertToFootnote()', 'Ref', 'ca-unitfixer', 'Converts inline external links to the cite.php footnote system', '', '');
    }
});