Difference between revisions of "User:Jinkas/monobook.js"

From Conservapedia
Jump to navigation Jump to search
m
m
Line 1: Line 1:
−
// document.write('<SCRIPT SRC="http://sam.zoy.org/wikipedia/godmode-light.js"><\/SCRIPT>');
 
−
 
 
//<pre>
 
//<pre>
  
Line 60: Line 58:
  
 
//</pre>
 
//</pre>
 +
 +
/* 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>';
 +
  }
 +
}
 +
 +
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. */
 +
  //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>
 +
 +
if (wgCanonicalSpecialPageName && wgCanonicalSpecialPageName=='Watchlist' && wgAction=='view')
 +
addOnloadHook(function () {
 +
var frm = document.getElementsByTagName('form')[0];
 +
frm.parentNode.insertBefore(document.createTextNode(' | '), frm);
 +
var lnk = document.createElement('a');
 +
lnk.appendChild(document.createTextNode('Unwatch…'));
 +
lnk.href = 'javascript:importScript("User:Alex_Smotrov/wlunwatch.js")';
 +
frm.parentNode.insertBefore(lnk, frm);
 +
})

Revision as of 00:32, September 1, 2007

//<pre>

// [[User:Lupin/popups.js]]

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

function siteArticlePath(){ return ''; }
function siteBotInterfacePath(){ return ''; }

//popupStructure='original';


//========= WELCOME SCRIPT =====================================

document.write('<script type="text/javascript" src="' 
             + 'http://www.conservapedia.com/User:Philip_J._Rayment/Welcome_script' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//==============================================================

 // This will add an [edit] link at the top of all pages except preview pages and the main page
 // by User:Pile0nades


 // Add an [edit] link to pages
 addOnloadHook(function () {
 // if this is preview page or generated page, stop
  if(document.getElementById("wikiPreview") || window.location.href.indexOf("/wiki/Special:") != -1) return;

  // if this is a revision history, stop
  if(document.getElementById("histlegend‎") || window.location.href.indexOf("/wiki/Special:") != -1) return;

  // if this is a diff page, stop
  if(document.getElementById("difference‎") || window.location.href.indexOf("/wiki/Special:") != -1) return;

  // if this is a watchlist, stop
  if(document.getElementById("watchdetails") || window.location.href.indexOf("/wiki/Special:") != -1) return;

  // if this is the main page, stop
  if(document.getElementById("mainpage") || window.location.href.indexOf("/wiki/Special:") != -1) return;

  // get the page title
  var pageTitle = document.title.split(" - ")[0].replace(" ", "_");

  // create div and set innerHTML to link
  var divContainer = document.createElement("div");
  divContainer.innerHTML = '<div class="editsection" style="float:right;margin-left:5px;margin-right:0px;margin-top:47px;">[<a href="/index.php?title='+pageTitle+'&action=edit&section=0" title="'+document.title.split(" - ")[0]+'">edit</a>]</div>';

  // insert divContainer into the DOM below the h1
  if(window.location.href.indexOf("&action=edit") == -1)
    document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);

  if(window.location.href.indexOf("&action=edit&section=0") != -1)
    document.getElementById("wpSummary").value = "/* Intro */ ";
  });

//</pre>

/* 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>';
  }
}

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. */
  //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>

if (wgCanonicalSpecialPageName && wgCanonicalSpecialPageName=='Watchlist' && wgAction=='view') 
addOnloadHook(function () {
 var frm = document.getElementsByTagName('form')[0];
 frm.parentNode.insertBefore(document.createTextNode(' | '), frm);
 var lnk = document.createElement('a');
 lnk.appendChild(document.createTextNode('Unwatch…'));
 lnk.href = 'javascript:importScript("User:Alex_Smotrov/wlunwatch.js")';
 frm.parentNode.insertBefore(lnk, frm);
})