User:Clindberg/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
The accompanying .css page for this skin can be added at User:Clindberg/monobook.css. |
//Custom monobook javascript extensions<!-- Makes this look OK on the Wikipedia page --><pre>
// This will add an [edit] link at the top of all pages except preview pages and the main page
// Originally by User:Pile0nades, with additions from User:David_Levy
// Add an [edit] link to pages
addOnloadHook(function ()
{
// Add label to edit box if actually editing
if(window.location.href.indexOf("&action=edit§ion=0") > 0) {
var editField = document.getElementById("wpSummary");
if (editField) editField.value = "/* Intro */ ";
return;
}
// Don't add the link if there are no other links on the page. This avoids adding it on
// history etc. pages and also if the user's edit link preference is turned off.
// IE's innerHTML does not have double quotes so use a regex.
if (document.getElementById('bodyContent').innerHTML.match('class="?editsection"?') == null)
return;
// create div and set innerHTML to link
var pageURL = mw.config.get('wgPageName').replace(/&/g, "%26");
var divContainer = document.createElement("div");
var divStart = '<div class="editsection" style="float:right;margin-left:5px;margin-right:0px;margin-top:38px;">';
var divLink = '<a href="/w/index.php?title='+pageURL+'&action=edit§ion=0" title="Edit intro section: '+mw.config.get('wgTitle')+'">';
divContainer.innerHTML = divStart+'['+divLink+'edit</a>]</div>';
// insert divContainer into the DOM below the h1
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
});
//</pre>