User:TotoBaggins/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 is at User:TotoBaggins/monobook.css. |
// install [[User:Cacycle/wikEd]] in-browser text editor
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ '&action=raw&ctype=text/javascript');
// Here's a hack to allow editing of the top section of a page.
// This is convenient when a page is very long.
// To use it, just copy the sections delimited by "START"
// and "END" to:
// http://en.wikipedia.org/w/index.php?title=User:TotoBaggins/monobook.js&action=edit
// Note that you must change "TotoBaggins" to your own user name,
// and you must also clear your browser cache.
//////////////////////////////////////////////////////////////////////////////////////////////////
// START START START START START START START
function addTopSectionEditButton() {
var listItems = document.getElementsByTagName("li");
var editThisPageListItem = null;
var editThisPageListAnchor = null;
for (var i = 0; i < listItems.length; i++)
{
var li = listItems[i];
editThisPageAnchor = li.firstChild;
if (li.getAttribute("id") == "ca-edit" && editThisPageAnchor != null)
{
editThisPageListItem = li;
break;
}
}
if (editThisPageListItem == null)
return;
var link = document.createElement("a");
link.setAttribute("href", editThisPageAnchor.getAttribute("href")
+ "§ion=0");
link.setAttribute("title", "Edit top section");
link.appendChild(document.createTextNode("section"));
editThisPageListItem.appendChild(document.createTextNode("/"));
editThisPageListItem.appendChild(link);
}
$(addTopSectionEditButton);
// END END END END END END END END END END END
//////////////////////////////////////////////////////////////////////////////////////////////////
//This code will change ISBN links to point to the url of your choice,
//instead of Special:Book_sources.
//
//How to use it:
//
//First, you must copy this code to your user javascript page. This is
//at User:<your username>/monobook.js . My username is Lunchboxhero so
//my javascript page is User:Lunchboxhero/monobook.js . You must be logged
//in to edit your javascript page.
//
//Once you have copied the code and saved the page, you need to refresh your
//browser's cache. For Mozilla/Safari/Konqueror: hold down Shift while clicking
//Reload (or press Ctrl-Shift-R), IE: press Ctrl-F5, Opera: press F5.
//
//The code should now work, as long as you are logged in.
//
//You can change the destination url by simply modifying the quoted url that
//follows document.links[i].href=
//
//Good luck, and if you have any questions, leave me a comment on the discussion
//page of User:Lunchboxhero/monobook.js .
//
//(Every line that starts with "//" is a comment and can be discarded.)
function externISBN() {
for (var i = 0; i < document.links.length; i++)
{
var ln = document.links[i].href.match(/isbn=(.*)/);
if (ln) {
document.links[i].href='http://www.amazon.com/exec/obidos/ASIN/'+RegExp.$1;
}
}
}
$(externISBN);