Jump to content

User:Troyp/common.js

From Wiktionary, the free dictionary

Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

This JavaScript is executed for Troyp on every page load.


importScript('User:Equazcion/ScriptInstaller.js');
importScript('User:Dixtosa/WhoDidThat.js');

// googleTitle.js - modified
$(document).ready(function()
{
		if(mw.config.get("wgCanonicalNamespace") == "")
		{
			var subjectName;
			var pageName = mw.config.get("wgPageName");
			if(pageName.charAt(pageName.length - 1) == ")")
			{
				subjectName = pageName.substring(0, pageName.lastIndexOf("(") - 1);
			}
			else
			{
				subjectName = pageName;
			}
			var google = " <a href='http://www.google.com/search?q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "+-wikipedia.org' target='_blank' class='_added-by-script'><span style='font-size:x-small;'>【Search Google】</span></a>"
			$("#firstHeading").append(google);
			var googleImages = " <a href='https://www.google.com/search?site=imghp&tbm=isch&biw=1920&q=" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "+-wikipedia.org' target='_blank' class='_added-by-script'><span style='font-size:x-small;'>【Search Google Images】</span></a>"
			$("#firstHeading").append(googleImages);
			
/*
			var searchNode = document.createElement("a");
			searchNode.href = "http://www.google.com/search?q=" + encodeURIComponent(subjectName.replace(/_/g, " ")) + "+-wikipedia.org";
			searchNode.target = "_blank";
			searchNode.innerHTML = " <span style='font-size:x-small;'>Search Google</span>";
			document.getElementById("firstHeading").appendChild(searchNode);
*/
		}
});