Jump to content

User:Anas Salloum/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.
//<nowiki>
importScript('User:AzaToth/twinkle.js');

TwinkleConfig = {
        revertMaxRevisions              :       50,
        userTalkPageMode                :       'tab',
        showSharedIPNotice              :       false,
        openTalkPage                    :       [ 'agf', 'norm', 'vand' ],
        openTalkPageOnAutoRevert        :       false,
        openAOLAnonTalkPage             :       false,
        summaryAd                       :       "",
        deletionSummaryAd               :       "",
        protectionSummaryAd             :       "",
        watchSpeedyPages                :       [ 'g3', 'g5', 'g10', 'g11', 'g12' ],
        watchProdPages                  :       true,
        openUserTalkPageOnSpeedyDelete  :       [ 'g1', 'g2', 'g10', 'g11', 'g12', 'a1', 'a7', 'i3', 'i4', 'i5', 'i6', 'i7', 'u3', 't1' ],
        watchRevertedPages              :       [ ],
        markRevertedPagesAsMinor        :       [ 'agf', 'norm', 'vand', 'torev' ],
        deleteTalkPageOnDelete          :       false,
        watchWarnings                   :       false,
        markWarningsAsMinor             :       false,
        markAIVReportAsMinor            :       false,
        markSpeedyPagesAsMinor          :       true,
        offerReasonOnNormalRevert       :       true,
        orphanBacklinksOnSpeedyDelete   :       true
};

(function () {
    var oldAddButton = addButton;
    if (typeof(oldAddButton) != 'function') return;
    addButton = function () {
        if (arguments.length > 2)
            arguments[2] = arguments[2].replace(/^--(~+)$/, '—$1');
        oldAddButton.apply(this, arguments);
    };
})();

//

// CSD AutoReason
importScript('User:^demon/csd.js');


//this helps automate AfD closing by adding a 'close' tab to AfD debates
//written by [[User:Johnleemk]] based on [[Wikipedia:WikiProject User scripts/Scripts/test-n.js]] by [[User:Celestianpower]]

function autoafd_result()
{
  var close = prompt("Result of debate?")
  var f = document.editform, t = f.wpTextbox1;
  t.value = t.value.split('{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD').join('{{ns:0');
  t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "~" + "~" + "~" + "~" + '\n' + '\n' + t.value;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "ab" + "}}";
  f.wpSummary.value = "Closing debate; result was " + close;
}

function autoafd_relist()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "relist" + "|~" + "~" + "~" + "~}}";
  f.wpSummary.value = "Relisting debate";
}

function autoafd_keep()
{
  var date = prompt("Nomination was made when?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD";
}

function autoafd_no_consensus()
{
  var date = prompt("Nomination was made when?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD with no consensus";
}

function autoafd_redirect()
{
  var date = prompt("Nomination was made when?")
  var redirect = prompt("Redirect to?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD";
}

function autoafd_merge()
{
  var date = prompt("Nomination was made when?")
  var redirect = prompt("Merge and redirect to?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''merge and redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article merged and redirected to [[" + redirect + "]] as per AfD";
}

function autoafd_other()
{
  var date = prompt("Nomination was made when?")
  var result = prompt("Result was?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "AfDed; result was " + result;
}

function autoafd_add_afd_tabs()
{
  // Only add for pages with the right string somewhere in the title
  if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1)
    {
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_result()', "close");
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_relist()', "relist");
    }
  if (document.title.indexOf("Editing Talk:") != -1)
    {
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_keep()', "keep");
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_no_consensus()', "no consensus");
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_redirect()', "redirect");
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_merge()', "merge");
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_other()', "other");
    }
}

$(autoafd_add_afd_tabs);

//end AfD closing script

importScript('User:ais523/editcount.js'); //[[User:ais523/editcount.js]]



var predefinedSummaries = {
    "Summary": "blank",
    "AfD": "Article has survived AfD; removing tag",
    "Fix": "Minor fix/tweak",
    "Syria": "WikiProject Syria assessment",
    "Typo": "Fixing typos",
    "Ref": "Added references",
    "Cat": "Categorizing article",
    "Stub": "Stub sort"
};
$(function () {
    var summary = document.getElementById("wpSummary");
    if (!summary) return;

    var dropdown = document.createElement("select");
    dropdown.style.width = "15%";

    for (var label in predefinedSummaries) {
        var option = document.createElement("option");
        option.setAttribute("value", predefinedSummaries[label]);
        option.appendChild(document.createTextNode(label));
        dropdown.appendChild(option);
    }

    dropdown.onchange = function () {
        summary.value = summary.value.replace(/(\/\*.*?\*\/\s+)?.*/,
            "$1" + dropdown.options[dropdown.selectedIndex].value);
    };

    summary.parentNode.insertBefore(dropdown, summary.nextSibling);
});

XEBOrder='0,1,2,3,4,AI,6,7,8,9,FS,10,V,S,I1,I2,J1,H,G,M,E,B,X,K,P,R1,TL,Z,_RW,_RB,_RN';
rmEditButtons=['all'];
myButtons={'_AR':['/media/wikipedia/commons/4/47/Button_arabic.png','Insert Template:Lang-ar','({{lang-ar|','}})','Text'],
           '_RW':['/media/wikipedia/commons/9/91/Button_cite_web.png','Cite Web','{{cite web','}}','|url= |title= |accessdate= |last= |first= |authorlink= |coauthors= |date= |publisher= |pages= |language= |quote= '],
           '_RB':['/media/wikipedia/commons/e/ef/Button_cite_book.png','Cite Book','{{cite book','}}','|last= |first= |authorlink= |coauthors= |title= |url= |year= |month= |publisher= |location= |language= |isbn= |pages= '],
           '_RN':['/media/wikipedia/commons/2/2c/Button_cite_news.png','Cite News','{{cite news','}}','|first= |last= |authorlink= |author= |coauthors= |title= |url= |publisher= |id= |pages= |page= |date= |accessdate= |language= |quote= ']};
importScript('User:MarkS/extraeditbuttons.js'); //[[User:MarkS/extraeditbuttons.js]]

// Arabic tagging script, by [[User:ais523]] on a request by [[User:Anas Salloum]]
$(function()
{
  var actionToTake='wpSave'; // you can change to wpSave once you're happy this works properly
 
  if(wgAction=="view"&&location.href.indexOf("/wiki/")!=-1)
  {
    if(wgNamespaceNumber==1) //talk page
    {
      mw.util.addPortletLink('p-cactions', "javascript:arremovetag();","ar","ca-ar","remove {"+"{arabic}} tag","");
    }
    else if(wgNamespaceNumber==0) //article
    {
      mw.util.addPortletLink('p-cactions', "javascript:araddtag();","ar","ca-ar","add {"+"{lang-ar}} tag","");
    }
  }
  if(location.href.indexOf("&arremovetag=yes")!=-1)
  {
    var tb1=document.getElementById('wpTextbox1');
    tb1.value=tb1.value.split(/\{\{\ *[aA]rabic\ *(\|[^}]*)?\}\}/).join("");
    document.getElementById('wpSummary').value="Removing {"+"{[[Template:Arabic|Arabic]]}}";
    document.getElementById(actionToTake).click();
  }
  else if(location.href.indexOf("&araddtag=")!=-1)
  {
    var x=decodeURIComponent(location.href.split("&araddtag=")[1]);
    var tb1=document.getElementById('wpTextbox1');
    var a=tb1.value.split("'''");
    if(a.length<3)
    {
      alert("Couldn't figure out where to put the tag; try adding it manually.");
      return;
    }
    a[2]=" ({"+"{lang-ar|'''"+x+"'''}})"+a[2];
    tb1.value=a.join("'''");
    document.getElementById('wpSummary').value="Adding original [[Arabic alphabet|Arabic script]]";
    document.getElementById('wpSave').click(); //too dangerous to save without user intervention
  }
});
 
function arremovetag()
{
  location.href+="?action=edit&arremovetag=yes";
}
function araddtag()
{
  var x=prompt("Please enter the parameter for the {"+"{lang-ar}} tag (it will be bolded "+
               "automatically):");
  if(x==null) return
  location.href+="?action=edit&araddtag="+encodeURIComponent(x);
}
//</nowiki>