Jump to content

User:Matrix/common.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScript("User:Writ Keeper/Scripts/teahouseUtility.js"); // Gives one-click option to add Teahouse invitation or talkback to a user

importScript("User:Writ Keeper/Scripts/teahouseTalkback.js"); // Adds Talkback reminder when you save an edit at the Teahouse

importScript("User:Writ Keeper/Scripts/teahouseTalkbackLink.js"); // Adds a talkback link to signatures on the Teahouse

importScript("User:Ocaasi/WikiLoveinstallscript.js");// Adds Teahouse Badges to WikiLove


// [[File:Krinkle_RTRC.js]]
(mw.loader.getState('ext.gadget.rtrc') ? mw.loader.load('ext.gadget.rtrc') : mw.loader.load('https://www.mediawiki.org/w/load.php?modules=ext.gadget.rtrc&lang=' + mw.config.get('wgUserLanguage', 'en')));

(mw.loader.getState('ext.gadget.rtrc') ? mw.loader.load('ext.gadget.VisualFileChange') : mw.loader.load('https://commons.wikimedia.org/w/load.php?modules=ext.gadget.VisualFileChange&lang=' + mw.config.get('wgUserLanguage', 'en')));
importScript('User:Enterprisey/cv-revdel.js'); // Backlink: [[User:Enterprisey/cv-revdel.js]]
importScript('User:Chlod/Scripts/Deputy.js'); // Backlink: [[User:Chlod/Scripts/Deputy.js]]

if (mw.config.get('wgNamespaceNumber') === 6 && /SVG/i.test(mw.config.get('wgTitle').slice(-3))) // SVGedit on SVG files only
	importScript('User:Rillke/SVGedit.js');
// [[User:Perhelion/simpleSVGcheck.js]]
if (mw.config.get('wgNamespaceNumber') === 6 && /SVG/i.test(mw.config.get('wgTitle').slice(-3)))
	mw.loader.load('//commons.wikimedia.org/w/index.php?title=User:Sarang/simpleSVGcheck.js&action=raw&ctype=text/javascript');
importScript('User:10nm/beta.js'); // Backlink: [[User:10nm/beta.js]]

if (mw.config.get('wgNamespaceNumber') === 6 && /SVG/i.test(mw.config.get('wgTitle').slice(-3))) // SVGedit on SVG files only
    mw.loader.load( '//commons.wikimedia.org/w/index.php?title=User:Rillke/SVGedit.js&action=raw&ctype=text/javascript' );
importScript('User:Eejit43/scripts/redirect-helper.js'); // Backlink: [[User:Eejit43/scripts/redirect-helper.js]]
importScript('User:MPGuy2824/MoveToDraft.js'); // Backlink: [[User:MPGuy2824/MoveToDraft.js]]
importScript('User:Writ Keeper/Scripts/massRollback.js'); // Backlink: [[User:Writ Keeper/Scripts/massRollback.js]]
importScript('User:Writ Keeper/rollbackSummary.js'); // Backlink: [[User:Writ Keeper/rollbackSummary.js]]
importScript('User:BrandonXLF/FFUHelper.js'); // Backlink: [[User:BrandonXLF/FFUHelper.js]]
importScript('User:Novem_Linguae/Scripts/anrfc-lister.js'); // Backlink: [[User:Novem_Linguae/Scripts/anrfc-lister.js]]
importScript('User:PerfektesChaos/js/lintHint/r.js'); // Backlink: [[User:PerfektesChaos/js/lintHint/r.js]]
importScript('User:Matrix/JWB.js/load.js'); // Backlink: [[User:Matrix/JWB.js/load.js]]
importScript('User:NguoiDungKhongDinhDanh/FormattedEditRequest.js'); // Backlink: [[User:NguoiDungKhongDinhDanh/FormattedEditRequest.js]]



$(function () {
'use strict';
if (mw.config.get('wgNamespaceNumber') !== 6 || mw.config.get('wgAction') !== "view" || !document.getElementById('file'))
	return;

var img = document.getElementById('file').getElementsByTagName('img');
if (!img || !img.length)
	return; // No preview image, e.g. for large PNGs

img = img[0];
var imgURL = img.parentNode.href;
if (!imgURL)
	return; // This occurs with thumbs of videos/sounds for instance

if (img.width <= 300)
	imgURL = img.src; // Image smaller than 300px width
else { // Get thumb url
	var n = imgURL.indexOf("/commons/") + 9;
	imgURL = imgURL.substr(0, n) + "thumb/" + imgURL.substr(n);
	n = imgURL.lastIndexOf('/') + 1;
	imgURL += "/300px-" + imgURL.substring(n);
	if (!imgURL.slice(-3).indexOf("svg"))
		imgURL += ".png";
}

var portletLink = mw.util.addPortletLink('p-cactions', 'https://lens.google.com/uploadbyurl?url=' + encodeURIComponent(imgURL), 'Google Lens', 'ca-googleimages', null);
if(portletLink && portletLink.children[0]) portletLink.children[0].target = '_blank';

portletLink = mw.util.addPortletLink('p-cactions', 'https://tineye.com/search?url=' + encodeURIComponent(imgURL) + '&sort=size&order=desc', 'TinEye', 'ca-tineye', null);
if(portletLink && portletLink.children[0]) portletLink.children[0].target = '_blank';

portletLink = mw.util.addPortletLink('p-cactions', 'https://yandex.com/images/search?rpt=imageview&url=' + encodeURIComponent(imgURL), 'Yandex', 'ca-yandex', null);
if(portletLink && portletLink.children[0]) portletLink.children[0].target = '_blank';


});