User:FDMS4/common.js

mw.loader.load( "//en.wikipedia.org/w/index.php?title=User:Kephir/gadgets/jssand.js&action=raw&ctype=text/javascript" );

jQuery(document).ready(function { 'use strict';	if (mw.config.get('wgNamespaceNumber') !== 6 || mw.config.get('wgAction') !== "view" || !document.getElementById('file')) return;	var imgs = document.getElementById('file').getElementsByTagName('img');	if (!imgs || imgs.length === 0) return; // No preview image, e.g. for large PNGs	var imageurl = imgs[0].parentNode.href;	if (!imageurl) return;	if (document.getElementById('file').getElementsByTagName('img').length <= 0) return; 	if (document.getElementById('file').getElementsByTagName('img')[0].width <= 300) {		imageurl = document.getElementById('file').getElementsByTagName('img')[0].src; //Image smaller than 300px width	} else {		var n = imageurl.indexOf("/en/");		imageurl = imageurl.substring(0, n + ("/en/").length) + "thumb/" + imageurl.substring(n + ("/en/").length);		n = imageurl.lastIndexOf('/') + 1;		imageurl = imageurl + "/300px-" + imageurl.substring(n); }	mw.util.addPortletLink('p-cactions', 'https://www.bing.com/images/search?q=imgurl:' + encodeURIComponent(imageurl) + '&view=detailv2&iss=sbi&FORM=IRSBIQ#enterInsights', 'Bing', 'ca-googleimages', null); }); // Gadget-GoogleImages.js © (CC BY-SA 3.0) authors of https://commons.wikimedia.org/wiki/MediaWiki:Gadget-GoogleImages.js