Create CopyTextLink.coffee
This commit is contained in:
parent
80b79320dd
commit
b303ffc7ef
25
src/Menu/CopyTextLink.coffee
Normal file
25
src/Menu/CopyTextLink.coffee
Normal 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
|
||||||
Loading…
x
Reference in New Issue
Block a user