From 6495f70581aef8410753969908833b0b569a57a5 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 21 Feb 2014 17:45:39 +0100 Subject: [PATCH 01/30] Quoting now also includes the spoiler and code tags. --- src/Posting/QR.coffee | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 8b1fe1ba8..ce9903c04 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -213,12 +213,28 @@ QR = e?.preventDefault() return unless QR.postingIsEnabled - sel = d.getSelection() - post = Get.postFromNode @ - text = ">>#{post}\n" - if (s = sel.toString().trim()) and post is Get.postFromNode sel.anchorNode - s = s.replace /\n/g, '\n>' - text += ">#{s}\n" + sel = d.getSelection() + post = Get.postFromNode @ + text = ">>#{post}\n" + if sel.toString().trim() and post is Get.postFromNode sel.anchorNode + range = sel.getRangeAt() + frag = range.cloneContents() + ancestor = range.commonAncestorContainer + if ancestor.nodeName is '#text' + # Quoting the insides of a spoiler/code tag. + if $.x 'ancestor::s', ancestor + $.prepend frag, $.tn '[spoiler]' + $.add frag, $.tn '[/spoiler]' + if $.x 'ancestor::pre[contains(@class,"prettyprint")]', ancestor + $.prepend frag, $.tn '[code]' + $.add frag, $.tn '[/code]' + for node in $$ 'br', frag + $.replace node, $.tn '\n>' + for node in $$ 's', frag + $.replace node, [$.tn('[spoiler]'), node.childNodes..., $.tn '[/spoiler]'] + for node in $$ '.prettyprint', frag + $.replace node, [$.tn('[code]'), node.childNodes..., $.tn '[/code]'] + text += ">#{frag.textContent.trim()}\n" QR.open() if QR.selected.isLocked From b10be8b87504a870a8c82f49828a53cdb2b8ce0f Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 22 Feb 2014 00:17:22 +0100 Subject: [PATCH 02/30] Fix quoting on Firefox. --- src/Posting/QR.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index ce9903c04..f86da7bba 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -217,7 +217,7 @@ QR = post = Get.postFromNode @ text = ">>#{post}\n" if sel.toString().trim() and post is Get.postFromNode sel.anchorNode - range = sel.getRangeAt() + range = sel.getRangeAt 0 frag = range.cloneContents() ancestor = range.commonAncestorContainer if ancestor.nodeName is '#text' From f337dcb0ca8538528bcade0679534e2a31f02a6d Mon Sep 17 00:00:00 2001 From: Mayhem Date: Thu, 10 Apr 2014 15:33:50 +0200 Subject: [PATCH 03/30] Don't leave an extra `>` when quoting. --- src/Posting/QR.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index f86da7bba..3df257a76 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -229,7 +229,7 @@ QR = $.prepend frag, $.tn '[code]' $.add frag, $.tn '[/code]' for node in $$ 'br', frag - $.replace node, $.tn '\n>' + $.replace node, $.tn '\n>' unless node is frag.lastElementChild for node in $$ 's', frag $.replace node, [$.tn('[spoiler]'), node.childNodes..., $.tn '[/spoiler]'] for node in $$ '.prettyprint', frag From bb1fcadfa2beebc4bf65d49d2d8c4db3d26cb1a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Grabovsk=C3=BD?= Date: Sat, 26 Apr 2014 21:01:13 +0200 Subject: [PATCH 04/30] Fix handling
s when quoting selection in QR The previous code caused, among others, merging of two-line selections into one line. --- src/Posting/QR.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 3df257a76..b1885a186 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -229,7 +229,7 @@ QR = $.prepend frag, $.tn '[code]' $.add frag, $.tn '[/code]' for node in $$ 'br', frag - $.replace node, $.tn '\n>' unless node is frag.lastElementChild + $.replace node, $.tn '\n>' unless node is frag.lastChild for node in $$ 's', frag $.replace node, [$.tn('[spoiler]'), node.childNodes..., $.tn '[/spoiler]'] for node in $$ '.prettyprint', frag From 7b348a00c60c60883be408ca3ba347f6cdf51ad2 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 6 Dec 2014 01:06:31 -0800 Subject: [PATCH 05/30] Fix Remove Spoilers stripping tags. --- src/General/css/style.css | 6 ++++++ src/Miscellaneous/RemoveSpoilers.coffee | 13 ++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/General/css/style.css b/src/General/css/style.css index 2ee7d0739..9801e788e 100755 --- a/src/General/css/style.css +++ b/src/General/css/style.css @@ -918,6 +918,12 @@ span.hide-announcement { :root.reveal-spoilers s > a { color: white !important; } +:root.reveal-spoilers .removed-spoiler::before { + content: "[spoiler]"; +} +:root.reveal-spoilers .removed-spoiler::after { + content: "[/spoiler]"; +} /* Thread & Reply Hiding */ .hide-thread-button, diff --git a/src/Miscellaneous/RemoveSpoilers.coffee b/src/Miscellaneous/RemoveSpoilers.coffee index f3e0e6cd2..53c1ea0d3 100755 --- a/src/Miscellaneous/RemoveSpoilers.coffee +++ b/src/Miscellaneous/RemoveSpoilers.coffee @@ -1,14 +1,10 @@ RemoveSpoilers = init: -> - if Conf['Reveal Spoilers'] and !Conf['Remove Spoilers'] + if Conf['Reveal Spoilers'] $.addClass doc, 'reveal-spoilers' return unless Conf['Remove Spoilers'] - if Conf['Reveal Spoilers'] - @wrapper = (text) -> - "[spoiler]#{text}[/spoiler]" - Post.callbacks.push name: 'Reveal Spoilers' cb: @node @@ -16,11 +12,10 @@ RemoveSpoilers = name: 'Reveal Spoilers' cb: @node - wrapper: (text) -> - text - node: (post) -> spoilers = $$ 's', @nodes.comment for spoiler in spoilers - $.replace spoiler, $.tn RemoveSpoilers.wrapper spoiler.textContent + span = $.el 'span', className: 'removed-spoiler' + $.replace spoiler, span + $.add span, [spoiler.childNodes...] return From ac4083b9f45993e4740b56313cc27e3987caf48d Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 6 Dec 2014 01:28:57 -0800 Subject: [PATCH 06/30] Fix quoting inside of spoiler/code tag when common ancestor is not text node. --- src/Posting/QR.coffee | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index b1885a186..d86453b18 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -220,14 +220,13 @@ QR = range = sel.getRangeAt 0 frag = range.cloneContents() ancestor = range.commonAncestorContainer - if ancestor.nodeName is '#text' - # Quoting the insides of a spoiler/code tag. - if $.x 'ancestor::s', ancestor - $.prepend frag, $.tn '[spoiler]' - $.add frag, $.tn '[/spoiler]' - if $.x 'ancestor::pre[contains(@class,"prettyprint")]', ancestor - $.prepend frag, $.tn '[code]' - $.add frag, $.tn '[/code]' + # Quoting the insides of a spoiler/code tag. + if $.x 'ancestor-or-self::s', ancestor + $.prepend frag, $.tn '[spoiler]' + $.add frag, $.tn '[/spoiler]' + if $.x 'ancestor-or-self::pre[contains(@class,"prettyprint")]', ancestor + $.prepend frag, $.tn '[code]' + $.add frag, $.tn '[/code]' for node in $$ 'br', frag $.replace node, $.tn '\n>' unless node is frag.lastChild for node in $$ 's', frag From 666276dd34671e96a9cc684f48e8a8ebb4a77259 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 6 Dec 2014 02:14:30 -0800 Subject: [PATCH 07/30] Make [spoiler] quoting compatible with Remove Spoilers. --- src/Posting/QR.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index d86453b18..c63f6d0aa 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -221,7 +221,7 @@ QR = frag = range.cloneContents() ancestor = range.commonAncestorContainer # Quoting the insides of a spoiler/code tag. - if $.x 'ancestor-or-self::s', ancestor + if $.x 'ancestor-or-self::*[self::s or contains(@class,"removed-spoiler")]', ancestor $.prepend frag, $.tn '[spoiler]' $.add frag, $.tn '[/spoiler]' if $.x 'ancestor-or-self::pre[contains(@class,"prettyprint")]', ancestor @@ -229,7 +229,7 @@ QR = $.add frag, $.tn '[/code]' for node in $$ 'br', frag $.replace node, $.tn '\n>' unless node is frag.lastChild - for node in $$ 's', frag + for node in $$ 's, .removed-spoiler', frag $.replace node, [$.tn('[spoiler]'), node.childNodes..., $.tn '[/spoiler]'] for node in $$ '.prettyprint', frag $.replace node, [$.tn('[code]'), node.childNodes..., $.tn '[/code]'] From 84211ce91e0c003da39db2bea02c6a4a3eae8cec Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 6 Dec 2014 02:35:02 -0800 Subject: [PATCH 08/30] Remove (embed) links from quotes. --- src/Posting/QR.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index c63f6d0aa..f5155e343 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -233,6 +233,9 @@ QR = $.replace node, [$.tn('[spoiler]'), node.childNodes..., $.tn '[/spoiler]'] for node in $$ '.prettyprint', frag $.replace node, [$.tn('[code]'), node.childNodes..., $.tn '[/code]'] + for node in $$ '.embedder', frag + $.rm node.previousSibling if node.previousSibling?.nodeValue is ' ' + $.rm node text += ">#{frag.textContent.trim()}\n" QR.open() From 5bc9da2a6cc43a36f6ef96db17186be338b798bd Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 6 Dec 2014 12:50:22 -0800 Subject: [PATCH 09/30] README.md: Uninstalling and native extension. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3d9b19726..8e4a0f926 100755 --- a/README.md +++ b/README.md @@ -39,6 +39,9 @@ If you want to install the current beta version but get updates from the stable ## Security note 4chan X currently shares your settings and post history between the HTTP and HTTPS versions of 4chan. If you are concerned about protecting your privacy against a man-in-the-middle attack, you should disable 4chan X on the HTTP version of 4chan and/or install [HTTPS Everywhere](https://www.eff.org/https-everywhere). +## Uninstalling +4chan X disables the native extension, so if you uninstall 4chan X, you'll need to re-enable it. To do this, click the `[Settings]` link in the top right corner and uncheck "`Disable the native extension`" in the panel that appears. + ## More information - [Source Code](https://github.com/ccd0/4chan-x) - [Changelog](https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md) From b48bdfbbbeb29c263708884b5b0e806a25a43ac9 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 6 Dec 2014 12:50:35 -0800 Subject: [PATCH 10/30] Build web page. --- index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.html b/index.html index 3ab6a33c2..aaac835ae 100644 --- a/index.html +++ b/index.html @@ -47,6 +47,8 @@ Only the latest stable version of 4chan X is available.

If you want to install the current beta version but get updates from the stable channel after that, install it from here for Firefox or here for Chromium.

Security note

4chan X currently shares your settings and post history between the HTTP and HTTPS versions of 4chan. If you are concerned about protecting your privacy against a man-in-the-middle attack, you should disable 4chan X on the HTTP version of 4chan and/or install HTTPS Everywhere.

+

Uninstalling

+

4chan X disables the native extension, so if you uninstall 4chan X, you'll need to re-enable it. To do this, click the [Settings] link in the top right corner and uncheck "Disable the native extension" in the panel that appears.

More information