Create CopyTextLink.coffee

This commit is contained in:
friendlyanon 2017-07-10 20:02:05 +02:00 committed by GitHub
parent 80b79320dd
commit b303ffc7ef

View File

@ -0,0 +1,25 @@
CopyTextLink =
init: ->
return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Copy Text Link']
a = $.el 'a',
className: 'copy-text-link'
href: 'javascript:;'
textContent: 'Copy Text'
$.on a, 'click', CopyTextLink.copy
Menu.menu.addEntry
el: a
open: (post) ->
CopyTextLink.text = post.nodes.commentClean.innerText
true
copy: ->
el = $.el 'textarea',
className: 'copy-text-element',
value: CopyTextLink.text
$.add d.body, el
el.select()
try
d.execCommand 'copy'
$.rm el