-
-
Save rcmdnk/fa04da82a25c602c0505 to your computer and use it in GitHub Desktop.
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
jQuery(function($){ | |
$(document).on('copy', function(e) { | |
var selected = ""; | |
if (typeof window.getSelection != "undefined") { | |
var sel = window.getSelection(); | |
if (sel.rangeCount) { | |
var container = document.createElement("div"); | |
for (var i = 0, len = sel.rangeCount; i < len; ++i) { | |
container.appendChild(sel.getRangeAt(i).cloneContents()); | |
} | |
selected = container.innerHTML; | |
} | |
} else if (typeof document.selection != "undefined") { | |
if (document.selection.type == "Text") { | |
selected = document.selection.createRange().htmlText; | |
} | |
} | |
var title = document.title; | |
var url = location.href; | |
$.ajax({ | |
type: "POST", | |
url: "https://mandrillapp.com/api/1.0/messages/send.json", | |
data: { | |
'key': 'YOUR_API_KEY', | |
'message': { | |
'from_email': 'your_sender@example.com', | |
'to': [ | |
{ | |
'email': 'your_receiver@example.com', | |
'name': 'your receiver', | |
'type': 'to' | |
} | |
], | |
'subject': 'Copied at ' + title, | |
'html': '<div><a href="' + url + '">' + title + '</a></div><br><br><div>' + selected + '</div>' | |
} | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment