User:ISebestyen~enwiki/monobook.js

From wikishia

Note: After publishing, 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: Press Ctrl-F5.
// [[User:Lupin/popups.js]]

importScript('User:Lupin/popups.js');

// install [[User:Cacycle/wikEd]] in-browser text editor
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ '&action=raw&ctype=text/javascript"></' + 'script>');




/* 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>
// [[Category:Wikipedia scripts]]
 
 
// ===================================== NEW SCRIPT =======================================
 
 
//This script ([[User:ais523/highlightmyname2.js]]) highlights all instances of the
//logged-in user's username on pages by giving them a bright red background. It only
//checks bodyContent, not titles or sidebars, and doesn't change edit windows or
//Special:Preferences.
 
//<nowiki><pre>
function highlightmyname(n,p) //node, parent node
{
while(n!=null)
{
if(n.nodeType==3) //text node
{
if(n.data.toLowerCase().indexOf(wgUserName.toLowerCase())!=-1)
{
var ix=n.data.toLowerCase().indexOf(wgUserName.toLowerCase());
var t1=ix?document.createTextNode(n.data.substr(0,ix)):null;
var t2=document.createTextNode(n.data.substr(ix,wgUserName.length));
var t3=ix+wgUserName.length==n.data.length?null:
document.createTextNode(n.data.substr(ix+wgUserName.length));
var s1=document.createElement("SPAN");
s1.style.backgroundColor="#ffd16f";
s1.style.border="1px solid #9d6b00";
s1.style.padding="2px";
s1.appendChild(t2);
var s2=document.createElement("SPAN");
if(t1!=null) s2.appendChild(t1);
s2.appendChild(s1);
if(t3!=null) s2.appendChild(t3);
p.replaceChild(s2,n);
if(t3!=null) highlightmyname(t3,s2); //find remaining occurences in the new nodes
n=s2.nextSibling;
}
else
n=n.nextSibling;
}
else
{
if(n.firstChild!=null) highlightmyname(n.firstChild,n);
n=n.nextSibling;
}
}
}
 
addOnloadHook(function() {
if(location.href.indexOf("?ais523")==-1&&location.href.indexOf("&ais523")==-1&&
location.href.indexOf("?action=edit")==-1&&location.href.indexOf("?action=submit")==-1&&
location.href.indexOf("&action=edit")==-1&&location.href.indexOf("&action=submit")==-1&&
wgPageName!="Special:Preferences")
highlightmyname(document.getElementById('bodyContent').firstChild,
document.getElementById('bodyContent'));
});
//</pre></nowiki>
//[[Category:Wikipedia scripts]]