Last active
October 10, 2016 06:33
-
-
Save krishnachaitanya7/e68f74256da8bbc59f5dd391e5d38398 to your computer and use it in GitHub Desktop.
This Gist can be used to search for words selected in a website and search them in your favorite word meaning search engines like dictionary.com specified here. This is a tampermonkey script, in @match specify websites in which you want to search and also allow pop-ups on that website. credits: http://mark.koli.ch/use-javascript-and-jquery-to-ge…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Select_Search | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description To Search for a word in your favourite word search engines. | |
// @author You | |
// @match https://quizlet.com/* | |
// @grant GM_setClipboard | |
// ==/UserScript== | |
(function() { | |
if(!window.Kolich){ | |
Kolich = {}; | |
} | |
Kolich.Selector = {}; | |
Kolich.Selector.getSelected = function(){ | |
var t = ''; | |
if(window.getSelection){ | |
t = window.getSelection(); | |
} | |
else if(document.getSelection){ | |
t = document.getSelection(); | |
} | |
else if(document.selection){ | |
t = document.selection.createRange().text; | |
} | |
return t; | |
}; | |
Kolich.Selector.mouseup = function(){ | |
var st = Kolich.Selector.getSelected(); | |
if(String(st).split(' ').length==1 && st!=''){ | |
window.open("http://www.dictionary.com/browse/"+st+"?s=ts"); | |
window.open("http://www.mnemonicdictionary.com/?word="+st,'_blank'); | |
GM_setClipboard (String(st)); | |
} | |
}; | |
$(document).ready(function(){ | |
$(document).bind("mouseup", Kolich.Selector.mouseup); | |
}); | |
// Experimental Code | |
$(document).bind("paste",function(){ | |
GM_setClipboard (''); | |
}); | |
// Experimental Code | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment