User:Az1568/tabs.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Copied from http://commons.wikimedia.org/wiki/MediaWiki:Extra-tabs.js
* Changed by Kernigh:
* 2006-04-16: Point to en.wikibooks.org, uncomment tab strings.
*/
//<pre><nowiki>
if (window.location.href.indexOf('action=edit') != -1 && window.location.href.indexOf('remexamplejpg=1') != -1) {
function RemoveExampleJpg() {
document.getElementById('wpSummary').value = "Removing [[Image:Example.jpg]], '''bold text''', etc...";
var contents = document.getElementById('wpTextbox1').value;
var newcontents = contents.replace(/(\[http:\/\/www\.example\.com link title\]|== Headline text ==|<math>Insert formula here<\/math>|<nowiki>Insert non-formatted text here<\/nowiki>|#REDIRECT \[\[Insert text\]\]|'''Bold text'''|''Italic text''|\[\[(Media:Example\.ogg|Image:Example\.jpg|Link title)\]\]|#REDIRECT \[\[Insert text\]\]|<s>Strike-through text<\/s>|<sup>Superscript text<\/sup>|<sub>Subscript text<\/sub>|<small>Small Text<\/small>|<!-- Comment -->|<gallery>\s+Image:Example.jpg\|Caption1\s+Image:Example.jpg\|Caption2\s+<\/gallery>|<blockquote>\s+Block quote\s+<\/blockquote>|\{\| class="wikitable"\s+\|-\s+! header 1\s+! header 2\s+! header 3\s+\|-\s+\| row 1, cell 1\s+\| row 1, cell 2\s+\| row 1, cell 3\s+\|-\s+\| row 2, cell 1\s+\| row 2, cell 2\s+\| row 2, cell 3\s+\|\})/g, "");
document.getElementById('wpTextbox1').value = newcontents;
document.getElementById('wpWatchthis').checked = "";
document.getElementById('wpDiff').click();
}
addOnloadHook(function(){ RemoveExampleJpg(); });
}
if(wgCanonicalNamespace != "Special") {
addOnloadHook(function(){
var taburl = "http://meta.wikimedia.org/w/index.php?title="+wgPageName+"&action=edit&remexamplejpg=1";
addTab(taburl, "example.jpg", "ca-examplejpgfix", "This is to remove Image:Example.jpg from stuff");
});
}
//</nowiki></pre>
//more tabs
$(add_testn_tabs)
function add_testn_tabs()
{
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
if (document.title.indexOf("Talk:") == -1 && document.title.indexOf("talk:") == -1 && document.title.indexOf("User:") == -1 && document.title.indexOf("MediaWiki:") == -1 && document.title.indexOf("Image:") == -1 && document.title.indexOf("Wikipedia:") == -1 && document.title.indexOf("Template:") == -1 && document.title.indexOf("Portal:") == -1 && document.title.indexOf("Help:") == -1 && document.title.indexOf("Main Page") == -1 && document.title.indexOf("Category:") == -1)
{
if(document.getElementById('ca-edit'))
{document.getElementById('ca-edit').firstChild.innerHTML = 'Modify';}
}
else
{
if(document.getElementById('ca-edit'))
{document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';}
if(document.getElementById('ca-talk'))
{document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';}
}
if (document.title.indexOf("Editing ") != -1)
{
if (document.title.indexOf("Editing User talk:") != -1)
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlimenu(tabs, '{{message}}', 'warnfunc');
var warnfunc = document.getElementById('warnfunc').getElementsByTagName('ul')[0];
addlilink(warnfunc, 'javascript:welcometn(1)', 'welcome', '');
addlilink(warnfunc, 'javascript:welcometn(3)', 'welcome2', '');
addlilink(warnfunc, 'javascript:welcometn(2)', 'anon', '');
addlilink(warnfunc, 'javascript:testn(1)', 'test', '');
addlilink(warnfunc, 'javascript:povn()', 'NPOV', '');
addlilink(warnfunc, 'javascript:testn(2)', 'vandal', '');
addlilink(warnfunc, 'javascript:testn(3)', 'vandal2', '');
addlilink(warnfunc, 'javascript:warningn()', 'warn', '');
addlilink(warnfunc, 'javascript:testbl()', 'blanking', '');
addlilink(warnfunc, 'javascript:spam(1)', 'spam', '');
addlilink(warnfunc, 'javascript:spam(2)', 'spam2', '');
addlilink(warnfunc, 'javascript:finalwn()', 'final', '');
addlilink(warnfunc, 'javascript:blockn()', 'vblock', '');
addlilink(warnfunc, 'javascript:revertsn()', '3rr', '');
addlilink(warnfunc, 'javascript:rrblockn()', 'rr block', '');
if(document.getElementById('ca-delete'))
{
document.getElementById('ca-delete').firstChild.innerHTML = '<span style="color:red;">[d]</span>';
}
if(document.getElementById('ca-move'))
{
document.getElementById('ca-move').firstChild.innerHTML = '[m]';
}
if(document.getElementById('ca-watch'))
{
document.getElementById('ca-watch').firstChild.innerHTML = '[w]';
}
if(document.getElementById('ca-unwatch'))
{
document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]';
}
if(document.getElementById('ca-edit'))
{
document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
}
}
else if (document.title.indexOf("Editing User:") != -1)
{
var nothing = 'yes';
}
else if (document.title.indexOf("Editing Wikipedia:Requests for page protection (section)") != -1)
{
if(document.getElementById('ca-delete'))
{
document.getElementById('ca-delete').firstChild.innerHTML = '<span style="color:red;">[d]</span>';
}
if(document.getElementById('ca-move'))
{
document.getElementById('ca-move').firstChild.innerHTML = '[m]';
}
if(document.getElementById('ca-watch'))
{
document.getElementById('ca-watch').firstChild.innerHTML = '[w]';
}
if(document.getElementById('ca-unwatch'))
{
document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]';
}
}
else if (document.title.indexOf("Editing Wikipedia:Administrators' noticeboard/3RR (section)") != -1)
{
addTab('javascript:rrwarn()',"a|wn","ca-wn","Warned","");
addTab('javascript:rrblock()',"a|bl","ca-bl","Blocked","");
addTab('javascript:rrnoblock()',"r|cl","ca-cl","Close to 3RR","");
}
else if(document.title.indexOf("Wikipedia:") != -1 || document.title.indexOf("Help:Contents/Editing Wikipedia") != -1 || document.title.indexOf("Editing Talk") != -1 || document.title.indexOf("Editing Wikipedia talk") != -1)
{
{nothing=1;}
}
}
else if (document.title.indexOf("User:") != -1)
{
if(document.getElementById('ca-talk'))
{
document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
}
}
else if (document.title.indexOf("User talk:") != -1)
{
if(document.getElementById('ca-talk'))
{
document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
}
}
}
/**** Add generic tab ****/
function addlilink(tabs, url, name, id){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = name;
li.appendChild(na);
tabs.appendChild(li);
return li;
}
/**** Add tab as menu ****/
function addlimenu(tabs, name, id)
{
var na = document.createElement('a');
na.href = '#';
var mn = document.createElement('ul');
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.className = 'tabmenu';
li.appendChild(na);
li.appendChild(mn);
tabs.appendChild(li);
return li;
}
/**** Add purge tab ****/
function addPurge()
{
ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
if(!document.getElementById) return;
var x = document.getElementById('ca-history');
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(!x) return;
if(x.children) x = x.children[0];
else x = x.childNodes[0];
addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge');
}
// appends msg to the currently-editted page, sets the summary to summ,
// and marks or unmarks the Watch this page checkbox according to watch.
function edit_summary_watch(msg, summ, watch)
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += msg;
f.wpSummary.value = summ;
f.wpWatchthis.checked = watch;
}