Created
October 6, 2016 20:52
-
-
Save krishnachaitanya7/7b8a9cea83f926679618838af4353c68 to your computer and use it in GitHub Desktop.
Copy sentences from a website (website should be specified in @match). just select the sentence and its copied.
This file contains hidden or 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 Dictionary.com Copy Sentences | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match http://www.dictionary.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(st!=''){ | |
console.log(String(st)); | |
GM_setClipboard (String(st)); | |
} | |
}; | |
$(document).ready(function(){ | |
$(document).bind("mouseup", Kolich.Selector.mouseup); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment