User:PoccilScript/myskin.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. |
![]() | Documentation for this user script can be added at User:PoccilScript/myskin. This user script seems to have an accompanying .css page at User:PoccilScript/myskin.css. |
function getPname() {
z=document.getElementById("content").childNodes;
for (var n=0;n<z.length;n++) {
if (z[n].className=="firstHeading") {
var text = z[n].textContent ? z[n].textContent : z[n].innerText;
return text;
}
}
}
function import_module(page){
if( document.createElement && document.childNodes ) {
var url =
'http://en.wikipedia.org/w/index.php?title=' +
page +
'&action=raw&ctype=text/javascript';
var scriptElem = document.createElement('script');
scriptElem.setAttribute('src',url);
scriptElem.setAttribute('type','text/javascript');
document.getElementsByTagName('head')[0].appendChild(scriptElem);
}
}
function replace() {
var s = prompt("Search regexp?");
if(s) {
var r = prompt("Replace regexp?");
if(!r && r != '') return;
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(new RegExp(s, "g"), r);
}
}
// User:Gimmetrow/replace.js
function fixRefMarks() {
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(new RegExp("[\n\r\f\t ]+?<ref", "g"), "<ref"); // one+ space/lf
txt.value = txt.value.replace(new RegExp("([\.,;])?<ref([^>]*?)>([^<]*)<\/ref> *?([\.,;])", "g"), "$4<ref$2>$3<\/ref>");
txt.value = txt.value.replace(new RegExp("([\.,;])?<ref([^>]*?)\/> *?([\.,;])", "g"), "$3<ref$2\/>");
}
addOnloadHook(function () {
if(document.forms.editform) {
addLink('p-cactions', 'javascript:replace()', 'replace', 'ca-replace', 'Regexp replace for the edit window', '', 'ca-history');
addLink('p-cactions', 'javascript:fixRefMarks()', 'fix refs', 'ca-reffix', 'Regexp ref fix for the edit window', '', 'ca-history');
}
});
var ta=[]
function addLink(where, url, name, id, title, key, after){
//* where is the id of the toolbar where the button should be added;
// i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
//
//* url is the URL which will be called when the button is clicked.
// javascript: urls can be used to do more complex things.
//
//* name is what will appear as the name of the button.
//
//* id is the id of the button; it's best to define one.
// Use a prefix to make sure its unique. Optional.
//
//* title is the tooltip title that gives a longer description
// of the button; if you define a accesskey, mention it here. Optional.
//
//* key is the char you want for the accesskey. Optional.
//
//* after is the id of the button you want to follow this one. Optional.
//
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
var tabs = document.getElementById(where)
tabs=tabs.getElementsByTagName('ul')[0];
if(after) {
tabs.insertBefore(li,document.getElementById(after));
} else {
tabs.appendChild(li);
}
if(id) {
if(key && title) { ta[id] = [key, title]; }
else if(key) { ta[id] = [key, '']; }
else if(title) { ta[id] = ['', title];}
}
// re-render the title and accesskeys from existing code in wikibits.js
akeytt();
return li;
}
function getElementsByClassName(oElm, strTagName, strClassName){
var arrElements=(strTagName=="*"&&oElm.all)?oElm.all:
oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, "\\-");
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
var oElement;
for(var i=0; i<arrElements.length; i++){
oElement = arrElements[i];
if(oRegExp.test(oElement.className)){
arrReturnElements.push(oElement);
}
}
return (arrReturnElements)
}
function getelbyclass(cls){
var e=getElementsByClassName(document,"*",cls)
return e?e[0]:null
}
function getspclpagelist(cls){
var e=document.getElementById("bodyContent")
e=e.getElementsByTagName("ul")
return e?e[0]:null
}
function sortfunc(a,b){
return a[2]-b[2]
}
function sortlist(){
var a=[]
var listel=getelbyclass('special')
var list=listel.childNodes
for(var i=0;i<list.length;i++){
var itxt=list[i].innerText
itm=itxt.match(/\[([\d,]+)\s+bytes/i)
if(itm&&itm[1]){
itm=parseInt(itm[1].replace(/[\.,]/g,""))
a[i]=[i,list[i],itm]
} else {
a[i]=[i,list[i],0]
}
}
a=a.sort(sortfunc)
for(var i=0;i<a.length;i++){
listel.appendChild(a[i][1])
}
}
function removeimagereverts(){
var a=[]
var listel=getspclpagelist()
var list=listel.childNodes
for(var i=0;i<list.length;i++){
var itxt=list[i].innerText
if(/reverted\s+to\s+earlier/i.exec(itxt)){
a[a.length]=list[i]
}
}
for(var i=0;i<a.length;i++){
listel.removeChild(a[i])
}
}
var oldonload=onload
onload=function(){
addLink("p-navigation",'javascript:sortlist()',"Sort items","poccil-sort")
addLink("p-navigation",'javascript:removeimagereverts()',
"Remove image reverts","poccil-noimgrev")
if(oldonload)oldonload()
}
//Following from [[User:Marudubshinki/cologneblue.js]]
function importPage(site){
var s=site.replace(/ /g,"_")
s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
s=escape(s)
s=s.replace(/([\/\[\]])/g,
function(a,b){
return "%"+b.charCodeAt(0).toString(16).toUpperCase()
})
var x='<scr'+'ipt type="text/javascript" src="http://en.wikipedia.org/w/index.php?title='
+ s + '&action=raw&ctype=text/javascript&dontcountme=s"></sc'+'ript>'
// alert(x)
document.write(x);
}
//Import two prerequisites for some scripts.
importPage('Wikipedia:WikiProject User scripts/Scripts/addLink');
importPage('Wikipedia:WikiProject User scripts/Scripts/addTab');
//add in cacyle's editor
// include comfortable javascript editor by cacycle
// levels of undo (each level holds the whole text)
undoBufferMax = 20;
// style for preview box
stylePreviewBox = 'background-color: #f9f9f9;';
// style for custom edit buttons
styleButtons = 'font-size: smaller; padding-left: 0.1em; padding-right: 0.1em';
// presets for input field dropdown options
findHistoryLength = 10;
// preset for combo box select options
presetOptions = [];
presetOptions['summary'] = [
'Copyedit',
'Linkfix',
'Reverting vandalism',
'Formatting source text'
];
// expiration time span for history cookies in seconds
cookieExpireSec = (365 * 24 * 60 * 60);
// enable cursor horizontal position memory
cursorMemory = true;
// show at least this number of lines ahead of cursor movement
scrollMargin = 1;
// show at least this number of lines ahead of cursor movement for
findMargin = 2;
// find ahead checkbox selected by default
findAheadSelected = true;
// css for change indicators
styleDelete = 'font-weight: normal; text-decoration: none; color: #ffffff; background-color: #990033;';
styleInsert = 'font-weight: normal; text-decoration: none; color: #ffffff; background-color: #009933;';
styleMoved = 'font-weight: bold; vertical-align: text-bottom; font-size: xx-small; padding: 0; border: solid 1px;';
styleBlock = [
'background-color: #ffff44;',
'background-color: #b0ff90;',
'background-color: #ffcc99;',
'background-color: #99ffff;',
'background-color: #99ccff;',
'background-color: #cc99ff;',
'background-color: #ff99cc;',
'background-color: #ffd040;',
'background-color: #d0d0d0;'
];
// html for change indicators, {number} is replaced by the block number, {block} is replaced by the block style
htmlMovedRight = '<input type="button" value=">" style="' + styleMoved + ' {block}">';
htmlMovedLeft = '<input type="button" value="<" style="' + styleMoved + ' {block}">';
htmlBlockStart = '<span style="{block}">';
htmlBlockEnd = '</span>';
htmlDeleteStart = '<span style="' + styleDelete + '">';
htmlDeleteEnd = '</span>';
htmlInsertStart = '<span style="' + styleInsert + '">';
htmlInsertEnd = '</span>';
// minimal number of real words for a moved block (0 for always displaying block move indicators)
blockMinLength = 3;
// exclude identical sequence starts and endings from change marking
wordDiff = true;
// enable recursive diff to resolve problematic sequences
recursiveDiff = true;
// enable block move display
showBlockMoves = true;
importPage('[[User:Cacycle/diff.js]]')
function getAnchors() {
var s=[''], anchs=document.getElementsByTagName('A');
for (var i=0; i<anchs.length; ++i) if (anchs[i].name && anchs[i].name!='top')
s.push(anchs[i].name);
return s;
}
window.handleKeys=function(evt){
if (window.handleKeys.disabled) {
return true;
}
var k = window.event ? window.event.keyCode : ( evt.keyCode ? evt.keyCode : evt.which);
if (!k) return;
var letter=String.fromCharCode(k);
switch (letter) {
case 'j': changeAnchor(1); return false;
case 'J': changeAnchor('last'); return false;
case 'k': changeAnchor(-1); return false;
case 'K': changeAnchor('first'); return false;
default: return true;
}
}
window.handleKeys.disabled=false;
window.handleKeys.disableFlags=[];
function setupFocusHandlers(elType, startAt) {
var inputs=document.getElementsByTagName(elType);
var j=startAt || 0;
for (var i=0; i<inputs.length; ++i) {
if (elType=='input' && inputs[i].type.toLowerCase()!='text') { continue; }
window.handleKeys.disableFlags[j]=false;
inputs[i].onfocus=function(){ window.handleKeys.disableFlags[j]=true; updateDisabledFlag(); }
inputs[i].onblur=function(){ window.handleKeys.disableFlags[j]=false; updateDisabledFlag(); }
++j;
}
//alert(j + ' handlers installed');
return j;
}
function updateDisabledFlag() {
for (var i=0; i<window.handleKeys.disableFlags.length; ++i) {
if (window.handleKeys.disableFlags[i]===true) {
window.handleKeys.disabled=true;
return true;
}
}
window.handleKeys.disabled=false;
return false;
}
var anchs, pos;
window.changeAnchor=function(step, loop) {
if(!anchs && !(anchs=getAnchors()) ) return;
var loc=document.location.toString().split('#');
switch (step) {
case 'first': pos=0; break;
case 'last': pos=anchs.length-1; break;
default:
if (loc.length > 0) {
var target=loc.slice(1).join('#');
for (var i=0; i<anchs.length; ++i) { if (anchs[i]==target) { pos=i; break; } }
}
if(typeof pos==='number') {
pos += step;
if (loop) { while(pos < 0) pos += anchs.length; pos %= anchs.length; }
else { if (pos<0) pos=0; if(pos>=anchs.length) pos=anchs.length-1; }
}
else pos = 0;
} /* switch */
var newloc=loc[0] + '#' + anchs[pos];
if(document.location!=newloc) document.location=newloc;
}
var sectionKeysPage=( ! /^(Editing|Search -|Confirm|Move page|Logs|E-mail user|All pages|Block user)/.test(document.title)
&&
! /([?&]=|wiki\/)[Ss]pecial:/.test(document.location) );
if (sectionKeysPage) {
addOnloadHook(function(){
var j=setupFocusHandlers('input');
setupFocusHandlers('textarea', j);
document.onkeypress=window.handleKeys;
});
}
if(0){
// CHECK THAT I'VE REMEMBERED TO SIGN TALK PAGES AND IF SURE DO IT AUTOMATIC:
// *** aut. signing / (automatische Unterschrift) *** 23. Apr. 2006 by [[User:Olliminatore]]
// updated by [[:en:User:Ilmari Karonen]] v1.43
//<pre><nowiki>
// helper-function
String.prototype.trim = function(){return this.replace(/^\s*|\s*$/g,"")};
addOnloadHook(function () {
if(!document.editform) return;
title = document.title; // Object to String
// regarded pages
regpages=new Array('talk:', 'Talk:', ':Village pump', ':Articles for deletion', ':Requests for adminship', ':Current surveys');
for (p in regpages)
if(title.indexOf(regpages[p])!=-1){
regpages=false;
break
}
if(regpages) return;
var txtObj=document.editform.wpTextbox1;
var txtOld=txtObj.value.trim();
txtOld_l=txtOld.length
var txtOldEnd=txtOld.slice(-24);
function doSign(){
if(document.editform.onsubmit==''){ // only once!
removeEvent(document.editform.wpSave,"click",doSign);
removeEvent(document.editform.wpPreview,"click",doSign);
}
if(document.editform.wpMinoredit.checked) return true;
signing = ' --\ ~\~\~ ~\~\~\~\~\n';
if(!txtObj.value.match(/~{3}/)){
txt=txtObj.value.trim();
txtEnd=txt.slice(-24);
if(txtOldEnd!=txtEnd) return txtObj.value = txt + signing; // aut. underwrite
else { // post between
pos = getCaretPos(txtObj);
pos = txt.indexOf('\n', pos); // go to the post-end
txtEnds = txt.substr(pos,24).replace(/^\s*/,""); // after
txtpEnds = txt.slice(pos-18,pos); // before
olldp = txtOld.indexOf(txtEnds);
if(olldp!=-1 && olldp < pos - 3 && txtOld.search(txtpEnds+txtEnds)==-1) // if some added
return txtObj.value = txt.slice(0,pos).trim() + signing + txt.slice(pos+1);
}
// FIXME: the edit-end is not found
}
else if(txtOld.search(/~{3}/)==-1 || !txtOld.match(/<nowiki>.*?~{3}.*?<\/nowiki>/i)) return 1;
else if(txtOld.match(/~{3}/g).length < txtObj.value.match(/~{3}/g).length) return 1;
return document.editform.onsubmit=new Function("document.editform.onsubmit='';return confirm('No signing was found. Save anyway?')");
};
addEvent(document.editform.wpSave,"click", doSign)
addEvent(document.editform.wpPreview,"click", doSign)
});
}
function getCaretPos(txtObj) {
if(txtObj.setSelectionRange) return txtObj.selectionStart; // NS like
else if(!document.selection) return 0; // not IE like
txtObj.focus();
var c="\001", pos=0;
var range=document.selection.createRange();
var txt=range.text, dul=range.duplicate();
dul.moveToElementText(txtObj);
range.text=txt+c;
pos=(dul.text.indexOf(c));
range.moveStart('character',-1);
range.text="";
return pos;
};
function addEvent(obj,type,fn){if(obj.addEventListener){obj.addEventListener(type,fn,false)}else if(obj.attachEvent){var eProp=type+fn;obj["e"+eProp]=fn;obj[eProp]=function(){obj["e"+eProp](window.event)};obj.attachEvent("on"+type,obj[eProp])}else{obj['on'+type]=fn}};
function removeEvent(obj,type,fn){if(obj.removeEventListener){obj.removeEventListener(type,fn,false)}else if(obj.detachEvent){var eProp=type+fn;obj.detachEvent("on"+type,obj[eProp]);obj['e'+eProp]=null;obj[eProp]=null}else{obj['on'+type]=null}};
//*** end ***
//</nowiki></pre>
// Interwiki <noinclude>[[de:Benutzer:Olliminatore/Signatur.js]]</noinclude>
//User:Lupin/popups.js
popupShortcutKeys=true; // optional: enable keyboard shortcuts
popupAdminLinks=false; // optional: enable admin links
popupDelay=.7;
popupFixRedits=true;
popupInitialWidth=200;
popupFixRedirs=true;
popupFixDabs=true;
popupLastModified=true;
popupMaxPreviewSentences=1;
popupImages=false;
popupSubpopups=true;
popupWatchRedirredPages=false;
popupRedirAutoClick='wpSave';
popupRedlinkRemoval=true;
popupLastModified=true;
popupDiffDates=true;
popupOnlyArticleLinks=true;
imagePopupsForImages=false;
popupStructure='fancy2';
importPage('[[User:Lupin/popups.js]]')
importPage('Wikipedia:WikiProject_User_scripts/Scripts/Fix_diff_width');
//Formats the article by removing excess whitespace and simplifying links.
importPage('Wikipedia:WikiProject User scripts/Scripts/Formatter');
/* Syntax highlighter */
if(document.title.indexOf(".js") == -1) // Ignore pages that end in .js
addOnloadHook(function () {
/* CSS syntax highlighting */
multicommentRE = new RegExp('(/\\*[\\s\\S]*?\\*/)', 'g');
ruleRE = new RegExp('([^\\{]+)\\{([^\\}]+)\\}', 'g');
idselectorRE = new RegExp('(#[a-zA-Z0-9\-\_]+)\\b', 'g');
classselectorRE = new RegExp('(\\.[a-zA-Z0-9\-\_]+)\\b', 'g');
pairRE = new RegExp('([a-zA-Z-]+):([^;]+);', 'g');
css = document.getElementsByTagName('pre');
for (i = 0; i < css.length; i++) {
c = css[i];
content = c.innerHTML;
content=content.replace(multicommentRE, '<span class="comment">$1</span>');
content = content.replace(ruleRE, function(text, selector, body) {
selector = selector.replace(idselectorRE, '<span class="idselector">$1</span>');
selector = selector.replace(classselectorRE, '<span class="classselector">$1</span>');
body = body.replace(pairRE, '<span class="property">$1</span>:<span class="value">$2</span>;');
return selector + '{' + body + '}';
});
c.innerHTML = content;
}
});
importPage('User:Zocky/SearchBox.js');
importPage("User:Lupin/recent2.js");
/* <pre> */
/* This function is used to include scripts from other Wikipedia pages in mine. I got it from [[User:Quarl/monobook.js]]. */
function winc(s) {
s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
document.write('<scr' + 'ipt type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=' + s
+ '&action=raw&ctype=text/javascript&dontcountme=s"></scr'
+ 'ipt>');
}
function justredirs(){
var els=document.getElementsByTagName("li")
for(var i=0;i<els.length;i++){
if(els[i].innerText.indexOf("(redirect page)")<0){
els[i].style.display="none"
els[i].innerHTML=""
}
}
}
addOnloadHook(function () {
addLink('p-personal', '/wiki/User:Poccil/myskin.js', 'My monobook.js', 'pt-monobookjs', 'monobook.js is used for storing user javascripts', '', 'pt-logout');
addLink('p-personal', '/wiki/User:Poccil/myskin.css', 'My monobook.css', 'pt-monobookcss', 'monobook.css is used for storing user CSS styles', '', 'pt-logout');
addLink('p-personal', '/w/index.php?title=Special%3AAllpages&from=Poccil&namespace=2', 'My subpages', 'pt-subpages', 'Subpages of my userspace', '', 'pt-logout');
addLink('p-personal', '/w/index.php?title=Special:Whatlinkshere&limit=5000&from=0&fakeaction=redirs&target='+escape(getPname())+'&from=Poccil&namespace=2', 'Redirs', 'pt-redirs', 'What redirects here', '', 'pt-logout');
if(location.href.indexOf("fakeaction=redirs")>=0){
justredirs()
}
});
importPage('[[User:ais523/editcount.js]]')