From b303ffc7eff96aca4dd9d52050e2affb73f29bd3 Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Mon, 10 Jul 2017 20:02:05 +0200 Subject: [PATCH] Create CopyTextLink.coffee --- src/Menu/CopyTextLink.coffee | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/Menu/CopyTextLink.coffee diff --git a/src/Menu/CopyTextLink.coffee b/src/Menu/CopyTextLink.coffee new file mode 100644 index 000000000..a1c705f7c --- /dev/null +++ b/src/Menu/CopyTextLink.coffee @@ -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