Jump to content

User:Dominic/monobook.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 uploadbatch() {
  if((document.title.indexOf('Upload file - ') == 0)&&(queryString('wpUploadFile'))) {
    try { netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead'); }
    catch($err) {
      var $privileges = false;
      alert('Error: Unable to perform file upload. App was denied elevated privileges to do so.');
      return;
    }
    if((queryString('wpUploadFile'))&&(document.getElementById('wpUploadFile').value == '')) document.getElementById('wpUploadFile').value = decodeURIComponent(queryString('wpUploadFile')).replace(/\+/g,' ')
    if((queryString('wpDestFile'))&&(document.getElementById('wpDestFile').value == '')) document.getElementById('wpDestFile').value = decodeURIComponent(queryString('wpDestFile')).replace(/\+/g,' ')
    if((queryString('wpUploadDescription'))&&(document.getElementById('wpUploadDescription').value == '')) document.getElementById('wpUploadDescription').value = decodeURIComponent(queryString('wpUploadDescription')).replace(/\+/g,' ')
    if(queryString('wpUpload') == 'submit') document.forms[0].wpUpload.click()
  }
}
addOnloadHook(uploadbatch);

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