Jump to content

User:Rankiri/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.
importScript('User:Sander Säde/quickpreview.js');
importScript('User:AzaToth/twinkle.js');


/* 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;
  if(xmlreq.responseText.indexOf('revid=')==-1)
  {
    document.getElementById('contentSub').innerHTML+=
      "<div class='watchlistnotify'>(<i>watchlistnotifier can't determine whether a "+
      "watched page has changed<i>)</div>";
    return;
  }
  watchrev=xmlreq.responseText.split('revid="')[1].split('"')[0];
  try
  {
    watchrevold=document.cookie.split('ais523wmwatchrev=')[1].split('.')[0];
  }
  catch(junk) {watchrevold=0;}
  if(wgPageName == "Special:Watchlist")
  {
    document.cookie="ais523wmwatchrev="+watchrev+".; path=/";
    var aas=document.getElementById('bodyContent').getElementsByTagName('a');
    var i=aas.length;
    while(i--)
    {
      if(aas[i].href.indexOf('diff=')!=-1&&watchrevold)
        if(+(aas[i].href.split('diff=')[1].split('&')[0])>watchrevold)
          aas[i].parentNode.style.fontWeight='bold';
    }
  }
  else
  {
    watchsum=xmlreq.responseText.split('comment="')[1].split('"')[0];
    watchpage=xmlreq.responseText.split('title="')[1].split('"')[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+
        '". (<a href="/wiki/Special:Watchlist">watchlist</a>)</div>';
  }
}
 
addOnloadHook(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. */
    wmwpajax.download({url:'http://en.wikipedia.org/w/api.php?action=query&list=watchlist&wllimit=1&'+
      'wldir=older&format=xml&wlprop=comment|ids|title', onSuccess: wmWatchEditFound});
});
// </nowiki></pre>
// [[Category:Wikipedia scripts]]

// [[User:Lupin/popups.js]]
//Customization Options at http://en.wikipedia.org/wiki/Wikipedia:Tools/Navigation_popups#Installation
importScript('User:Lupin/popups.js');
popupDelay=0.5
popupHideDelay=0.45
imagePopupsForImages=false
popupMaxWidth=500
popupRevertSummaryPrompt=true
popupHistoryPreviewLimit=20
popupMaxPreviewSentences=5
popupMaxPreviewCharacters=600
popupPreviewFirstParOnly=true


//------------Wikipedia:WikiProject User scripts/Scripts/qSig-----------
if ((wgNamespaceNumber % 2 || wgNamespaceNumber==4) 
 &&  document.URL.match(/&action=(edit|submit)/))
addOnloadHook(function(){
 
 var wpSave = document.getElementById('wpSave');
 if (!wpSave) return;
 
 if (window.sigText) //change normal sig button as well
   mwEditButtons[9].tagOpen = sigText;
 else 
   sigText = '— ~~' + '~~';
 
 //create button
 var btn = document.createElement('input');
 btn.type='button'; btn.value = 'Sign';
 btn.onclick = function(){ insertTags(sigText,'','') };
 btn.style.marginRight = '4px'; 
 btn.title = 'Put your signature';
 if (window.sigAccessKey){
   btn.accessKey = sigAccessKey;
   btn.title += ' [' + tooltipAccessKeyPrefix + btn.accessKey + ']';
 } 
 wpSave.parentNode.insertBefore(btn, wpSave);
 
  //for 'Wikipedia:' namespace: Sig is ok on Forum pages, on all others put it after Save button
 if ( ( wgNamespaceNumber == 4 )
  && ( !wgTitle.match('^(Village pump [(]|Reference desk/|Deletion review/|Articles for deletion/|Templates for deletion/|.*noticeboard.*|Requests for (adminship|checkuser|arbitration|feedback|page protection|mediation)|Bot requests|Help desk|Editor review|Adminship survey|Cleanup|Miscellany for deletion|New contributors\' help page|Media copyright questions)')  ) ) 
 {
   wpSave.parentNode.insertBefore(btn, wpSave.nextSibling);
   return; //avoid warning below
 }
 
 //warn if saving without signature 
 wpSave.onclick = function(){
 if (document.editform.wpTextbox1.value.indexOf('~\~~') >= 0 )
  return true
 else 
  return confirm('No signature?')
 }
})
//-------------------------------------------