Jump to content

User:LOL/sandbox.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.
function lolsandbox() {
    var xmlhttp;
    if (window.XMLHttpRequest) {
        xmlhttp=new XMLHttpRequest();
    } else {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById('wpTextbox1').value = xmlhttp.responseText;
        }
    }
    var url = prompt('Enter the URL of a page whose source shall be fetched', 'URL');
    xmlhttp.open('GET', url, true);
    xmlhttp.send();
}

$(function() {
    if (document.forms.editform) {
        mw.util.addPortletLink('p-tb', 'javascript:lolsandbox()', 'Sandbox', 't-mmarecordcolumns', 'LOL', '', '');
    }
});