From 80b79320ddbc87420831a37b58a91fe1afd8f786 Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Mon, 10 Jul 2017 20:02:00 +0200 Subject: [PATCH 1/4] Update style.css --- src/css/style.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/css/style.css b/src/css/style.css index c6ded5821..5cd1ba9db 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -1012,6 +1012,14 @@ div[data-checked="false"] > .suboption-list { left: calc(110px - .5px * var(--tn-w)); } +/* Copy Text Link's textarea element */ +textarea.copy-text-element { + height: 0; + width: 0; + position: absolute; + top: -10000px; +} + /* Announcement Hiding */ :root.hide-announcement #globalMessage { display: none; From b303ffc7eff96aca4dd9d52050e2affb73f29bd3 Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Mon, 10 Jul 2017 20:02:05 +0200 Subject: [PATCH 2/4] 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 From 33672110327e1d66c4a62e897f39dea00bdf94a7 Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Mon, 10 Jul 2017 20:05:34 +0200 Subject: [PATCH 3/4] Update Main.coffee --- src/main/Main.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/Main.coffee b/src/main/Main.coffee index 21fda05e2..bc8037d9e 100644 --- a/src/main/Main.coffee +++ b/src/main/Main.coffee @@ -461,6 +461,7 @@ Main = ['Menu', Menu] ['Index Generator (Menu)', Index.menu] ['Report Link', ReportLink] + ['Copy Text Link', CopyTextLink] ['Thread Hiding (Menu)', ThreadHiding.menu] ['Reply Hiding (Menu)', PostHiding.menu] ['Delete Link', DeleteLink] From ca7e286b9bf24a777fcf8b4cdc85c20dd4a33085 Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Mon, 10 Jul 2017 20:13:29 +0200 Subject: [PATCH 4/4] Update Config.coffee --- src/config/Config.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/config/Config.coffee b/src/config/Config.coffee index cd9332164..6e64c3eb0 100644 --- a/src/config/Config.coffee +++ b/src/config/Config.coffee @@ -307,6 +307,11 @@ Config = 'Add a report link to the menu.' 1 ] + 'Copy Text Link': [ + true + 'Add a link to copy the post\'s text.' + 1 + ] 'Thread Hiding Link': [ true 'Add a link to hide entire threads.'