User:16@r/monobook.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

This JavaScript is executed for 16@r on every page load, when User:16@r is using the Monobook skin.


// 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&dontcountme=s"></script>');

// Add an [edit] link to pages
hookEvent("load", function ()
{
	if(wgCanonicalNamespace == "Special") return;
	if(document.getElementById("difference?")) return;
	if(wgTitle == "Main Page") return;
 
	if(wgAction == "view")
	{
		var divContainer = document.createElement("div");
		divContainer.innerHTML = '<div class="editsection" style="float:right;margin-top:1em;font-size:100%;">[<a href="' + wgScript + '?title=' + wgPageName + '&action=edit&section=0" title="Edit introduction">edit</a>]</div>';
		var coos = document.getElementById("coordinates");
		if(coos) coos.style.right = "4.5em";
		document.getElementById("content").insertBefore(
			divContainer, document.getElementsByTagName("h1")[0]);
	}
	else if(window.location.href.indexOf("&action=edit&section=0") != -1)
	{
		e = document.getElementById("wpSummary");
		if(e) e.value = "/* Intro */ " + e.value;
		else alert("Cannot find the ‘Edit summary’ textbox.");
	}
});