User:Jinkas/monobook.js

From Conservapedia
< User:Jinkas
This is an old revision of this page, as edited by Jinkas (talk | contribs) at 00:38, September 1, 2007. It may differ significantly from current revision.
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
//<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>


// [[User:Quarl/watchlist.js]] - adds buttons to watchlist: "unwatch", "diff
// since"

//  UNWATCH button asynchronously unwatches and crosses the entry off the
//  watchlist.
//
//  DIFF SINCE button shows differences since last edited.

// quarl 2006-01-09 added asynchronous feature.
// quarl 2006-02-03 factored; added diff since.

// requires: wikipage.js, util.js, wikiwatch.js, diffsince.js

// originally based on http://en.wikipedia.org/wiki/User:Omegatron/monobook.js
// see also http://en.wikipedia.org/wiki/User:Matthewmayer/monobook.js

// see also Bug 424 http://bugzilla.wikipedia.org/show_bug.cgi?id=424

// <pre><nowiki>

var watchlist = new Object();
watchlist.wp = {};

watchlist.unwatchAsync = function(pagename) {
    var wp = watchlist.wp[pagename];
    if (!wp) { alert("## internal error 72192d74-ab57-4a98-917f-8c6ca03b0559"); return; }
    wikiwatch.unwatchAsync(wp, watchlist._unwatchSuccess, wp.unwatchSpan);
    return false;
}

watchlist.watchAsync = function(pagename) {
    var wp = watchlist.wp[pagename];
    if (!wp) { alert("## internal error 72192d74-ab57-4a98-917f-8c6ca03b0559"); return; }
    wikiwatch.watchAsync(wp, watchlist._watchSuccess, wp.unwatchSpan);
    return false;
}

watchlist.diffSince = function(pagename) {
    var wp = watchlist.wp[pagename];
    if (!wp) { alert("## internal error 72192d74-ab57-4a98-917f-8c6ca03b0559"); return; }
    return diffsince.diffPageAsync(wp, wp.diffsinceSpan);
}

watchlist._addStrikeThrough = function(node) {
    // return node && insertNode(node, document.createElement('s'));
    if (!node) return 0;

    addClass(ensureSpan(node), 'history-deleted');
    return 1;
}

watchlist._removeStrikeThrough = function(node) {
    if (!node) return 0;

    removeClass(ensureSpan(node), 'history-deleted');
    return 1;
}

watchlist._unwatchSuccess = function(wp) {
    var wpNT = wp.notalkPage();
    var wpT = wp.talkPage();

    if (0 == (watchlist._addStrikeThrough(findHref(wpNT.url)) +
              watchlist._addStrikeThrough(findHref(wpT.url))))
    {
        alert("Unwatched article '"+wp.page+"', but couldn't annotate current page.");
        return;
    }

    watchlist._updateWuwLink(wpT, 'watch');
    watchlist._updateWuwLink(wpNT, 'watch');
}

watchlist._watchSuccess = function(wp) {
    var wpNT = wp.notalkPage();
    var wpT = wp.talkPage();

    if (0 == (watchlist._removeStrikeThrough(findHref(wpNT.url)) +
              watchlist._removeStrikeThrough(findHref(wpT.url))))
    {
        alert("Watched article '"+wp.page+"', but couldn't annotate current page.");
        return;
    }

    watchlist._updateWuwLink(wpT, 'unwatch');
    watchlist._updateWuwLink(wpNT, 'unwatch');
}

// Update a watch/unwatch link.  Returns 1 on success, 0 if not found.
//
// wuw must be 'watch' or 'unwatch'
watchlist._updateWuwLink = function(wpX, wuw) {
    wp = watchlist.wp[wpX.page];
    if (!wp) return 0;
    var link = "javascript:return watchlist."+wuw+"Async("+string_quote_escape(wp.page)+")";
    var url = wp.qurl+'&action='+wuw;
    wp.unwatchSpan.innerHTML = '<a onclick="'+link+'" href="' + url + '">'+wuw+'</a>';
    return 1;
}


watchlist._load = function()
{
    if (wikiPage.page == "Special:Watchlist") watchlist._annotatePage();
}

watchlist._annotatePage = function() {
    var links = copyArray(document.getElementById('bodyContent').getElementsByTagName('a'));
    for (i in links) {
        var link = links[i];
        if (link.href && link.href.match(/action=history$/)) {
            var wp = new WikiPage(link.href);
            watchlist.wp[wp.page] = wp;

            wp.unwatchSpan = document.createElement('span');
            var unwatchLink = "javascript:return watchlist.unwatchAsync("+string_quote_escape(wp.page)+")";
            var unwatchUrl = wp.qurl+'&action=unwatch';
            wp.unwatchSpan.innerHTML = '<a onclick="'+unwatchLink+'" href="' + unwatchUrl + '">unwatch</a>';
            add_after(link, wp.unwatchSpan);
            add_after(link, document.createTextNode('; '));

            wp.diffsinceSpan = document.createElement('span');
            diffsinceLink = "javascript:return watchlist.diffSince("+string_quote_escape(wp.page)+")";
            var diffsinceUrl = diffsince.makeUrl(wp);
            wp.diffsinceSpan.innerHTML = '<a onclick="'+diffsinceLink+'" href="' + diffsinceUrl + '">since</a>';
            add_before(link, wp.diffsinceSpan);
            add_before(link, document.createTextNode('; '));
        }
    }
}

addOnloadHook(watchlist._load);

// </nowiki></pre>