Utente:Mr buick/common.js
Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.
Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.
/* This script adds "Source links" below "What links here" in the sidebar.
"What links here" will include pages using a template with the link.
"Source links" tries to search for pages where the link is in the source.
To use the script, add the following line to Special:MyPage/common.js:
importScript('User:PrimeHunter/Source links.js'); // Linkback: [[User:PrimeHunter/Source links.js]]
*/
mw.loader.using(['mediawiki.util'], function () {
var name = mw.config.get( 'wgPageName' ).replace("Special:WhatLinksHere/", "");
var url;
try {
url = mw.util.getUrl( 'Special:Search' ) + '?profile=all&search=' +
encodeURIComponent('linksto:"' + name + '" ' + 'insource:"' + name + '" ' +
'insource:/\\[\\[:?[' + name[0] + name.charAt(0).toLowerCase() + ']' +
name.substring(1).replace(/[-[\]{}()*+!<=:?.\/\\^$|#\s,]/g, '\\$&') + '[\\]\\|#]/' ).replace(/_/g, " ");
} catch(e) {
url = '#error'; // EXAMPLE URL: https://en.wikipedia.org/w/index.php?title=%F0%9F%91%A9%F0%9F%8F%BF&action=history
}
mw.util.addPortletLink(
'p-tb',
url,
'Source links',
'pt-sourcelinks',
'What links here in the source',
null,
'#t-recentchangeslinked'
);
});