Link Guru

Adds boxes full on links to a few sites.

  1. // ==UserScript==
  2. // @name Link Guru
  3. // @namespace http://greasyfork.org/users/2240-doodles
  4. // @author Doodles
  5. // @version 5
  6. // @description Adds boxes full on links to a few sites.
  7. // @match *://*.wikipedia.org/*
  8. // @match *://www.google.com/search?*
  9. // @include *://www.google.co.*/search?*
  10. // @match *://*.wiktionary.org/wiki/*
  11. // @match *://www.imdb.com/*
  12. // @match *://www.rottentomatoes.com/*
  13. // @run-at document-end
  14. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
  15. // @require https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js
  16. // @require https://greasyfork.org/scripts/38339-little-site-icons/code/Little%20Site%20Icons.js?version=250233
  17. // @grant GM_getValue
  18. // @grant GM_setValue
  19. // ==/UserScript==
  20.  
  21. this.$ = this.jQuery = jQuery.noConflict(true);
  22. var lgSettings = [];
  23.  
  24. var unknownIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2' +
  25. 'AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAA' +
  26. 'AAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4Onht' +
  27. 'cG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDEx' +
  28. 'IDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJo' +
  29. 'dHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiBy' +
  30. 'ZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBN' +
  31. 'TT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9i' +
  32. 'ZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9z' +
  33. 'aG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OTYxQkY0MkQwQjAwMTFFODg3' +
  34. 'QjZFNTlGOTU1NTYzMzEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OTYxQkY0MkUwQjAwMTFFODg3QjZF' +
  35. 'NTlGOTU1NTYzMzEiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5NjFC' +
  36. 'RjQyQjBCMDAxMUU4ODdCNkU1OUY5NTU1NjMzMSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo5NjFCRjQy' +
  37. 'QzBCMDAxMUU4ODdCNkU1OUY5NTU1NjMzMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6' +
  38. 'eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PvesF4UAAABtSURBVHjaYrxbGspACmABYvFsPyJVv5y6iYmB' +
  39. 'RMCCKcSjEAtnf3mwGE2WCY9qTC66DRBpZFOBIkCELIKiAc0BmMZjcRKmajRTmEhSjc8GrKqxBysupQSchNXH' +
  40. 'BJxEbEyT4yQCNgDTIPEaAAIMALyJIxfWPzt6AAAAAElFTkSuQmCC';
  41.  
  42. $(document).ready(function () {
  43. "use strict";
  44.  
  45. $("<style></style>").prop("type", "text/css").html(
  46. 'div#lgSettingsContainer {padding:2px 2px 0 0;float:left;display:block;z-index:1000;}' +
  47. 'div#lgLinkContainer {padding:0 0 3px 0;margin:0 0 10px 0;line-height:16px;font-size:' +
  48. '12px;}div#lgLinkContainer a img {display:inline-block;vertical-align:middle;width:16' +
  49. 'px;height:16px;}div#lgLinkContainer a {display:inline-block;}div#lgLinkContainer a s' +
  50. 'pan {vertical-align:middle;display:inline-block;margin:0 7px 0 3px;}.ui-corner-all {' +
  51. 'border-radius:0 !important;}.ui-dialog {z-index:403 !important;background-color:#CCC' +
  52. ';background:#CCC;color:#333;font-size:14px;border:1px solid #FFF;box-shadow:5px 5px ' +
  53. '5px rgba(0, 0, 0, 0.5);font-family:Arial, Helvetica, Verdana, sans-serif !important;' +
  54. 'outline:1px solid #000;}.ui-widget-content {background-color:#AAAAAA;background:#AAA' +
  55. 'AAA;border:none !important;}.ui-dialog-titlebar {font-size:16px;background-color:#AA' +
  56. 'AAAA;background:#AAAAAA;padding:4px 4px 4px 7px;text-shadow:1px 1px 2px #000000;colo' +
  57. 'r:#daf0ff;font-weight:bold;border:none !important;}.ui-dialog-titlebar-close {float:' +
  58. 'right !important;height:19px !important;background-color:#3498db !important;border:1' +
  59. 'px solid #222222 !important;background-image:none !important;text-shadow:1px 1px 1px' +
  60. ' #000000 !important;font-size:11px !important;font-weight:bold !important;color:#FFF' +
  61. ' !important;}.ui-dialog-titlebar-close:after {content:"Close";}.ui-dialog-titlebar-c' +
  62. 'lose:hover {background-color:#3cb0fd !important;}.ui-dialog-titlebar-close span {dis' +
  63. 'play:none;}.ui-dialog-content {background-color:#CCC;padding:5px;border:none !import' +
  64. 'ant;color:#000;}.ui-dialog-buttonpane {padding:2px 7px 7px 7px;background-color:none' +
  65. ' !important;background:none !important;border:none;}.ui-dialog-buttonset {text-align' +
  66. ':right;}.ui-dialog-buttonset button {background-color:#3498db !important;border:1px ' +
  67. 'solid #222222 !important;background-image:none !important;text-shadow:1px 1px 1px #0' +
  68. '00000;font-size:16px;font-weight:bold;color:#FFF;font-family:Arial, Helvetica, Verda' +
  69. 'na, sans-serif !important;padding:2px 12px 3px 12px;margin-left:3px;}.ui-dialog-butt' +
  70. 'onset button:hover {background-color:#3cb0fd !important;}.ui-widget-overlay {positio' +
  71. 'n:absolute;top:0;left:0;width:100%;height:100%;background-color:#000000;opacity:.60;' +
  72. 'filter:Alpha(Opacity=60);background-image:none !important;}.ui-tabs .ui-tabs-nav {di' +
  73. 'splay:block;margin:0;padding:0;border: none;background-color:#AAAAAA;background:#AAA' +
  74. 'AAA;}.ui-tabs .ui-tabs-nav li {list-style:none;float:left;margin:0 6px 1px 0;border:' +
  75. ' none;border-radius:0 !important;}a.ui-tabs-anchor:link {list-style:none;display:inl' +
  76. 'ine-block;margin:0 0 0 0;}a.ui-tabs-anchor:link, a.ui-tabs-anchor:visited {display:i' +
  77. 'nline-block;padding:2px 12px 3px 12px;background-color:#446382;color:#FFF;font-weigh' +
  78. 't:bold;text-decoration:none;}a.ui-tabs-anchor:hover, a.ui-tabs-anchor:active, a.ui-t' +
  79. 'abs-anchor:focus {background-color:#F5F5F5;color:#000;}.ui-tabs-active a.ui-tabs-anc' +
  80. 'hor:link, .ui-tabs-active a.ui-tabs-anchor:visited {background-color:#F5F5F5;color:#' +
  81. '000;}.ui-tabs-active a.ui-tabs-anchor:hover, .ui-tabs-active a.ui-tabs-anchor:active' +
  82. ', .ui-tabs-active a.ui-tabs-anchor:focus {background-color:#F5F5F5;color:#000;}.ui-t' +
  83. 'abs .ui-tabs-panel {clear:left;background-color:#F5F5F5;height:251px;padding:5px;bor' +
  84. 'der-radius:0 !important;}.ui-tabs .ui-tabs-panel p {padding:0 5px 3px 5px;margin:0 0' +
  85. ' 0 0;}div#lgSettingsTabs hr {margin:2px 0 2px 0;border: none;height: 1px;background-' +
  86. 'color:#AAAAAA;}div.lgSettingsPadder {padding:0 25px 0 25px;}label.lgSetCheckbox {pad' +
  87. 'ding:2px;display:block;line-height:16px;}label.lgSetCheckbox input[type="checkbox"] ' +
  88. '{margin-right:5px;line-height:16px;}div.lgSetRadioHeader {padding:2px 5px 2px 5px;li' +
  89. 'ne-height:16px;}label.lgSetRadio {padding:2px;display:inline-block;line-height:16px;' +
  90. '}label.lgSetRadio input[type="radio"] {margin-right:5px;line-height:16px;}div.lgSett' +
  91. 'ingsFooter {padding:3px;margin:0 0 0 0;font-size:10px;}').appendTo("head");
  92. $("body").append(
  93. '<div id="lgSettingsDialog" title="Link Guru - Settings"><div id="lgSettingsTabs"><ul' +
  94. '><li><a href="#tabs-1">Wikipedia</a></li><li><a href="#tabs-2">Wiktionary</a></li><l' +
  95. 'i><a href="#tabs-3">IMDb</a></li><li><a href="#tabs-4">Rotten Tomatoes</a></li><li><' +
  96. 'a href="#tabs-5">Google</a></li></ul><div id="tabs-1"><p>Add links to Wikipedia arti' +
  97. 'cles. The links are searches using the article&#39;s title as the search parameter.<' +
  98. '/p><hr /><label class="lgSetCheckbox"><input type="checkbox" name="lgSetWikipediaEna' +
  99. 'bled" id="lgSetWikipediaEnabled"><strong>Enabled</strong> - Enable/Disable Link Guru' +
  100. ' on Wikipedia</label><hr /><label class="lgSetCheckbox"><input type="checkbox" name=' +
  101. '"lgSetWikipediaNewtab" id="lgSetWikipediaNewtab"><strong>New Tab</strong> - Links wi' +
  102. 'll automatically open in a new tab.</label><hr /><div class="lgSetRadioHeader"><stro' +
  103. 'ng>Display Style</strong> - How the links are displayed.</div><div class="lgSettings' +
  104. 'Padder"><label class="lgSetRadio"><input type="radio" name="lgSetWikipediaStyle" val' +
  105. 'ue="0"><strong>Icon</strong></label><label class="lgSetRadio"><input type="radio" na' +
  106. 'me="lgSetWikipediaStyle" value="1"><strong>Text</strong></label><label class="lgSetR' +
  107. 'adio"><input type="radio" name="lgSetWikipediaStyle" value="2"><strong>Icon and Text' +
  108. '</strong></label></div></div><div id="tabs-2"><p>Add links to Wiktionary word pages.' +
  109. ' The links are other dictionaries and word related services.</p><hr /><label class="' +
  110. 'lgSetCheckbox"><input type="checkbox" name="lgSetWiktionaryEnabled" id="lgSetWiktion' +
  111. 'aryEnabled"><strong>Enabled</strong> - Enable/Disable Link Guru on Wiktionary</label' +
  112. '><hr /><label class="lgSetCheckbox"><input type="checkbox" name="lgSetWiktionaryNewt' +
  113. 'ab" id="lgSetWiktionaryNewtab"><strong>New Tab</strong> - Links will automatically o' +
  114. 'pen in a new tab.</label><hr /><div class="lgSetRadioHeader"><strong>Display Style</' +
  115. 'strong> - How the links are displayed.</div><div class="lgSettingsPadder"><label cla' +
  116. 'ss="lgSetRadio"><input type="radio" name="lgSetWiktionaryStyle" value="0"><strong>Ic' +
  117. 'on</strong></label><label class="lgSetRadio"><input type="radio" name="lgSetWiktiona' +
  118. 'ryStyle" value="1"><strong>Text</strong></label><label class="lgSetRadio"><input typ' +
  119. 'e="radio" name="lgSetWiktionaryStyle" value="2"><strong>Icon and Text</strong></labe' +
  120. 'l></div></div><div id="tabs-3"><p>Add search links to Movie, TV Series, Person, and ' +
  121. 'Character pages.</p><hr /><label class="lgSetCheckbox"><input type="checkbox" name="' +
  122. 'lgSetImdbEnabled" id="lgSetImdbEnabled"><strong>Enabled</strong> - Enable/Disable Li' +
  123. 'nk Guru on IMDb</label><hr /><label class="lgSetCheckbox"><input type="checkbox" nam' +
  124. 'e="lgSetImdbNewtab" id="lgSetImdbNewtab"><strong>New Tab</strong> - Links will autom' +
  125. 'atically open in a new tab.</label><hr /><div class="lgSetRadioHeader"><strong>Displ' +
  126. 'ay Style</strong> - How the links are displayed.</div><div class="lgSettingsPadder">' +
  127. '<label class="lgSetRadio"><input type="radio" name="lgSetImdbStyle" value="0"><stron' +
  128. 'g>Icon</strong></label><label class="lgSetRadio"><input type="radio" name="lgSetImdb' +
  129. 'Style" value="1"><strong>Text</strong></label><label class="lgSetRadio"><input type=' +
  130. '"radio" name="lgSetImdbStyle" value="2"><strong>Icon and Text</strong></label></div>' +
  131. '</div><div id="tabs-4"><p>Add search links to Movie and Person pages.</p><hr /><labe' +
  132. 'l class="lgSetCheckbox"><input type="checkbox" name="lgSetRottenEnabled" id="lgSetRo' +
  133. 'ttenEnabled"><strong>Enabled</strong> - Enable/Disable Link Guru on Rotten Tomatoes<' +
  134. '/label><hr /><label class="lgSetCheckbox"><input type="checkbox" name="lgSetRottenNe' +
  135. 'wtab" id="lgSetRottenNewtab"><strong>New Tab</strong> - Links will automatically ope' +
  136. 'n in a new tab.</label><hr /><div class="lgSetRadioHeader"><strong>Display Style</st' +
  137. 'rong> - How the links are displayed.</div><div class="lgSettingsPadder"><label class' +
  138. '="lgSetRadio"><input type="radio" name="lgSetRottenStyle" value="0"><strong>Icon</st' +
  139. 'rong></label><label class="lgSetRadio"><input type="radio" name="lgSetRottenStyle" v' +
  140. 'alue="1"><strong>Text</strong></label><label class="lgSetRadio"><input type="radio" ' +
  141. 'name="lgSetRottenStyle" value="2"><strong>Icon and Text</strong></label></div></div>' +
  142. '<div id="tabs-5"><p>Replaces the "Videos" tab on Google searches with a link to a Yo' +
  143. 'uTube search with the same search parameter.</p><hr /><label class="lgSetCheckbox"><' +
  144. 'input type="checkbox" name="lgSetGoogleEnabled" id="lgSetGoogleEnabled"><strong>Enab' +
  145. 'led</strong> - Enable/Disable Link Guru on Google</label><hr /><label class="lgSetCh' +
  146. 'eckbox"><input type="checkbox" name="lgSetGoogleDefinition" id="lgSetGoogleDefinitio' +
  147. 'n"><strong>Defintion Links</strong> - Add word related links to Google definition bo' +
  148. 'xes.</label></div></div><div class="lgSettingsFooter">Settings changes do not immedi' +
  149. 'ately take effect. A refresh is required.</div></div>');
  150. $("#lgSettingsTabs").tabs();
  151. $("#lgSettingsDialog").dialog({
  152. modal: true, resizable: false, autoOpen: false, width: 634,
  153. position: {my: "center top", at: "center top+120", of: window}
  154. });
  155. var settingsLink = $('<a href="#" id="lgSettingsLink">Link Guru Settings</a>');
  156. $(settingsLink).click(function (e) {
  157. e.preventDefault();
  158. $("#lgSettingsDialog").dialog("open");
  159. });
  160. // =======================================================================================================================
  161. // Stored Data Variables
  162. SetupBoolVariable("WikipediaEnabled", true);
  163. SetupBoolVariable("WiktionaryEnabled", true);
  164. SetupBoolVariable("RottenEnabled", true);
  165. SetupBoolVariable("ImdbEnabled", true);
  166. SetupBoolVariable("GoogleEnabled", true);
  167. SetupBoolVariable("WikipediaNewtab", false);
  168. SetupBoolVariable("WiktionaryNewtab", false);
  169. SetupBoolVariable("RottenNewtab", false);
  170. SetupBoolVariable("ImdbNewtab", false);
  171. SetupRadioVariable("WikipediaStyle", 2);
  172. SetupRadioVariable("WiktionaryStyle", 2);
  173. SetupRadioVariable("RottenStyle", 2);
  174. SetupRadioVariable("ImdbStyle", 2);
  175. SetupBoolVariable("GoogleDefinition", true);
  176. var links = [];
  177. // =======================================================================================================================
  178. // WIKIPEDIA
  179. if (UrlContains("wikipedia.org") && window.top === window.self) {
  180. links.push(["Google", "Google search for {{PARAM}}", "http://www.google.com/search?output=search&q={{PARAM}}", "google"]);
  181. links.push(["Google Image", "Google Image search for {{PARAM}}", "http://www.google.com/search?tbm=isch&q={{PARAM}}", "googleimage"]);
  182. links.push(["YouTube", "YouTube search for {{PARAM}}", "https://www.youtube.com/results?search_query={{PARAM}}", "youtube"]);
  183. if ($("ul > li > a.external[href*='www.imdb.com']").length) {
  184. links.push(["IMDb", "IMDb - {{PARAM}}", $("ul > li > a.external[href*='www.imdb.com']").attr('href'), "imdb"]);
  185. } else {
  186. links.push(["IMDb", "IMDb search for {{PARAM}}", "http://www.imdb.com/find?s=all&q={{PARAM}}", "imdb"]);
  187. }
  188. if ($("a[href='/wiki/Portal:Anime_and_Manga']").length) {
  189. links.push(["MyAnimeList", "MyAnimeList search for {{PARAM}}", "https://myanimelist.net/search/all?q={{PARAM}}", "myanimelist"]);
  190. }
  191. links.push(["Pirate Bay", "The Pirate Bay search for {{PARAM}}", "https://thepiratebay.org/search/{{PARAM}}/0/99/0", "thepiratebay"]);
  192. links.push(["Imgur", "Imgur search for {{PARAM}}", "http://imgur.com/search?q={{PARAM}}", "imgur"]);
  193. links.push(["last.fm", "Last.fm search for {{PARAM}}", "http://www.last.fm/search?q={{PARAM}}&type=track", "lastfm"]);
  194. $("#p-navigation > div.body > ul").append($("<li></li>").append(settingsLink));
  195. if (lgSettings['WikipediaEnabled'] && !UrlContains("/wiki/Main_Page")
  196. && !UrlContains("/wiki/Portal:") && !UrlContains("/wiki/Talk:")
  197. && $("h1#firstHeading") && $("li#ca-nstab-main.selected")) {
  198. var pageTitle = $("h1#firstHeading").text();
  199. pageTitle = pageTitle.lgReplaceAll("<i>", "").lgReplaceAll("</i>", "");
  200. pageTitle = pageTitle.lgReplaceAll("&equals;", "%3D").lgReplaceAll("&#61;", "%3D").lgReplaceAll("=", "%3D");
  201. pageTitle = pageTitle.lgReplaceAll("&amp;", "%26").lgReplaceAll("&#38;", "%26").lgReplaceAll("&", "%26");
  202. pageTitle = pageTitle.replace(" (film)", "").replace("(film)", "").replace(" film)", ")");
  203. $(CreateLinkContainer(links, pageTitle, lgSettings["WikipediaStyle"], lgSettings["WikipediaNewtab"])).insertBefore("h1#firstHeading");
  204. $('div#lgLinkContainer').css({'float': 'right', 'padding': '10px 0 10px 0'});
  205. if ($('div.mw-indicators').children().length > 0) {
  206. $('div.mw-indicators').css({'padding-left': '25px'});
  207. }
  208. }
  209. }
  210. // =======================================================================================================================
  211. // WIKTIONARY
  212. if (UrlContains("wiktionary.org") && window.top === window.self) {
  213. links.push(["Merriam-Webster", "Merriam-Webster Dictionary and Thesaurus", "http://www.merriam-webster.com/dictionary/{{PARAM}}", "merriamwebster"]);
  214. links.push(["Thesaurus.com", "Thesaurus.com", "http://thesaurus.com/browse/{{PARAM}}", "thesaurus"]);
  215. links.push(["Google", "Google search for define:{{PARAM}}", "http://www.google.com/search?output=search&q=define:{{PARAM}}", "google"]);
  216. links.push(["Synonym.com", "Synonym.com", "http://www.synonym.com/synonyms/{{PARAM}}/", "synonym"]);
  217. links.push(["Wikisaurus", "Wikisaurus", "http://wiktionary.org/wiki/Wikisaurus:{{PARAM}}", "wiktionary"]);
  218. links.push(["One Look", "One Look", "http://www.onelook.com/?w={{PARAM}}&ls=a", "onelook"]);
  219. links.push(["Wolfram|Alpha", "Wolfram|Alpha", "http://www.wolframalpha.com/input/?i={{PARAM}}", "wolframalpha"]);
  220. links.push(["Urban Dictionary", "Urban Dictionary", "http://www.urbandictionary.com/define.php?term={{PARAM}}", "urbandictionary"]);
  221. links.push(["iTools", "iTools", "http://itools.com/language/dictionary?q={{PARAM}}&submit=English+Dictionary", "itools"]);
  222. links.push(["Vocabulary.com", "Vocabulary.com Dictionary", "http://www.vocabulary.com/dictionary/{{PARAM}}", "vocabulary"]);
  223. links.push(["Cambridge", "Cambridge Dictionary", "http://dictionary.cambridge.org/dictionary/english/{{PARAM}}", "cambridge"]);
  224. links.push(["RhymeZone", "RhymeZone", "http://www.rhymezone.com/r/rhyme.cgi?Word={{PARAM}}&typeofrhyme=perfect&org1=syl&org2=l&org3=y", "rhymezone"]);
  225. links.push(["Online Etymology", "Online Etymology Dictionary", "http://www.etymonline.com/index.php?search={{PARAM}}", "etymonline"]);
  226. links.push(["howjsay", "howjsay: Online Dictionary of English Pronunciation", "http://howjsay.com/index.php?word={{PARAM}}", "howjsay"]);
  227. $("#p-navigation > div.body > ul").append($("<li></li>").append(settingsLink));
  228. if (lgSettings["WiktionaryEnabled"] && !UrlContains("/wiki/Wiktionary:Main_Page")
  229. && !UrlContains("/wiki/Index:") && !UrlContains("/wiki/Talk:")
  230. && !UrlContains("/wiki/Special:") && !UrlContains("/wiki/Category:")
  231. && $("h1#firstHeading") && $("li#ca-nstab-main.selected")) {
  232. var pageTitle = $("h1#firstHeading").text().lgReplaceAll("<i>", "").lgReplaceAll("</i>", "");
  233. $(CreateLinkContainer(links, pageTitle, lgSettings["WiktionaryStyle"], lgSettings["WiktionaryNewtab"])).insertBefore("h1#firstHeading");
  234. $("div#lgLinkContainer").css({"float": "right", "padding": "10px 0 10px 0"});
  235. }
  236. }
  237. // =======================================================================================================================
  238. // Rotten Tomatoes
  239. if (UrlContains("www.rottentomatoes.com") && window.top === window.self) {
  240. $("div.header_links").prepend(settingsLink);
  241. if (lgSettings["RottenEnabled"]) {
  242. if (UrlContains("rottentomatoes.com/m/")) {
  243. links.push(["YouTube", "YouTube search for {{PARAM}} trailer", "http://www.youtube.com/results?search_query={{PARAM}} trailer", "youtube"]);
  244. links.push(["Google Image", "Google Image search for {{PARAM}}", "http://www.google.com/search?tbm=isch&q={{PARAM}}", "google"]);
  245. links.push(["Google", "Google search for {{PARAM}}", "http://www.google.com/search?output=search&q={{PARAM}}", "googleimage"]);
  246. links.push(["Wikipedia", "Wikipedia search for {{PARAM}}", "http://en.wikipedia.org/w/index.php?title=Special:Search&search={{PARAM}}", "wikipedia"]);
  247. links.push(["IMDb", "IMDb search for {{PARAM}}", "http://www.imdb.com/find?s=all&q={{PARAM}}", "imdb"]);
  248. links.push(["MetaCritic", "MetaCritic search for {{PARAM}}", "http://www.metacritic.com/search/all/{{PARAM}}/results", "metacritic"]);
  249. links.push(["AllMovie", "AllMovie search for {{PARAM}}", "http://www.allmovie.com/search/movies/{{PARAM}}", "allmovie"]);
  250. links.push(["Box Office Mojo", "Box Office Mojo search for {{PARAM}}", "http://www.boxofficemojo.com/search/?q={{PARAM}}", "boxofficemojo"]);
  251. links.push(["Movie Mistakes", "Movie Mistakes search for {{PARAM}}", "http://www.moviemistakes.com/search.php?text={{PARAM}}", "moviemistakes"]);
  252. links.push(["Letterboxd", "Letterboxd search for {{PARAM}}", "http://letterboxd.com/search/{{PARAM}}/", "letterboxd"]);
  253. links.push(["Pirate Bay", "The Pirate Bay search for {{PARAM}}", "http://thepiratebay.org/search/{{PARAM}}/0/99/200", "thepiratebay"]);
  254. links.push(["YIFY Subtitles", "YIFY Subtitles search for {{PARAM}}", "http://www.yifysubtitles.com/search?q={{PARAM}}", "yifysubtitles"]);
  255. links.push(["Imgur", "Imgur search for {{PARAM}}", "http://imgur.com/search?q={{PARAM}}", "imgur"]);
  256. var titleText = $("h1.title.hidden-xs").html().split("<span")[0].trim();
  257. titleText = titleText.lgReplaceAll("/", " ").lgReplaceAll("\\", " ");
  258. $(CreateLinkContainer(links, titleText, lgSettings["RottenStyle"], lgSettings["RottenNewtab"])).insertBefore("div#topSection");
  259. $("div#lgLinkContainer").css({"padding": "8px 0 8px 0", "margin-bottom": "0"});
  260. $("div#topSection").css({"margin-top": "0"});
  261. } else if (UrlContains("rottentomatoes.com/tv/")) {
  262. links.push(["YouTube", "YouTube search for {{PARAM}} trailer", "http://www.youtube.com/results?search_query={{PARAM}} trailer", "youtube"]);
  263. links.push(["Google Image", "Google Image search for {{PARAM}}", "http://www.google.com/search?tbm=isch&q={{PARAM}}", "google"]);
  264. links.push(["Google", "Google search for {{PARAM}}", "http://www.google.com/search?output=search&q={{PARAM}}", "googleimage"]);
  265. links.push(["Wikipedia", "Wikipedia search for {{PARAM}}", "http://en.wikipedia.org/w/index.php?title=Special:Search&search={{PARAM}}", "wikipedia"]);
  266. links.push(["IMDb", "IMDb search for {{PARAM}}", "http://www.imdb.com/find?s=all&q={{PARAM}}", "imdb"]);
  267. links.push(["MetaCritic", "MetaCritic search for {{PARAM}}", "http://www.metacritic.com/search/all/{{PARAM}}/results", "metacritic"]);
  268. links.push(["AllMovie", "AllMovie search for {{PARAM}}", "http://www.allmovie.com/search/movies/{{PARAM}}", "allmovie"]);
  269. links.push(["Box Office Mojo", "Box Office Mojo search for {{PARAM}}", "http://www.boxofficemojo.com/search/?q={{PARAM}}", "boxofficemojo"]);
  270. links.push(["Movie Mistakes", "Movie Mistakes search for {{PARAM}}", "http://www.moviemistakes.com/search.php?text={{PARAM}}", "moviemistakes"]);
  271. links.push(["Letterboxd", "Letterboxd search for {{PARAM}}", "http://letterboxd.com/search/{{PARAM}}/", "letterboxd"]);
  272. links.push(["Episode Calendar", "Episode Calendar search for {{PARAM}}", "http://episodecalendar.com/en/shows?q[name_cont]={{PARAM}}", "episodecalendar"]);
  273. links.push(["Pirate Bay", "The Pirate Bay search for {{PARAM}}", "http://thepiratebay.org/search/{{PARAM}}/0/99/200", "thepiratebay"]);
  274. links.push(["YIFY Subtitles", "YIFY Subtitles search for {{PARAM}}", "http://www.yifysubtitles.com/search?q={{PARAM}}", "yifysubtitles"]);
  275. links.push(["Imgur", "Imgur search for {{PARAM}}", "http://imgur.com/search?q={{PARAM}}", "imgur"]);
  276. if (document.URL.split("/tv/")[1].split("/").length > 1) {
  277. var titleText = $("h1.movie_title").html().split("<span")[0].split(": Season")[0].split(": season")[0].trim();
  278. titleText = titleText.lgReplaceAll("/", " ").lgReplaceAll("\\", " ");
  279. $(CreateLinkContainer(links, titleText, lgSettings["RottenStyle"], lgSettings["RottenNewtab"])).insertAfter("div#season_score_panel");
  280. $("div#lgLinkContainer").css({"padding": "8px 0 8px 0", "margin-bottom": "0", "float": "left", "width": "70%"});
  281. } else {
  282. var titleText = $('h1.title').html().split("<span")[0].trim();
  283. titleText = titleText.lgReplaceAll("/", " ").lgReplaceAll("\\", " ");
  284. $(CreateLinkContainer(links, titleText, lgSettings["RottenStyle"], lgSettings["RottenNewtab"])).insertBefore("div#series_info");
  285. $("div#lgLinkContainer").css({"padding": "8px 0 8px 0", "margin-bottom": "0", "float": "left", "width": "70%"});
  286. }
  287. } else if (UrlContains("rottentomatoes.com/celebrity/")) {
  288. links.push(["YouTube", "YouTube search for {{PARAM}} interview", "http://www.youtube.com/results?search_query={{PARAM}} interview", "youtube"]);
  289. links.push(["Google Image", "Google Image search for {{PARAM}}", "http://www.google.com/search?tbm=isch&q={{PARAM}}", "google"]);
  290. links.push(["Google", "Google search for {{PARAM}}", "http://www.google.com/search?output=search&q={{PARAM}}", "googleimage"]);
  291. links.push(["Wikipedia", "Wikipedia search for {{PARAM}}", "http://en.wikipedia.org/w/index.php?title=Special:Search&search={{PARAM}}", "wikipedia"]);
  292. links.push(["IMDb", "IMDb search for {{PARAM}}", "http://www.imdb.com/find?s=nm&q={{PARAM}}", "imdb"]);
  293. links.push(["MetaCritic", "MetaCritic search for {{PARAM}}", "http://www.metacritic.com/search/person/{{PARAM}}/results", "metacritic"]);
  294. links.push(["AllMovie", "AllMovie search for {{PARAM}}", "http://www.allmovie.com/search/people/{{PARAM}}", "allmovie"]);
  295. links.push(["Box Office Mojo", "Box Office Mojo search for {{PARAM}}", "http://www.boxofficemojo.com/search/?q={{PARAM}}", "boxofficemojo"]);
  296. links.push(["Letterboxd", "Letterboxd search for {{PARAM}}", "http://letterboxd.com/search/{{PARAM}}/", "letterboxd"]);
  297. links.push(["Imgur", "Imgur search for {{PARAM}}", "http://imgur.com/search?q={{PARAM}}", "imgur"]);
  298. var titleText = $("div.celeb_name > h1").text();
  299. $(CreateLinkContainer(links, titleText, lgSettings["RottenStyle"], lgSettings["RottenNewtab"])).appendTo("div.celeb_name");
  300. $("div.celeb_name > h1").css({"border-bottom": "none", "margin-bottom": "0", "padding-bottom": "0"});
  301. }
  302. }
  303. }
  304. // =======================================================================================================================
  305. // IMDb
  306. if (UrlContains("www.imdb.com") && window.top === window.self) {
  307. $(settingsLink).css({"color": "white"});
  308. $("<div></div>").css({"font-size": "10px", "height": "15px", "line-height": "15px", "padding-left": "3px"}).append(settingsLink).prependTo("div#nb20");
  309. $("div#navbar").css({"margin-top": "0"});
  310. if (lgSettings["ImdbEnabled"]) {
  311. if (UrlContains("/title/") && !UrlContains("/characters/")) {
  312. links.push(["YouTube", "YouTube search for {{PARAM}} tralier", "http://www.youtube.com/results?search_query={{PARAM}} trailer", "youtube"]);
  313. links.push(["Google Image", "Google Image search for {{PARAM}}", "http://www.google.com/search?tbm=isch&q={{PARAM}}", "google"]);
  314. links.push(["Google", "Google search for {{PARAM}}", "http://www.google.com/search?output=search&q={{PARAM}}", "googleimage"]);
  315. links.push(["Wikipedia", "Wikipedia search for {{PARAM}}", "http://en.wikipedia.org/w/index.php?title=Special:Search&search={{PARAM}}", "wikipedia"]);
  316. links.push(["Rotten Tomatoes", "Rotten Tomatoes search for {{PARAM}}", "http://www.rottentomatoes.com/search/?search={{PARAM}}&sitesearch=rt", "rottentomatoes"]);
  317. links.push(["MetaCritic", "MetaCritic search for {{PARAM}}", "http://www.metacritic.com/search/all/{{PARAM}}/results", "metacritic"]);
  318. links.push(["AllMovie", "AllMovie search for {{PARAM}}", "http://www.allmovie.com/search/movies/{{PARAM}}", "allmovie"]);
  319. links.push(["Box Office Mojo", "Box Office Mojo search for {{PARAM}}", "http://www.boxofficemojo.com/search/?q={{PARAM}}", "boxofficemojo"]);
  320. links.push(["Movie Mistakes", "Movie Mistakes search for {{PARAM}}", "http://www.moviemistakes.com/search.php?text={{PARAM}}", "moviemistakes"]);
  321. links.push(["Letterboxd", "Letterboxd search for {{PARAM}}", "http://letterboxd.com/search/{{PARAM}}/", "letterboxd"]);
  322. links.push(["Episode Calendar", "Episode Calendar search for {{PARAM}}", "http://episodecalendar.com/en/shows?q[name_cont]={{PARAM}}", "episodecalendar"]);
  323. links.push(["Pirate Bay", "The Pirate Bay search for {{PARAM}}", "http://thepiratebay.org/search/{{PARAM}}/0/99/200", "thepiratebay"]);
  324. links.push(["YIFY Subtitles", "YIFY Subtitles search for {PARAM}}", "http://www.yifysubtitles.com/search?q={{PARAM}}", "yifysubtitles"]);
  325. links.push(["Imgur", "Imgur search for {{PARAM}}", "http://imgur.com/search?q={{PARAM}}", "imgur"]);
  326. var titleText = $("div.title_wrapper > h1").html().split("&nbsp;<span")[0].trim();
  327. titleText = titleText.lgReplaceAll("/", " ").lgReplaceAll("\\", " ");
  328. titleText = titleText.lgReplaceAll("&nbsp;", " ").trim();
  329. $(CreateLinkContainer(links, titleText, lgSettings["ImdbStyle"], lgSettings["ImdbNewtab"])).insertAfter("div.titleBar");
  330. $("div#lgLinkContainer").css({"padding": "5px 0 0 20px"});
  331. } else if (UrlContains("/name/")) {
  332. links.push(["YouTube", "YouTube search for {{PARAM}} interview", "http://www.youtube.com/results?search_query={{PARAM}} interview", "youtube"]);
  333. links.push(["Google Image", "Google Image search for {{PARAM}}", "http://www.google.com/search?tbm=isch&q={{PARAM}}", "google"]);
  334. links.push(["Google", "Google search for {{PARAM}}", "http://www.google.com/search?output=search&q={{PARAM}}", "googleimage"]);
  335. links.push(["Wikipedia", "Wikipedia search for {{PARAM}}", "http://en.wikipedia.org/w/index.php?title=Special:Search&search={{PARAM}}", "wikipedia"]);
  336. links.push(["Rotten Tomatoes", "Rotten Tomatoes search for {{PARAM}}", "http://www.rottentomatoes.com/search/?search={{PARAM}}&sitesearch=rt", "rottentomatoes"]);
  337. links.push(["MetaCritic", "MetaCritic search for {{PARAM}}", "http://www.metacritic.com/search/person/{{PARAM}}/results", "metacritic"]);
  338. links.push(["AllMovie", "AllMovie search for {{PARAM}}", "http://www.allmovie.com/search/people/{{PARAM}}", "allmovie"]);
  339. links.push(["Box Office Mojo", "Box Office Mojo search for {{PARAM}}", "http://www.boxofficemojo.com/search/?q={{PARAM}}", "boxofficemojo"]);
  340. links.push(["Letterboxd", "Letterboxd search for {{PARAM}}", "http://letterboxd.com/search/{{PARAM}}/", "letterboxd"]);
  341. links.push(["Imgur", "Imgur search for {{PARAM}}", "http://imgur.com/search?q={{PARAM}}", "imgur"]);
  342. var titleText = $('h1.header > span.itemprop').text();
  343. $(CreateLinkContainer(links, titleText, lgSettings["ImdbStyle"], lgSettings["ImdbNewtab"])).insertAfter("div.infobar");
  344. $("div#name-job-categories").css({"margin-bottom": "4px"});
  345. }
  346. }
  347. }
  348. // =======================================================================================================================
  349. // GOOGLE
  350. if (lgSettings["GoogleEnabled"] && UrlContains("www.google.") && window.top === window.self) {
  351. PersistFunction(function () {
  352. var xs = document.URL.split("?")[1];
  353. if (xs.indexOf("#q=") !== -1) {
  354. xs = xs.split("#")[1];
  355. }
  356. xs = xs.split("q=")[1].split("&")[0].split("#")[0];
  357. $("a.q.qs").filter(function (index) {
  358. return $(this).text() === "Videos" || $(this).text() === "Video's";
  359. }).text("YouTube").attr("href", "http://www.youtube.com/results?search_query=" + xs);
  360. $("div._sxc > a._UXb._Jhd").filter(function (index) {
  361. return $(this).text() === "Videos" || $(this).text() === "Video's";
  362. }).text("YouTube").attr("href", "http://www.youtube.com/results?search_query=" + xs);
  363.  
  364. if (lgSettings["GoogleDefinition"] && $("#dictionary-modules").length && !$("div#lgLinkContainer").length) {
  365. var wordHeader = $("#dictionary-modules > div > div > div > div > div > div > span").parent();
  366. var word = $(wordHeader).text();
  367. links.push(["Wiktionary", "Wiktionary page on {{PARAM}}", "https://en.wiktionary.org/wiki/{{PARAM}}", "wiktionary"]);
  368. links.push(["Merriam-Webster", "Merriam-Webster Dictionary and Thesaurus", "http://www.merriam-webster.com/dictionary/{{PARAM}}", "merriamwebster"]);
  369. links.push(["Thesaurus.com", "Thesaurus.com", "http://thesaurus.com/browse/{{PARAM}}", "thesaurus"]);
  370. links.push(["Google", "Google search for define:{{PARAM}}", "http://www.google.com/search?output=search&q=define:{{PARAM}}", "googleimage"]);
  371. links.push(["Synonym.com", "Synonym.com", "http://www.synonym.com/synonyms/{{PARAM}}/", "synonym"]);
  372. links.push(["Wikisaurus", "Wikisaurus", "http://wiktionary.org/wiki/Wikisaurus:{{PARAM}}", "wiktionary"]);
  373. links.push(["One Look", "One Look", "http://www.onelook.com/?w={{PARAM}}&ls=a", "onelook"]);
  374. links.push(["Wolfram|Alpha", "Wolfram|Alpha", "http://www.wolframalpha.com/input/?i={{PARAM}}", "wolframalpha"]);
  375. links.push(["Urban Dictionary", "Urban Dictionary", "http://www.urbandictionary.com/define.php?term={{PARAM}}", "urbandictionary"]);
  376. links.push(["iTools", "iTools", "http://itools.com/language/dictionary?q={{PARAM}}&submit=English+Dictionary", "itools"]);
  377. links.push(["Vocabulary.com", "Vocabulary.com Dictionary", "http://www.vocabulary.com/dictionary/{{PARAM}}", "vocabulary"]);
  378. links.push(["Cambridge", "Cambridge Dictionary", "http://dictionary.cambridge.org/dictionary/english/{{PARAM}}", "cambridge"]);
  379. links.push(["RhymeZone", "RhymeZone", "http://www.rhymezone.com/r/rhyme.cgi?Word={{PARAM}}&typeofrhyme=perfect&org1=syl&org2=l&org3=y", "rhymezone"]);
  380. links.push(["Online Etymology", "Online Etymology Dictionary", "http://www.etymonline.com/index.php?search={{PARAM}}", "etymonline"]);
  381. links.push(["howjsay", "howjsay: Online Dictionary of English Pronunciation", "http://howjsay.com/index.php?word={{PARAM}}", "howjsay"]);
  382.  
  383. $(CreateLinkContainer(links, word, 0, false)).insertAfter(wordHeader);
  384. $("div#lgLinkContainer").css({"margin-bottom": "0"});
  385. }
  386.  
  387. }, 500);
  388. }
  389. // =======================================================================================================================
  390. // End Brace for document.ready function
  391. });
  392.  
  393. String.prototype.lgReplaceAll = function (f, r) {
  394. return this.split(f).join(r);
  395. };
  396.  
  397. function UrlContains(urlfragment) {
  398. return document.URL.indexOf(urlfragment) !== -1;
  399. }
  400.  
  401. function PersistFunction(functionToFire, delay) {
  402. delay = delay || 2500;
  403. new MutationObserver(function () {
  404. setTimeout(function () {
  405. functionToFire();
  406. }, delay);
  407. }).observe(document.body, {childList: true, subtree: true});
  408. }
  409.  
  410. function CreateLinkContainer(linkList, urlfragment, linkStyle, newTab) {
  411. var linkContainter = $('<div id="lgLinkContainer"></div>');
  412. for (var i = 0; i < linkList.length; i++) {
  413. var linkData = linkList[i];
  414. var linkElement = $("<a></a>")
  415. .attr("title", linkData[1].replace("{{PARAM}}", urlfragment))
  416. .attr("href", linkData[2].replace("{{PARAM}}", urlfragment));
  417. if (linkStyle !== 1) {
  418. $("<img />")
  419. .attr("src", (LITTLE_SITE_ICONS && LITTLE_SITE_ICONS[linkData[3]] ?
  420. LITTLE_SITE_ICONS[linkData[3]] : unknownIcon))
  421. .attr("alt", linkData[0])
  422. .appendTo(linkElement);
  423. }
  424. if (linkStyle !== 0) {
  425. $("<span></span>")
  426. .text(linkData[0])
  427. .appendTo(linkElement);
  428. }
  429. if (newTab) {
  430. $(linkElement).attr("target", "_blank");
  431. }
  432. $(linkContainter).append(linkElement);
  433. if (i + 1 < linkList.length) {
  434. $(linkContainter).append(document.createTextNode((linkStyle !== 1 ? " " : " | ")));
  435. }
  436. }
  437. return linkContainter;
  438. }
  439.  
  440. function SetupBoolVariable(variableIndex, defaultValue) {
  441. lgSettings[variableIndex] = GM_getValue(variableIndex, defaultValue);
  442. $("#lgSet" + variableIndex).prop("checked", lgSettings[variableIndex]).change(function () {
  443. lgSettings[variableIndex] = this.checked ? true : false;
  444. GM_setValue(variableIndex, lgSettings[variableIndex]);
  445. });
  446. }
  447.  
  448. function SetupRadioVariable(variableIndex, variableMax) {
  449. lgSettings[variableIndex] = GM_getValue(variableIndex, 0);
  450. $("input[name='lgSet" + variableIndex + "'][value='" + lgSettings[variableIndex] + "']")
  451. .prop('checked', true);
  452. $("input[name='lgSet" + variableIndex + "']").change(function () {
  453. lgSettings[variableIndex] = $(this).filter(":checked").val();
  454. GM_setValue(variableIndex, lgSettings[variableIndex]);
  455. });
  456. }