Utente:Andyrom75/Admin.js
Nota: dopo aver salvato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tenere premuto il tasto delle maiuscole e fare clic su Ricarica, oppure premere Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premere Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Internet Explorer: tenere premuto il tasto Ctrl mentre si fa clic su Refresh, oppure premere Ctrl-F5
- Opera: svuotare completamente la cache dal menu Strumenti → Preferenze
/*</pre>
== Script per titoli in JS ==
<pre>*/
function sourceheadings() {
if ((wgNamespaceNumber == 2 || wgNamespaceNumber == 8) && wgTitle.lastIndexOf('.js') != -1 && wgAction == 'view') {
var bc = document.getElementById('bodyContent');
if (bc != null) {
var pres = bc.getElementsByTagName('pre');
if (pres.length == 1) {
var spans = pres[0].getElementsByTagName('span');
var numspans = spans.length;
var j = 0;
for (var i = 0; i < numspans; i++) {
if (spans[i].className == 'coMULTI') {
var res = null;
if (spans[i].firstChild.nodeValue)
// TODO \n+ doesn't seem to work here
res = spans[i].firstChild.nodeValue.match(/\/\*\s*<\/pre>[\r\n\s]+(==+)(.*?)(==+)[\r\n\s]+<pre>\s*\*\//,"gi");
if (res!= null && res.length != 0) {
j++;
var l = res[1].length < res[3].length ? res[1].length : res[3].length;
var h = document.createElement('h' + l);
h.innerHTML =
'<span class="editsection">[<a href="' +
wgScript + '?title=' + wgPageName + '&action=edit&section=' + j +
'">edit</a>]</span><span class="mw-headline">' + res[2] + '</span>';
pres[0].replaceChild(h, spans[i]);
}
}
}
}
}
}
}
$(sourceheadings);
/*</pre>
== Batch Delete ==
<pre>*/
/* Ajax batch delete thingy, version [0.1.1b]
Originally from: http://en.wikipedia.org/wiki/User:Splarka/ajaxbatchdelete.js
Notes:
* It is a bit verbose, after debugging perhaps some output should be removed.
* It waits 1 second after every delete before starting the next.
* Can be aborted by simply deleting the contents of the textarea, or leaving the page.
* Stops when it hits a blank line.
* Nonfatal errors (skip to next line):
** Bad character or malformed line
** Bad token
** Unexpected response
* Pauses in execution can be added with a blank line.
To do:
* Cache the token if two the same?
** Please note the delete token is not guaranteed to be static, but currently it always is.
*/
$(function() {
mw.util.addPortletLink('p-tb','/wiki/Special:BlankPage?blankspecial=ajaxbd','Batch Delete');
});
if(wgCanonicalSpecialPageName && wgCanonicalSpecialPageName.toLowerCase() == 'blankpage' && queryString('blankspecial') == 'ajaxbd') {
document.title = 'Ajax Batch Deletion';
addOnloadHook(abdForm);
}
function abdForm() {
mw.util.addPortletLink('p-tb','/wiki/Special:Log/delete?user=' + encodeURIComponent(wgUserName),'My delete log');
//subvert this Special: page to our own needs.
var con = document.getElementById('content') || document.getElementById('mw_content');
var bcon = document.getElementById('bodyContent') || document.getElementById('mw_contentholder');
var fh = getElementsByClassName(con,'h1','firstHeading')[0];
while(fh.firstChild) fh.removeChild(fh.firstChild)
fh.appendChild(document.createTextNode('Ajax Batch Deletion'));
for(var i=0;i<bcon.childNodes.length;i++) {
bcur = bcon.childNodes[i];
if(bcur.id != 'siteSub' && bcur.id != 'contentSub' && bcur.className != 'visualClear') {
while(bcur.firstChild) bcur.removeChild(bcur.firstChild)
if(bcur.nodeType == 3) bcur.nodeValue = '';
}
}
//generate content
var form = document.createElement('form');
form.appendChild(document.createTextNode('Lista delle pagine da cancellare:'));
form.appendChild(document.createElement('p'));
form.setAttribute('action','javascript:void(0);');
var txt = document.createElement('textarea');
txt.style.height = '20em';
txt.style.width = '50%';
txt.setAttribute('id','abd-textarea');
form.appendChild(txt);
form.appendChild(document.createElement('p'));
var lab1 = document.createElement('label');
lab1.setAttribute('for','abd-reason')
lab1.appendChild(document.createTextNode('Oggetto delle cancellazioni: '));
form.appendChild(lab1);
var inp1 = document.createElement('input');
inp1.style.width = '20em';
inp1.setAttribute('type','text');
inp1.setAttribute('id','abd-reason');
form.appendChild(inp1);
form.appendChild(document.createElement('p'));
var sub1 = document.createElement('input');
sub1.setAttribute('type','button');
sub1.setAttribute('id','abd-startbutton');
sub1.setAttribute('value','start');
sub1.setAttribute('onclick','abdStart()');
form.appendChild(sub1);
bcon.appendChild(form);
var pre = document.createElement('pre');
pre.setAttribute('id','abd-output');
bcon.appendChild(pre);
}
function abdStart() {
document.getElementById('abd-startbutton').setAttribute('disabled','disabled');
var out = document.getElementById('abd-output');
var txt = document.getElementById('abd-textarea');
var deletes = txt.value.split('\n');
var page = deletes[0];
if(page == '') {
out.appendChild(document.createTextNode('* fatto! Non resta altro da fare, o la riga successiva è vuota.\n'));
document.getElementById('abd-startbutton').removeAttribute('disabled');
} else {
var badchars = /(\#|\<|\>|\[|\]|\{|\}|\|)/;
if(badchars.test(page)) {
out.appendChild(document.createTextNode('! trovato un carattere non ammesso, la pagina' + page + ' è stata ignorata\n'));
setTimeout('abdStart()',1000);
} else {
out.appendChild(document.createTextNode('> Tento di cancellare [[' + page + ']]\n'));
abdGetToken(page);
}
}
deletes = deletes.slice(1,deletes.length);
txt.value = deletes.join('\n');
}
function abdGetToken(page) {
var out = document.getElementById('abd-output');
out.appendChild(document.createTextNode(' > Recupero delete token per [[' + page + ']]\n'));
var url = wgScriptPath + '/api.php?action=query&prop=info&indexpageids=1&intoken=delete&format=json&titles=' + encodeURIComponent(page);
var req = sajax_init_object();
req.open('GET', url, true);
req.onreadystatechange = function() {
if(req.readyState == 4 && req.status == 200) {
eval("abdDelete(" + req.responseText + ",'" + req.responseText.replace(/\'/g,"`") + "','" + page + "')");
}
}
req.send(null);
}
function abdDelete(obj,txt,page) {
var out = document.getElementById('abd-output');
if(obj['error']) {
out.appendChild(document.createTextNode(' ! Errore nelle API: ' + obj['error']['code'] + ' - ' + obj['error']['info'] + '\n'));
return;
}
if(!obj['query'] || !obj['query']['pageids'] || !obj['query']['pages'][obj['query']['pageids'][0]] || !obj['query']['pages'][obj['query']['pageids'][0]]['deletetoken']) {
out.appendChild(document.createTextNode(' ? Unexpected response: ' + txt + '\n'));
return;
}
var token = obj['query']['pages'][obj['query']['pageids'][0]]['deletetoken'];
out.appendChild(document.createTextNode(' > Token trovato, attendere la cancellazione\n'));
var reason = document.getElementById('abd-reason').value;
var params = 'action=delete&format=json&token=' + encodeURIComponent(token) + '&title=' + encodeURIComponent(page) + '&reason=' + encodeURIComponent(reason);
var url = wgScriptPath + '/api.php';
var req = sajax_init_object();
req.open('POST', url, true);
req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
req.setRequestHeader('Content-length', params.length);
req.setRequestHeader('Connection', 'close');
req.onreadystatechange = function() {
if(req.readyState == 4 && req.status == 200) {
eval("abdDeleteAftermath(" + req.responseText + ",'" + req.responseText.replace(/\'/g,"`") + "')");
}
}
req.send(params);
}
function abdDeleteAftermath(obj,txt) {
var out = document.getElementById('abd-output');
if(obj['error']) {
out.appendChild(document.createTextNode(' ! Api error: ' + obj['error']['code'] + ' - ' + obj['error']['info'] + '\n'));
} else if(obj['delete'] && obj['delete']['title']) {
out.appendChild(document.createTextNode(' > La pagina [[' + obj['delete']['title'] + ']] è stata cancellata\n'));
} else {
out.appendChild(document.createTextNode(' ? Unexpected response: ' + txt + '\n'));
return;
}
setTimeout('abdStart()',1000);
}
function queryString(p) {
var re = RegExp('[&?]' + p + '=([^&]*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches[1]);
} catch (e) {
}
}
return null;
}
/*</pre>
==Rimando a fondopagina==
<pre>*/
//Di [[m:User:Wim b]]
mw.util.addPortletLink("p-personal","#footer","▼","pt-fondo","Fondopagina","",document.getElementById('pt-userpage'));
/*</pre>
==Collegamento a inizio pagina==
<pre>*/
// [[w:en:User:Numbermaniac/goToTop.js]]
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Numbermaniac/goToTop.js&action=raw&ctype=text/javascript');
/*</pre>
==Tab utilità==
<pre>*/
$(function (){
var urlLinkHere = location.href;
urlLinkHere = urlLinkHere.replace('/Speciale:PuntanoQui/', '/');
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlimenu(tabs, 'utilità', 'utilità'); //puoi cambiare 'Utilità' in qualcos'altro, ma non cambiare 'Sysop'
var utilità = document.getElementById('utilità').getElementsByTagName('ul')[0];
//Una riga per ogni voce del menu
addlilink(utilità, mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + wgPageName + '&action=purge','Purge', '');
addlilink(utilità,'javascript:replace()','replace', '');
if(document.title.indexOf("Pagine che linkano") != -1 )
{
addlilink(utilità, urlLinkHere + '?action=delete','Cancella', '');
}
if(document.title.indexOf("Pagine che linkano") == -1 )
{
addlilink(utilità,'/wiki/Speciale:PuntanoQui/' + wgPageName,'Puntano qui', ''); // Esempio di collegamento nel menu
}
});
/*</pre>
==Tab Admin==
<pre>*/
$(function (){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlimenu(tabs, 'Admin', 'Sysop'); //puoi cambiare 'Utilità' in qualcos'altro, ma non cambiare 'Sysop'
var Sysop = document.getElementById('Sysop').getElementsByTagName('ul')[0];
//Una riga per ogni voce del menu
if(document.title.indexOf("tente:") != -1 )
{
addlilink(Sysop,'/wiki/Speciale:DeletedContributions/'+ wgTitle,'contributi eliminati', ''); // Esempio di collegamento nel menu
addlilink(Sysop,'/wiki/Speciale:Blocca/'+ wgTitle,'blocca utente', '');
}
if(document.title.indexOf("tente:") == -1 )
{
addlilink(Sysop,'/wiki/Speciale:DeletedContributions/','contributi eliminati', '');
addlilink(Sysop,'/wiki/Speciale:Blocca','blocca utente', '');
}
addlilink(Sysop,'/wiki/Speciale:Importa','importa pagina', '');
addlilink(Sysop,'/wiki/Speciale:Ripristina','recupera pagina', '');
addlilink(Sysop,'/wiki/Speciale:ALinksearch','link esterni', '');
addlilink(Sysop,'/wiki/Speciale:Protectedpages','pagine bloccate', '');
addlilink(Sysop,'javascript:GetNomeUtente();','inter edit', '');
});
//NOME UTENTE INTEREDIT
function GetNomeUtente(){
var prmtnome
prmtnome=prompt("Inserisci il nome utente","");
window.location = 'http://tools.wikimedia.de/~luxo/contributions/contributions.php?user='+ prmtnome +'&blocks=true&lang=it';
}
/*</pre>
==Global==
<pre>*/
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Ajax_sysop/experimental.js&action=raw&ctype=text/javascript');
/*</pre>
==Contributi utente==
<pre>*/
$(function () {
if (wgNamespaceNumber != 2 && wgNamespaceNumber != 3) // User or User talk
return;
var user = wgTitle.split("/")[0];
var url = wgScript + "?title=Speciale:Contributi/" + encodeURIComponent(user);
mw.util.addPortletLink("p-tb", url, "Contributi utente", "t-userrcontribs", "Contributi di "+user);
});
/*</pre>
== Nuke link ==
<pre>*/
mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-SpecialNukeOnContribsLink.js&action=raw&ctype=text/javascript');
/*</pre>
== Revert summary ==
<pre>*/
mw.loader.load('//it.wiktionary.org/w/index.php?title=MediaWiki:Gadget-RollbackSummary.js&action=raw&ctype=text/javascript');
/*</pre>
== CSS Globale admin ==
<pre>*/
// Link: [[Utente:Wim b/Admin/Global.css]]
mw.loader.load("//it.wiktionary.org/w/index.php?title=Utente:Wim_b/Admin/Global.css&action=raw&ctype=text/css", 'text/css');
/*</pre>
==Configurazione Popup==
<pre>*/
popupSubpopups = true; // attivazione popup dai link nei popup
popupRevertSummaryPrompt = true; // possibilità di editare l'oggetto della modifica di un rollback
popupDelay = 1.5; // aspetta 1.5 secondi per aprirsi
popupHideDelay=0.3; //aspetta 0.3 secondi prima di chiudersi
popupRedlinkRemoval = true; // elimina i collegamenti a link rossi
popupQueriedRevertSummary = "Rollback da popup. Ripristinata la versione $1 di [[user:$3|$3]]";
popupRedlinkSummary = "Eliminato link rosso: %s";
popupAdminLinks=true; //LINK ALLE FUNZIONI PER ADMIN
popupPreviewKillTemplates=false;
popupPreviewFirstParOnly=false;
popupExtraUserMenu='<menurow><<monobook|shortcut=M>>|<<editMonobook|edit>></menurow>';
popupFixRedirs=true; //CORREGGI REDIRECT
popupFixRedirsSummary='Correggo redirect da [[%s]] a [[%s]] tramite [[w:Wikipedia:Popup di navigazione|popup]]'; //OGGETTO DELLA CORREZIONE DEI REDIRECT
extraPopupFilters=[
function(data) { if (/[{]{2}[Ff]eatured article[}]{2}/.test(data) )
return '<img src="http://upload.wikimedia.org/wikipedia/en/thumb/c/cf/Cscr-featured.png/7px-Cscr-featured.png">';
else return ''; }
];
popupFixDabs = true;
popupImageLinks = true;
// EDIT COUNT
popupEditCounterTool="custom";
popupEditCounterUrl="http://toolserver.org/~vvv/yaec.php?user=$1&wiki=itwiktionary_p";
// /EDIT COUNT
popupAdminLinks=true; // optional: enable admin links
/*</pre>
== Link nei contributi ==
<pre>*/
// codice preso da http://www.mediawiki.org/wiki/MediaWiki:Gadget-SpecialNukeOnContribsLink.js e riadattato da [[m:user:Wim b]]
if( wgCanonicalSpecialPageName === 'Contributions' ) {
$( contribTool );
}
function contribTool() {
var ug = wgUserGroups.join(' '),
ctype,
targ = $( 'input[name="target"]' ).val();
// poorman contribs type finder. -1 = existing user
try {
ctype = $( '#contentSub > a:first' ).attr( 'href' ).indexOf( 'User_talk' );
} catch(e) {
ctype = -1;
}
if( !targ ) {
return;
}
var regIP = /(([0-9]+\.){3}[0-9]|^([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}$)/;
var isIP = regIP.test(targ);
insertContentSubContribTool('http://tools.wmflabs.org/guc/?user=' + targ.replace( ' ', '+' ) + '', 'crosswiki edits' );
insertContentSubContribTool(wgServer +'/wiki/Special:CentralAuth/' + targ.replace( ' ', '_' ) + '', 'Central Auth' );
if (isIP == true ) insertContentSubContribTool('http://toolserver.org/~overlordq/cgi-bin/whois.cgi?lookup=' + targ.replace( ' ', '+' ) + '', 'whois' );
}
//jQuery version of Splarka's insertContentSubContribLink, by Grunny
function insertContentSubContribTool( link, text ) {
$( '#contentSub > a:last' ).after( ' | <a href="' + link + '" title="' + link + '">' + text + '</a>' );
}
/*</pre>
== Link agli edit crosswiki ==
* di [[M:User:Wim b|Wim b]]
<pre>*/
if (wgNamespaceNumber == 2 || wgNamespaceNumber == 3) {
var nome = wgTitle.split("/")[0];
mw.util.addPortletLink('p-tb','https://toolserver.org/~luxo/contributions/contributions.php?user=' + nome + '&blocks=true&lang=it','Crosswiki edit', 't-crosswiki', 'crosswiki edit di ' + nome + '');
}
/*</pre>
== Link Supplementari nei PuntanoQui ==
<pre>*/
/* @source: http://www.mediawiki.org/wiki/Snippets/Special:WhatLinksHere_history_link*/
$( '#mw-whatlinkshere-list li' ).each( function() {
var url = mw.config.get( 'wgScript' ) + '?title=' + encodeURIComponent( $( 'a:first', this ).text() ) + '&action=';
$( '.mw-whatlinkshere-tools a:last', this )
.after( $( '<a>' ).attr( 'href', url + 'delete' ).text( 'cancella' ) ).after( ' | ' )
.after( $( '<a>' ).attr( 'href', url + 'history' ).text( 'crono' ) ).after( ' | ' )
.after( $( '<a>' ).attr( 'href', url + 'edit' ).text( 'edita' ) ).after( ' | ' );
});
/*</pre>
== Rimuovo link a funzionalità beta ==
<pre>*/
$("#pt-betafeatures").remove();
/*</pre>
== motivazione immediate ==
* di [[M:User:Wim b|Wim b]]
<pre>*/
if( wgAction === 'delete' ) {
$('.mw-submit').append(' <input id="DirectButton"type="button" value="Immediata" onclick="SpeedyDel()">');
function SpeedyDel() {
var SpeedyDelNewString = $('#wpReason').val().replace(/(.*?)\{\{([Dd]elete|[Cc]ancella( subito)?)\|(.*?)\}\}(.*)/g,'In cancellazione immediata con la seguente motivazione: $4');
$('#wpReason').val(SpeedyDelNewString);
}
}
/*</pre>
== popup di navigazione ==
<pre>*/
//carica il tool
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
+ '&action=raw&ctype=text/javascript');
//carica la traduzione
mw.loader.load('//it.wikibooks.org/w/index.php?title=Utente:wim_b/strings-it.js'
+ '&action=raw&ctype=text/javascript');
//funzione di blocco utenze
// di [[M:User:Wim b|Wim b]]
function GetBlocco() {
document.getElementById('mw-input-wpReason-other').value = 'Crosswiki Spam: [[m:User:Mathonius/Reports/Nothing to say about me really]]';
document.getElementById('mw-input-wpExpiry').value = 'infinite';
document.getElementById('mw-input-wpCreateAccount').checked = true;
document.getElementById('mw-input-wpDisableEmail').checked = false;
document.getElementById('mw-input-wpDisableUTEdit').checked = true;
document.getElementById('mw-input-wpAutoBlock').checked = true;
document.getElementById('mw-input-wpWatch').checked = false;
document.getElementById('mw-input-wpHardBlock').checked = true;
}
if (wgCanonicalSpecialPageName == 'Block') {
mw.util.addPortletLink('p-navigation','javascript:GetBlocco();','Crosswiki spam');
}