User:Vanderdecken/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:Vanderdecken/monobook.css. |
importScript('User:VoA/monobook.js');
//[[Category:Wikipedians who use RC script]]
/**** afd helper ****/
document.write('<script type="text/javascript"' +
'src="http://en.wikipedia.org/w/index.php?title=User:Jnothman/afd_helper/' +
'script.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
/* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */
/* <pre> [[User:DStoykov/defaultsort.js]] <nowiki> */
function defaultsort() {
//var apiurl = wgServer+wgScriptPath+'/api.php?action=query&meta=siteinfo&siprop=namespaces&format=xml';
//var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : null;
//xmlhttp.open('GET',apiurl, false);
//xmlhttp.send(null);
//alert(xmlhttp.responseXML.getElementById('14'));
var txt = document.editform.wpTextbox1.value;
var sortkey = '';
// Create an array of all category links
if (txt.match(/\{\{\s*defaultsort/i)) {
alert('There\'s already a defaultsort statement!');
return;
}
var catlinks = txt.match(/\[\[\s*((C|K)at(e|e)gor(y|i|ie|ia|ia|ija|io)|Кат(е|э)гор(ия|ија|ія|ыя)|Luokka|Flokkur)\s*:.*\]\]/ig);
if (!catlinks) {
alert('There are no category links!');
return;
}
for (i=0; i< catlinks.length; i++) {
// Extract the name of the category
var catname = catlinks[i].replace(/.+\s*:\s*([^|]*[^|\s])\s*(\|.*)?\]\]/,"$1");
// Extract the sort key
var match = /\|[^\]]+/.exec(catlinks[i]);
if (match == null) {
alert('Category '+catname+' doesn\'t include a sort key!');
return;
}
// Strip the '|' and any trailing spaces
var sk = match[0].replace(/\|(.+)/, "$1").replace(/(\S) +$/,"$1");
if (i == 0) {
sortkey = sk;
} else {
if (sortkey != sk) {
alert('Not all sort keys are identical!\nThe sort key for category '+catname+' is different.');
return;
}
}
}
// Now that we know that everything is OK, we can proceed with modifying the content of the editbox
txt = txt.replace(catlinks[0], "{{DEFAULTSORT:"+sortkey+"}}\n"+catlinks[0]);
for (i=0; i< catlinks.length; i++) {
subst = catlinks[i].replace(/\|[^\]]+/,"");
txt = txt.replace(catlinks[i], subst);
}
document.editform.wpTextbox1.value=txt;
}
addOnloadHook(function () {
if(document.forms.editform) {
addPortletLink('p-cactions', 'javascript:defaultsort()', 'defaultsort', 'ca-defaultsort', '', '', document.getElementById('ca-purge'));
}
});
/* </nowiki></pre> */
/* <pre> */
function welcome() {
// Find the edit box
var txt = document.editform.wpTextbox1;
//The welcome *template* you want to use, modified to be Welcomeh, edit summary Welcome! and no watch
var welcome_template = 'welcomeh';
var welcome_summary = 'Welcome!';
var welcome_watch = false;
// The tag to be included is a welcome message
var tag = '{{subst:'+ welcome_template +'}}';
// If the edit box doesn't already have this tag...
if (txt.value.indexOf(tag) == -1) {
// Append the tag
txt.value += tag;
// Add an edit summary
document.editform.wpSummary.value = welcome_summary;
document.editform.wpWatchthis.checked = welcome_watch;
// Press the Save page button
document.editform.submit();
}
// If the tag was already there, turn the tab background red to indicate
// that the script is functioning properly, but that there is no action
// to do. This doesn't interrupt the user's work like an alert() would.
else {
document.getElementById('ca-unverified').firstChild.style.backgroundColor = "#ff4444";
document.getElementById('ca-unverified').style.backgroundColor = "#ff4444";
}
}
// Create a tab that calls this function when pressed
// Create a tab that calls this function when pressed
addOnloadHook(
function ()
{
if(document.title.indexOf("Editing User talk:") == 0)
{
addPortletLink('p-cactions', 'javascript:welcome()', 'welcome', 'ca-welcome', 'Adds a welcome note to a new user', '', '');
}
}
);
/* This is to keep track of who is using this extension: [[User:Flex/welcome_newuser.js]] */
/* </pre> */
// Compare link
/* In addition to the GFDL:
This function (compare link) is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This function is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
A copy of the GPL is available at http://www.prism.gatech.edu/~mflaschen3/gpl.txt .
By modifying "Wikipedia:WikiProject User scripts/Scripts/Compare link":
You agree to dual-license your contributions under both the GFDL (http://en.wikipedia.org/wiki/WP:GFDL)
and version 2 of the GPL (http://www.prism.gatech.edu/~mflaschen3/gpl.txt) or any later version
of the GPL published by the FSF.
*/
function fixCompare()
{
var histForm=document.getElementsByTagName("form")[0];
var finalButton=document.getElementById("historysubmit");
var firstButton=histForm.getElementsByTagName("input")[1];
histForm.removeChild(finalButton);
histForm.removeChild(firstButton);
var compareLink=document.createElement("a");
var genLink="http://en.wikipedia.org/w/index.php?title=" + histForm.title.value + "&diff=" + histForm.diff[0].value + "&oldid=" + histForm.oldid[1].value;
compareLink.setAttribute("href", genLink);
compareLink.appendChild(document.createTextNode("Compare selected versions"));
histForm.insertBefore(compareLink, document.getElementById("pagehistory"));
var endLink=compareLink.cloneNode(true);
histForm.appendChild(endLink);
var diffList=document.getElementById("pagehistory");
diffList.setAttribute("onchange", "updateCompare()");
}
function updateCompare()
{
var histForm=document.getElementsByTagName("form")[0];
var diffList=document.getElementById("pagehistory");
var compareLink=diffList.previousSibling;
var endLink=diffList.nextSibling;
var oldInd=-1;
var i=0;
while(oldInd==-1 & i<histForm.oldid.length)
{
if(histForm.oldid[i].checked)
oldInd=i;
i++;
}
var diffInd=-1;
var j=0;
while(diffInd==-1 & j<histForm.diff.length)
{
if(histForm.diff[j].checked)
diffInd=j;
j++;
}
var genLink="http://en.wikipedia.org/w/index.php?title=" + histForm.title.value + "&diff=" + histForm.diff[diffInd].value + "&oldid=" + histForm.oldid[oldInd].value;
compareLink.setAttribute("href", genLink);
endLink.setAttribute("href", genLink);
}
if(window.location.href.indexOf("action=history")!=-1)
addOnloadHook(fixCompare);
//