Skip to content

Instantly share code, notes, and snippets.

@krishnachaitanya7
Created October 6, 2016 20:52
Show Gist options
  • Save krishnachaitanya7/7b8a9cea83f926679618838af4353c68 to your computer and use it in GitHub Desktop.
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.
// ==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