// ==UserScript==
// @name Link Guru
// @namespace http://greasyfork.org/users/2240-doodles
// @author Doodles
// @version 1
// @description Adds boxes full on links to a few sites.
// @include *://*.wikipedia.org/*
// @include *://www.google.*/search?*
// @include *://*.wiktionary.org/wiki/*
// @include *://www.imdb.com/*
// @include *://www.rottentomatoes.com/*
// @run-at document-end
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
// @require https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js
// @grant GM_getValue
// @grant GM_setValue
// @updateVersion 1
// @downloadURL none
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);
$(document).ready(function () {
'use strict';
// =======================================================================================================================
String.prototype.lgReplaceAll = function(f, r) {
return this.split(f).join(r);
}
function UrlContains(urlfragment) {
return document.URL.indexOf(urlfragment) != -1;
}
function SelectiveFire(functionToFire, delay){
delay = delay || 2500;
document.body.addEventListener("DOMSubtreeModified", function(){
setTimeout(function() {
functionToFire();
}, delay);
});
functionToFire();
}
function CreateLink(givenLink, urlfragment, linkStyle) {
var linkElement = $('');
$(linkElement).attr('title', givenLink[0]);
$(linkElement).attr('href', givenLink[1] + urlfragment + givenLink[2]);
if(linkStyle != 1){
$('
').attr('src', givenLink[3]).attr('alt', givenLink[0]).appendTo(linkElement);
}
if(linkStyle != 0){
$('').text(givenLink[0]).appendTo(linkElement);
}
return linkElement;
}
function CreateLinkContainer(linkList, urlfragment, linkStyle) {
var linkContainter = $('
Individual Wikipedia Settings Coming...' +
'div>
Individual Wiktionary Settings Coming...
Individual Rotten Tomatoes Settings Coming...
Individual IMDb Settings Coming...
' +
'');
$("#lgSettingsTabs").tabs();
$('#lgSettingsDialog').dialog({ modal:true, resizable: false, autoOpen: false, width: 634, position: { my: "center top", at: "center top+120", of: window } });
var settingsLink = $('
Link Guru Settings');
$(settingsLink).click(function() {$('#lgSettingsDialog').dialog('open');});
// =======================================================================================================================
// Stored Data Variables
var lgSetEnWikipedia = GM_getValue('lgEnWikipedia', true);
$("#lgSetEnableWikipedia").prop('checked', lgSetEnWikipedia).change(function() {
lgSetEnWikipedia = this.checked ? true : false;
GM_setValue('lgEnWikipedia', lgSetEnWikipedia);
});
// -------------------
var lgSetEnWiktionary = GM_getValue('lgEnWiktionary', true);
$("#lgSetEnableWiktionary").prop('checked', lgSetEnWiktionary).change(function() {
lgSetEnWiktionary = this.checked ? true : false;
GM_setValue('lgEnWiktionary', lgSetEnWiktionary);
});
// -------------------
var lgSetEnRotten = GM_getValue('lgEnRotten', true);
$("#lgSetEnableRotten").prop('checked', lgSetEnRotten).change(function() {
lgSetEnRotten = this.checked ? true : false;
GM_setValue('lgEnRotten', lgSetEnRotten);
});
// -------------------
var lgSetEnImdb = GM_getValue('lgEnImdb', true);
$("#lgSetEnableImdb").prop('checked', lgSetEnImdb).change(function() {
lgSetEnImdb = this.checked ? true : false;
GM_setValue('lgEnImdb', lgSetEnImdb);
});
// -------------------
var lgSetEnGoogle = GM_getValue('lgEnGoogle', true);
$("#lgSetEnableGoogle").prop('checked', lgSetEnGoogle).change(function() {
lgSetEnGoogle = this.checked ? true : false;
GM_setValue('lgEnGoogle', lgSetEnGoogle);
});
// =======================================================================================================================
// WIKIPEDIA
var linkStyleWiki = 0; // 0 = icon links, 1 = text links, 2 = icon and text links
var linksWiki = [];
linksWiki.push(["Google", "http://www.google.com/search?output=search&q=", "", "http://i.imgur.com/Ocn9d7X.png"]);
linksWiki.push(["Google Image", "http://www.google.com/search?tbm=isch&q=", "", "http://i.imgur.com/FFntMod.png"]);
linksWiki.push(["YouTube", "https://www.youtube.com/results?search_query=", "", "http://i.imgur.com/Oi6BUxD.png"]);
linksWiki.push(["IMDB", "http://www.imdb.com/find?s=all&q=", "", "http://i.imgur.com/At43y4m.png"]);
linksWiki.push(["Pirate Bay", "https://thepiratebay.se/search/", "/0/99/0", "http://i.imgur.com/cnc2XKT.png"]);
linksWiki.push(["Imgur", "http://imgur.com/search?q=", "", "http://i.imgur.com/bMdIHrQ.png"]);
if (UrlContains('wikipedia.org') && window.top == window.self) {
$('#p-navigation > div.body > ul').append($('
').append(settingsLink));
if (lgSetEnWikipedia && !UrlContains('/wiki/Main_Page') && !UrlContains('/wiki/Portal:') && !UrlContains('/wiki/Talk:') && $('h1#firstHeading') && $('li#ca-nstab-main.selected')) {
var pageTitle = $('h1#firstHeading').text();
pageTitle = pageTitle.lgReplaceAll("
", "").lgReplaceAll("", "");
pageTitle = pageTitle.lgReplaceAll("=", "%3D").lgReplaceAll("=", "%3D").lgReplaceAll("=", "%3D");
pageTitle = pageTitle.lgReplaceAll("&", "%26").lgReplaceAll("&", "%26").lgReplaceAll("&", "%26");
pageTitle = pageTitle.replace(" (film)","").replace("(film)","").replace(" film)",")");
$(CreateLinkContainer(linksWiki, pageTitle, linkStyleWiki)).insertBefore('h1#firstHeading');
$('div#lgLinkContainer').css({'float':'right', 'padding':'10px 0 10px 0'});
if ($('div.mw-indicators').children().length > 0) {
$('div.mw-indicators').css({'padding-left':'25px'});
}
}
}
// =======================================================================================================================
// WIKTIONARY
var linkStyleWiktionary = 0; // 0 = icon links, 1 = text links, 2 = icon and text links
var linksWiktionary = [];
linksWiktionary.push(["Merriam-Webster synonyms", "http://www.merriam-webster.com/thesaurus/", "", "http://i.imgur.com/3IkK6gI.png"]);
linksWiktionary.push(["Thesaurus.com", "http://thesaurus.com/browse/", "", "http://i.imgur.com/Ngxbqzc.png"]);
linksWiktionary.push(["Google", "http://www.google.com/search?output=search&q=define:", "", "http://i.imgur.com/Ocn9d7X.png"]);
linksWiktionary.push(["Synonym.com", "http://www.synonym.com/synonyms/", "/", "http://i.imgur.com/5zx9OP9.png"]);
linksWiktionary.push(["Wikisaurus", "http://wiktionary.org/wiki/Wikisaurus:", "", "http://i.imgur.com/2wDa3Kq.png"]);
linksWiktionary.push(["One Look", "http://www.onelook.com/?w=", "&ls=a", "http://i.imgur.com/GjvfCVA.png"]);
linksWiktionary.push(["Wolfram|Alpha", "http://www.wolframalpha.com/input/?i=", "", "http://i.imgur.com/z5p7oL7.png"]);
linksWiktionary.push(["Urban Dictionary", "http://www.urbandictionary.com/define.php?term=", "", "http://i.imgur.com/oRspJNs.png"]);
linksWiktionary.push(["iTools", "http://itools.com/language/dictionary?q=", "&submit=English+Dictionary", "http://i.imgur.com/caWzb02.png"]);
linksWiktionary.push(["Vocabulary.com", "http://www.vocabulary.com/dictionary/", "", "http://i.imgur.com/8MNsoze.png"]);
linksWiktionary.push(["Cambridge Dictionary", "http://dictionary.cambridge.org/dictionary/english/", "", "http://i.imgur.com/MtWE6Yt.png"]);
linksWiktionary.push(["RhymeZone", "http://www.rhymezone.com/r/rhyme.cgi?Word=", "&typeofrhyme=perfect&org1=syl&org2=l&org3=y", "http://i.imgur.com/d9giQh4.png"]);
linksWiktionary.push(["Online Etymology Dictionary", "http://www.etymonline.com/index.php?search=", "", "http://i.imgur.com/uUiJWbY.png"]);
if (UrlContains('wiktionary.org') && window.top == window.self) {
$('#p-navigation > div.body > ul').append($('
').append(settingsLink));
if (lgSetEnWiktionary && !UrlContains('/wiki/Wiktionary:Main_Page') && !UrlContains('/wiki/Index:') && !UrlContains('/wiki/Talk:') && !UrlContains('/wiki/Special:') &&
!UrlContains('/wiki/Category:') && $('h1#firstHeading') && $('li#ca-nstab-main.selected')) {
var pageTitle = $('h1#firstHeading').text().lgReplaceAll("
", "").lgReplaceAll("", "");
$(CreateLinkContainer(linksWiktionary, pageTitle, linkStyleWiktionary)).insertBefore('h1#firstHeading');
$('div#lgLinkContainer').css({'float':'right', 'padding':'10px 0 10px 0'});
}
}
// =======================================================================================================================
// Rotten Tomatoes
var linkStyleRotten = 0; // 0 = icon links, 1 = text links, 2 = icon and text links
var linksRotten = [];
if (UrlContains('www.rottentomatoes.com') && window.top == window.self) {
$('div.header_links').prepend(settingsLink);
if (lgSetEnRotten) {
if(UrlContains("rottentomatoes.com/m/")){
linksRotten.push(["YouTube Trailer Search", "http://www.youtube.com/results?search_query=", " trailer", "http://i.imgur.com/Oi6BUxD.png"]);
linksRotten.push(["Google Image Search", "http://www.google.com/search?tbm=isch&q=", "", "http://i.imgur.com/FFntMod.png"]);
linksRotten.push(["Google Search", "http://www.google.com/search?output=search&q=", "", "http://i.imgur.com/Ocn9d7X.png"]);
linksRotten.push(["Wikipedia", "http://en.wikipedia.org/w/index.php?title=Special:Search&search=", "", "http://i.imgur.com/8GnE9TT.png"]);
linksRotten.push(["IMDB", "http://www.imdb.com/find?s=all&q=", "", "http://i.imgur.com/At43y4m.png"]);
linksRotten.push(["MetaCritic", "http://www.metacritic.com/search/all/", "/results", "http://i.imgur.com/j84MuyF.png"]);
linksRotten.push(["AllMovie", "http://www.allmovie.com/search/movies/", "", "http://i.imgur.com/893QQhS.png"]);
linksRotten.push(["Box Office Mojo", "http://www.boxofficemojo.com/search/?q=", "", "http://i.imgur.com/GLa3QlT.png"]);
linksRotten.push(["Movie Mistakes", "http://www.moviemistakes.com/search.php?text=", "", "http://i.imgur.com/DNn1W4y.png"]);
linksRotten.push(["Letterboxd", "https://letterboxd.com/search/", "/", "http://i.imgur.com/BnJx4gH.png"]);
linksRotten.push(["Episode Calendar", "http://episodecalendar.com/en/shows?q[name_cont]=", "", "http://i.imgur.com/5IeiE6p.png"]);
linksRotten.push(["ThePirateBay", "https://thepiratebay.org/search/", "/0/99/200", "http://i.imgur.com/cnc2XKT.png"]);
linksRotten.push(["YIFY Subtitles", "http://www.yifysubtitles.com/search?q=", "", "http://i.imgur.com/VyMFcXf.png"]);
linksRotten.push(["Imgur", "http://imgur.com/search?q=", "", "http://i.imgur.com/bMdIHrQ.png"]);
var titleText = $('h1.title.hidden-xs').html().split("
h1').text();
$(CreateLinkContainer(linksRotten, titleText, linkStyleRotten)).appendTo('div.celeb_name');
$('div.celeb_name > h1').css({'border-bottom':'none', 'margin-bottom':'0', 'padding-bottom':'0'});
}
}
}
// =======================================================================================================================
// IMDb
var linkStyleImdb = 0; // 0 = icon links, 1 = text links, 2 = icon and text links
var linksImdb = [];
if (UrlContains('www.imdb.com') && window.top == window.self) {
$(settingsLink).css({'color':'white'});
$('').css({'font-size':'10px', 'height':'15px', 'line-height':'15px', 'padding-left':'3px' }).append(settingsLink).prependTo('div#nb20');
$('div#navbar').css({'margin-top':'0'});
if (lgSetEnImdb) {
if(UrlContains("/title/")){
linksImdb.push(["YouTube Trailer Search", "http://www.youtube.com/results?search_query=", " trailer", "http://i.imgur.com/Oi6BUxD.png"]);
linksImdb.push(["Google Image Search", "http://www.google.com/search?tbm=isch&q=", "", "http://i.imgur.com/FFntMod.png"]);
linksImdb.push(["Google Search", "http://www.google.com/search?output=search&q=", "", "http://i.imgur.com/Ocn9d7X.png"]);
linksImdb.push(["Wikipedia", "http://en.wikipedia.org/w/index.php?title=Special:Search&search=", "", "http://i.imgur.com/8GnE9TT.png"]);
linksImdb.push(["Rotten Tomatoes", "http://www.rottentomatoes.com/search/?search=", "&sitesearch=rt", "http://i.imgur.com/KdEB9NR.png"]);
linksImdb.push(["MetaCritic", "http://www.metacritic.com/search/all/", "/results", "http://i.imgur.com/j84MuyF.png"]);
linksImdb.push(["AllMovie", "http://www.allmovie.com/search/movies/", "", "http://i.imgur.com/893QQhS.png"]);
linksImdb.push(["Box Office Mojo", "http://www.boxofficemojo.com/search/?q=", "", "http://i.imgur.com/GLa3QlT.png"]);
linksImdb.push(["Movie Mistakes", "http://www.moviemistakes.com/search.php?text=", "", "http://i.imgur.com/DNn1W4y.png"]);
linksImdb.push(["Letterboxd", "https://letterboxd.com/search/", "/", "http://i.imgur.com/BnJx4gH.png"]);
linksImdb.push(["Episode Calendar", "http://episodecalendar.com/en/shows?q[name_cont]=", "", "http://i.imgur.com/5IeiE6p.png"]);
linksImdb.push(["ThePirateBay", "https://thepiratebay.org/search/", "/0/99/200", "http://i.imgur.com/cnc2XKT.png"]);
linksImdb.push(["YIFY Subtitles", "http://www.yifysubtitles.com/search?q=", "", "http://i.imgur.com/VyMFcXf.png"]);
linksImdb.push(["Imgur", "http://imgur.com/search?q=", "", "http://i.imgur.com/bMdIHrQ.png"]);
var titleText = $('div.title_wrapper > h1').html().split(" span.itemprop').text();
$(CreateLinkContainer(linksImdb, titleText, linkStyleImdb)).insertAfter('div.infobar');
$('div#name-job-categories').css({'margin-bottom':'4px'});
}else if(UrlContains("/character/")){
linksImdb.push(["YouTube", "http://www.youtube.com/results?search_query=", "", "http://i.imgur.com/Oi6BUxD.png"]);
linksImdb.push(["Google Image Search", "http://www.google.com/search?tbm=isch&q=", "", "http://i.imgur.com/FFntMod.png"]);
linksImdb.push(["Google Search", "http://www.google.com/search?output=search&q=", "", "http://i.imgur.com/Ocn9d7X.png"]);
linksImdb.push(["Wikipedia", "http://en.wikipedia.org/w/index.php?title=Special:Search&search=", "", "http://i.imgur.com/8GnE9TT.png"]);
linksImdb.push(["Rotten Tomatoes", "http://www.rottentomatoes.com/search/?search=", "&sitesearch=rt", "http://i.imgur.com/KdEB9NR.png"]);
linksImdb.push(["MetaCritic", "http://www.metacritic.com/search/all/", "/results", "http://i.imgur.com/j84MuyF.png"]);
linksImdb.push(["AllMovie", "http://www.allmovie.com/search/all/", "", "http://i.imgur.com/893QQhS.png"]);
linksImdb.push(["Box Office Mojo", "http://www.boxofficemojo.com/search/?q=", "", "http://i.imgur.com/GLa3QlT.png"]);
linksImdb.push(["Imgur", "http://imgur.com/search?q=", "", "http://i.imgur.com/bMdIHrQ.png"]);
var titleText = document.getElementById("tn15title").getElementsByTagName("h1")[0].innerHTML.split("")[0].trim();
$(CreateLinkContainer(linksImdb, titleText, linkStyleImdb)).insertBefore('div#tn15title');
$('div#lgLinkContainer').css({'float':'right'});
}
}
}
// =======================================================================================================================
// GOOGLE
if (lgSetEnGoogle && UrlContains('www.google.') && window.top == window.self) {
SelectiveFire(function(){
var xs = document.URL.split('?')[1];
if(xs.indexOf('#q=') != -1){
xs = xs.split('#')[1];
}
xs = xs.split('q=')[1].split('&')[0].split('#')[0];
$('a.q.qs').filter(function(index) {
return $(this).text() == 'Videos' || $(this).text() == 'Video\'s';
}).text('YouTube').attr('href', 'http://www.youtube.com/results?search_query=' + xs);
}, 500);
}
// =======================================================================================================================
// End Brace for document.ready function
});