User:Circuit Judge/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.
// [[User:Lupin/popups.js]] - please include this line 
 
mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');
 
 
 
importScript('User:AzaToth/twinkle.js');
 
TwinkleConfig = {
        revertMaxRevisions              :       50,
        userTalkPageMode                :       'blank',
        showSharedIPNotice              :       false,
        openTalkPage                    :       ['norm', 'vand' ],
        openTalkPageOnAutoRevert        :       false,
        openAOLAnonTalkPage             :       true,
        summaryAd                       :       " ",
        deletionSummaryAd               :       " ",
        protectionSummaryAd             :       " ",
        watchSpeedyPages                :       [ ],
        watchProdPages                  :       true,
        openUserTalkPageOnSpeedyDelete  :       [ ],
        watchRevertedPages              :       [ ],
        markRevertedPagesAsMinor        :       ['agf' ],
        watchWarnings                   :       false,
        markAIVReportAsMinor            :       false,
        markSpeedyPagesAsMinor          :       true,
        markProdPagesAsMinor            :       false,
        confirmUsernameToAIV            :       true,
        toolboxButtons                  :       ['tw-prod', 'tw-rpp', 'tw-since', 'tw-sincemine'  ]
};
 
 
/* Watchlist notifier ([[User:Ais523/watchlistnotifier.js]]); displays a message every time a watched page changes. */
//<pre><nowiki>
 
var wmwpajax;
// From [[WP:US]] mainpage (wpajax renamed to wmwpajax)
wmwpajax={
        download:function(bundle) {
                // mandatory: bundle.url
                // optional:  bundle.onSuccess (xmlhttprequest, bundle)
                // optional:  bundle.onFailure (xmlhttprequest, bundle)
                // optional:  bundle.otherStuff OK too, passed to onSuccess and onFailure
 
                var x = window.XMLHttpRequest ? new XMLHttpRequest()
                : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP")
                : false;
 
                if (x) {
                        x.onreadystatechange=function() {
                                x.readyState==4 && wmwpajax.downloadComplete(x,bundle);
                        };
                        x.open("GET",bundle.url,true);
                        x.send(null); 
                }
                return x;
        },
 
        downloadComplete:function(x,bundle) {
                x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true )
                || ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText+': '+bundle.url));
        }
};
 
// Example:
// function dlComplete(xmlreq, data) {
//      alert(data.message + xmlreq.responseText);
// }
//  wmwpajax.download({url:'http://en.wikipedia.org/w/index.php?title=Thresher&action=raw', 
//                   onSuccess: dlComplete, message: "Here's what we got:\n\n" });
 
// End of [[WP:US]] quote
 
function wmWatchEditFound(xmlreq, data) {
  var watchrev, watchsum, watchrevold, watchpage, junk;
  watchrev=xmlreq.responseText.split('timestamp="')[1].split('"')[0];
  if(wgPageName == "Special:Watchlist")
    document.cookie="ais523wmwatchrev="+watchrev+".; path=/";
  else
  {
    watchsum=xmlreq.responseText.split('comment="')[1].split('"')[0];
    watchpage=xmlreq.responseText.split('title="')[1].split('"')[0];
    try
    {
      watchrevold=document.cookie.split('ais523wmwatchrev=')[1].split('.')[0];
    }
    catch(junk) {watchrevold=0;}
    watchsum=watchsum.split('<').join('&lt;').split('>').join('&gt;');
    watchpage=watchpage.split('<').join('&lt;').split('>').join('&gt;');
    if(watchrev!=watchrevold)
      document.getElementById('contentSub').innerHTML+=
        "<div class='watchlistnotify'>\""+watchpage+'" changed: "'+watchsum+'".</div>';
  }
}
 
$(function() {
  /* Find the top item in the watchlist, and its edit summary. We only need one item, so
     set the limit to 1 to ease the load on the server. */
  //if(location.href.indexOf("/wiki/")!=-1)
    wmwpajax.download({url:'http://en.wikipedia.org/w/api.php?action=query&list=watchlist&wllimit=1&'+
      'wldir=older&format=xml&wlprop=comment|timestamp|title', onSuccess: wmWatchEditFound});
});
// </nowiki></pre>
// [[Category:Wikipedia scripts]]
 
 
importScript('User:TheJosh/Scripts/NewPagePatrol.js');
 
 
importScript('User:Tra/userwatchlist.js'); //[[User:Tra/userwatchlist.js]]
 
 
// CleanupTab.js
//
// This script adds a "cleanup" tab to the top of article pages
// when in edit mode. It is disabled for the User namespace.
 
function doCleanup() {
  document.editform.wpTextbox1.value = '{' + '{' + 'Cleanup|date=' + '{' + '{' + 'subst:CURRENTMONTHNAME}} ' + '{' + '{' + 'subst:CURRENTYEAR}}}}\n\n' + document.editform.wpTextbox1.value;
  document.editform.wpSummary.value = 'Marked for cleanup.';
  document.editform.wpMinoredit.checked = true;
  document.editform.submit();
}
 
$(function() {
  if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
     return;
  }
  if (document.editform) {
     mw.util.addPortletLink("p-cactions", "javascript:doCleanup()", "cleanup", "ca-cleanup", "Mark for cleanup", "");
  }
});
 
//
 
 
/* <pre><nowiki> */
 
//Please adjust the following variables according to when you want to end your break:
var year = 2008; //YYYY
var month = 01; //MM
var day = 01; //DD
var hour = 08; //HH
var minute = 00; //MM
var second = 00; //SS 
 
function EnforceWikiBreak() {
    var currentdate = new Date();
    var enforced_break_end = new Date(year,changemonth(),day,hour,minute,second);
    if (currentdate > enforced_break_end) {
      // alert ("Welcome back from your enforced wikibreak!");
    } else {
      alert ("No way!! You're on an Enforced Wikibreak until " + enforced_break_end.toLocaleString() + " (currently " + currentdate.toLocaleString() + "). Bye!");
      window.location.href = ("http://"+document.location.host+"/w/index.php?title=Special:Userlogout&returnto=Main_Page");
    }
}
 
function changemonth() {
//thing to subtract 1 from the month. you can't use month-1 because it removes the '0' from the front
if(month==01) return 00;
if(month==02) return 01;
if(month==03) return 02;
if(month==04) return 03;
if(month==05) return 04;
if(month==06) return 05;
if(month==07) return 06;
if(month==08) return 07;
if(month==09) return 08;
if(month==10) return 09;
if(month==11) return 10;
if(month==12) return 11;
return 00;
}
 
$(function() { EnforceWikiBreak(); });
 
/* </nowiki></pre> */
 
 
function resetSandbox() {
    document.editform.wpTextbox1.value = "\{\{Please leave this line alone (sandbox heading)\}\}\n" + 
"<!-- Hello! Feel free to try your formatting and editing skills below this line\. As this page is for editing experiments, this page will automatically be cleaned every 12 hours. -->"; //Add the base text for the sandbox
    document.editform.wpSummary.value = "Script-based reset of sandbox"; //Make a descriptive edit summary
    document.editform.wpMinoredit.checked = false; //Make it a minor edit
    document.editform.wpSave.click(); //Submit it!
}
 
function addResetTab() {
    if( wgPageName == "Wikipedia:Sandbox" && ( wgAction == "edit" || wgAction == "submit" ) ) //Add the tab for previews, edit conflicts, and bare editing of the sandbox 
      { mw.util.addPortletLink('p-cactions', 'javascript:resetSandbox()', 'reset', 'ca-reset', "Reset the Sandbox"); }
}
 
$(addResetTab);