MediaWiki:IMO magic.js

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/* [[Commons:IMO sources]]
 * Quick and dirty for generic sources pages
 * by [[User:Dispenser]]
 */
$(function() {
    // Retrieve and escape the replacement for MAGICNUMBER
    var mn_replacement = mw.util.getParamValue("imon");
    if(!mn_replacement) {
        // Null or blank value
        return;
    }
    if(!mn_replacement.match(/^\d+$/)) {
        // Invalid value
        return;
    }
    // Replace HTML with magic number text
    $('#mw-content-text')[0].innerHTML = $('#mw-content-text')[0].innerHTML.replace(/MAGICNUMBER/g, mw.html.escape(mn_replacement));
    // Remove the no JavaScript notice
    $("#nojs-notice").remove();
});