From c438ab6c3b8dc6d7bf4d084756b81d04ca1946a6 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Fri, 9 Aug 2013 01:05:10 -0700 Subject: [PATCH 1/2] Highlight posts that quote you when scrolling to them update window.location because lolwhynot --- LICENSE | 2 +- builds/4chan-X.user.js | 13 +++++++++---- builds/crx/script.js | 13 +++++++++---- src/Quotelinks/QuoteYou.coffee | 12 +++++++++--- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/LICENSE b/LICENSE index 8986054f8..b6e66b546 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.2.25 - 2013-08-08 +* 4chan X - Version 1.2.25 - 2013-08-09 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 51cb3c167..971e68444 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -19,7 +19,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.2.25 - 2013-08-08 +* 4chan X - Version 1.2.25 - 2013-08-09 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -4206,14 +4206,17 @@ if (!QuoteYou.lastRead) { if (!(post = QuoteYou.lastRead = $('.quotesYou'))) { new Notification('warning', 'No posts are currently quoting you, loser.', 20); + return; } if (QuoteYou.cb.scroll(post)) { return; } + } else { + post = QuoteYou.lastRead; } + $.rmClass($('.highlight'), 'highlight'); str = "" + type + "::div[contains(@class,'quotesYou')]"; - result = $.X(str, QuoteYou.lastRead); - while (post = result.snapshotItem(type === 'preceding' ? result.snapshotLength - 1 : 0)) { + while (post = (result = $.X(str, post)).snapshotItem(type === 'preceding' ? result.snapshotLength - 1 : 0)) { if (QuoteYou.cb.scroll(post)) { return; } @@ -4222,11 +4225,13 @@ return QuoteYou.cb.scroll(posts[type === 'following' ? 0 : posts.length - 1]); }, scroll: function(post) { - QuoteYou.lastRead = post; if (Get.postFromRoot(post).isHidden) { return false; } else { + QuoteYou.lastRead = post; + window.location = "#" + post.id; Header.scrollToPost(post); + $.addClass($('.post', post), 'highlight'); return true; } } diff --git a/builds/crx/script.js b/builds/crx/script.js index 656b8d531..8aecb2dd6 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.2.25 - 2013-08-08 +* 4chan X - Version 1.2.25 - 2013-08-09 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -4211,14 +4211,17 @@ if (!QuoteYou.lastRead) { if (!(post = QuoteYou.lastRead = $('.quotesYou'))) { new Notification('warning', 'No posts are currently quoting you, loser.', 20); + return; } if (QuoteYou.cb.scroll(post)) { return; } + } else { + post = QuoteYou.lastRead; } + $.rmClass($('.highlight'), 'highlight'); str = "" + type + "::div[contains(@class,'quotesYou')]"; - result = $.X(str, QuoteYou.lastRead); - while (post = result.snapshotItem(type === 'preceding' ? result.snapshotLength - 1 : 0)) { + while (post = (result = $.X(str, post)).snapshotItem(type === 'preceding' ? result.snapshotLength - 1 : 0)) { if (QuoteYou.cb.scroll(post)) { return; } @@ -4227,11 +4230,13 @@ return QuoteYou.cb.scroll(posts[type === 'following' ? 0 : posts.length - 1]); }, scroll: function(post) { - QuoteYou.lastRead = post; if (Get.postFromRoot(post).isHidden) { return false; } else { + QuoteYou.lastRead = post; + window.location = "#" + post.id; Header.scrollToPost(post); + $.addClass($('.post', post), 'highlight'); return true; } } diff --git a/src/Quotelinks/QuoteYou.coffee b/src/Quotelinks/QuoteYou.coffee index c8a69684c..3cf656e80 100644 --- a/src/Quotelinks/QuoteYou.coffee +++ b/src/Quotelinks/QuoteYou.coffee @@ -36,21 +36,27 @@ QuoteYou = unless QuoteYou.lastRead unless post = QuoteYou.lastRead = $ '.quotesYou' new Notification 'warning', 'No posts are currently quoting you, loser.', 20 + return return if QuoteYou.cb.scroll post + else + post = QuoteYou.lastRead + + $.rmClass $('.highlight'), 'highlight' str = "#{type}::div[contains(@class,'quotesYou')]" - result = $.X(str, QuoteYou.lastRead) - while post = result.snapshotItem(if type is 'preceding' then result.snapshotLength - 1 else 0) + while post = (result = $.X(str, post)).snapshotItem(if type is 'preceding' then result.snapshotLength - 1 else 0) return if QuoteYou.cb.scroll post posts = $$ '.quotesYou' QuoteYou.cb.scroll posts[if type is 'following' then 0 else posts.length - 1] scroll: (post) -> - QuoteYou.lastRead = post if Get.postFromRoot(post).isHidden return false else + QuoteYou.lastRead = post + window.location = "##{post.id}" Header.scrollToPost post + $.addClass $('.post', post), 'highlight' return true \ No newline at end of file From 97f7cca2b1690d41159ef9c92a521850ae1ff968 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Fri, 9 Aug 2013 01:08:39 -0700 Subject: [PATCH 2/2] Just a couple checks --- builds/4chan-X.user.js | 5 +++-- builds/crx/script.js | 5 +++-- src/Quotelinks/QuoteYou.coffee | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 971e68444..00e4422d2 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4161,7 +4161,7 @@ QuoteYou = { init: function() { - if (g.VIEW === 'catalog' || !Conf['Mark Quotes of You'] || !Conf['Quick Reply']) { + if (!(g.VIEW !== 'catalog' && Conf['Mark Quotes of You'] && Conf['Quick Reply'])) { return; } if (Conf['Highlight Own Posts']) { @@ -4203,6 +4203,8 @@ seek: function(type) { var post, posts, result, str; + return unlses(Conf['Mark Quotes of You'] && Conf['Quick Reply']); + $.rmClass($('.highlight'), 'highlight'); if (!QuoteYou.lastRead) { if (!(post = QuoteYou.lastRead = $('.quotesYou'))) { new Notification('warning', 'No posts are currently quoting you, loser.', 20); @@ -4214,7 +4216,6 @@ } else { post = QuoteYou.lastRead; } - $.rmClass($('.highlight'), 'highlight'); str = "" + type + "::div[contains(@class,'quotesYou')]"; while (post = (result = $.X(str, post)).snapshotItem(type === 'preceding' ? result.snapshotLength - 1 : 0)) { if (QuoteYou.cb.scroll(post)) { diff --git a/builds/crx/script.js b/builds/crx/script.js index 8aecb2dd6..111dc57fc 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4166,7 +4166,7 @@ QuoteYou = { init: function() { - if (g.VIEW === 'catalog' || !Conf['Mark Quotes of You'] || !Conf['Quick Reply']) { + if (!(g.VIEW !== 'catalog' && Conf['Mark Quotes of You'] && Conf['Quick Reply'])) { return; } if (Conf['Highlight Own Posts']) { @@ -4208,6 +4208,8 @@ seek: function(type) { var post, posts, result, str; + return unlses(Conf['Mark Quotes of You'] && Conf['Quick Reply']); + $.rmClass($('.highlight'), 'highlight'); if (!QuoteYou.lastRead) { if (!(post = QuoteYou.lastRead = $('.quotesYou'))) { new Notification('warning', 'No posts are currently quoting you, loser.', 20); @@ -4219,7 +4221,6 @@ } else { post = QuoteYou.lastRead; } - $.rmClass($('.highlight'), 'highlight'); str = "" + type + "::div[contains(@class,'quotesYou')]"; while (post = (result = $.X(str, post)).snapshotItem(type === 'preceding' ? result.snapshotLength - 1 : 0)) { if (QuoteYou.cb.scroll(post)) { diff --git a/src/Quotelinks/QuoteYou.coffee b/src/Quotelinks/QuoteYou.coffee index 3cf656e80..b71d37a99 100644 --- a/src/Quotelinks/QuoteYou.coffee +++ b/src/Quotelinks/QuoteYou.coffee @@ -1,6 +1,6 @@ QuoteYou = init: -> - return if g.VIEW is 'catalog' or !Conf['Mark Quotes of You'] or !Conf['Quick Reply'] + return unless g.VIEW isnt 'catalog' and Conf['Mark Quotes of You'] and Conf['Quick Reply'] if Conf['Highlight Own Posts'] $.addClass doc, 'highlight-own' @@ -33,6 +33,9 @@ QuoteYou = cb: seek: (type) -> + return unlses Conf['Mark Quotes of You'] and Conf['Quick Reply'] + $.rmClass $('.highlight'), 'highlight' + unless QuoteYou.lastRead unless post = QuoteYou.lastRead = $ '.quotesYou' new Notification 'warning', 'No posts are currently quoting you, loser.', 20 @@ -41,8 +44,6 @@ QuoteYou = else post = QuoteYou.lastRead - $.rmClass $('.highlight'), 'highlight' - str = "#{type}::div[contains(@class,'quotesYou')]" while post = (result = $.X(str, post)).snapshotItem(if type is 'preceding' then result.snapshotLength - 1 else 0)