User:Ilmari Karonen/common.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
The accompanying .css page for this skin can be added at User:Ilmari Karonen/common.css. |
- Report page listing warnings and errors.
/**
* Load a script from another Wikimedia wiki. Based on importScript() in wikibits.js.
* Does the right thing also when used via the secure server.
*
* Usage example: importScriptFromWiki("User:Ilmari Karonen/replace.js", "en", "wikipedia");
*
* Leave the third parameter empty for wikis like meta or commons that have ".wikimedia.org"
* host names but belong internally to the "wikipedia" group for historical reasons!
*/
function importScriptFromWiki(page, lang, domain) {
if (wgServer == 'https://secure.wikimedia.org') {
if (!domain) domain = 'wikipedia';
var prefix = '/' + domain + '/' + lang;
} else {
if (!domain) domain = 'wikimedia';
var prefix = 'http://' + lang + '.' + domain + '.org';
if (prefix == wgServer) prefix = "";
}
var uri = prefix + '/w/index.php?title=' +
encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') +
'&action=raw&ctype=text/javascript';
return mw.loader.load(uri);
}
importScriptFromWiki('User:Ilmari_Karonen/catsort.js', 'en', 'wikipedia');
importScriptFromWiki('User:Ilmari_Karonen/checkusage.js', 'en', 'wikipedia');
importScriptFromWiki('User:Ilmari_Karonen/fixconverttosvg.js', 'en', 'wikipedia');
importScriptFromWiki('User:Ilmari_Karonen/ifdthumbnails.js', 'en', 'wikipedia');
importScriptFromWiki('User:Ilmari_Karonen/replace.js', 'en', 'wikipedia');
importScriptFromWiki('User:Ilmari_Karonen/searchnsmenu.js', 'en', 'wikipedia');
importScriptFromWiki('User:Ilmari_Karonen/sigdash.js', 'en', 'wikipedia');
importScriptFromWiki('User:Ilmari_Karonen/watchsince.js', 'en', 'wikipedia');
importScript('User:Ilmari Karonen/licensemigration.js');
importScript('User:Ilmari Karonen/rollbacksummary.js'); // test local copy
importScript('User:Ilmari Karonen/ajax quick delete.js'); // test
// quick link to API image info
if (wgNamespaceNumber == 6) addOnloadHook(function () {
var url = wgScriptPath + "/api.php?action=query&prop=imageinfo&iiprop=timestamp|user|comment|url|size|sha1|mime|metadata|archivename&iilimit=50&titles=" + encodeURIComponent(mw.config.get('wgPageName'));
mw.util.addPortletLink('p-tb', url, 'API file info', 't-apiimageinfo', 'Get extra information about this file from the MediaWiki API');
});
// test script to look for identically named and sized images on Google
if (wgNamespaceNumber == 6) addOnloadHook(function () {
// extract image size from history table (could also use the API or parse the "file" section, but this seems simplest
var history = document.getElementById("mw-imagepage-section-filehistory");
if (!history) return;
var cells = history.getElementsByTagName("td");
for (var i = 0; i < cells.length; i++) {
var match = /^(\d+(?:[,.\s\xA0]\d{3})*)×(\d+(?:[,.\s\xA0]\d{3})*)\b/.exec( cells[i].textContent );
if (!match) continue;
// found it! add portlet and return.
var w = match[1].replace(/[^0-9]+/g, "");
var h = match[2].replace(/[^0-9]+/g, "");
var q = '"' + wgTitle.replace(/\.[^.]+$/, "") + '"';
var url = "http://images.google.com/images?q=" + encodeURIComponent(q) + "&tbs=isch:1,isz:ex,iszw:" + w + ",iszh:" + h;
mw.util.addPortletLink('p-tb', url, 'Find on Google', 't-googleimagesize', 'Find images with the same title and size on Google image search');
return;
}
});