From 0c22569dd83c423d79c6f3bd4d2d88ab53279037 Mon Sep 17 00:00:00 2001 From: wholelotofhs Date: Tue, 6 Jan 2015 23:26:58 -0500 Subject: [PATCH 1/3] added a way to hide posts highjacks localStorage.hiddenthreads to save which posts are hidden; I don't want to rename the file in fear it will break. --- js/hide-threads.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/js/hide-threads.js b/js/hide-threads.js index 175018ed..4b26859d 100644 --- a/js/hide-threads.js +++ b/js/hide-threads.js @@ -78,10 +78,40 @@ $(document).ready(function(){ if (hidden_data[board][id]) thread_container.find('.hide-thread-link').click(); } + var do_hide_posts = function(){ + var post = $(this) + var id = post.children('p.intro').children('a.post_no:eq(1)').text(); + var board = post.parent().data('board'); + + $(' [–]') + .insertAfter($(this).children('p.intro').children('a.post_no')) + .click(function() { + hidden_data[board][id] = Math.round(Date.now() / 1000); + store_data(); + var hide_link = $(this) + post.children('div').hide() + hide_link.hide() + $(' [+]') + .insertAfter($(this).children('p.intro').children('a.post_no')) + .click(function() { + delete hidden_data[board][id]; + store_data(); + post.children('div').show(); + $(this).remove(); + hide_link.show() + }); + }) + if (hidden_data[board][id]) + post.find('.post-hide-link').click(); + } $('div.post.op').each(do_hide_threads); + $('div.post.reply').each(do_hide_posts); $(document).on('new_post', function(e, post) { do_hide_threads.call($(post).find('div.post.op')[0]); + if($(post).is('div.post.reply')) { + $(post).each(do_hide_posts); + } }); }); From 564862f3322c0e010741848bdf1b113563ed8fcd Mon Sep 17 00:00:00 2001 From: wholelotofhs Date: Tue, 6 Jan 2015 23:32:47 -0500 Subject: [PATCH 2/3] removed useless tabs --- js/hide-threads.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/hide-threads.js b/js/hide-threads.js index 4b26859d..55d29f10 100644 --- a/js/hide-threads.js +++ b/js/hide-threads.js @@ -83,7 +83,7 @@ $(document).ready(function(){ var id = post.children('p.intro').children('a.post_no:eq(1)').text(); var board = post.parent().data('board'); - $(' [–]') + $('[–]') .insertAfter($(this).children('p.intro').children('a.post_no')) .click(function() { hidden_data[board][id] = Math.round(Date.now() / 1000); @@ -91,7 +91,7 @@ $(document).ready(function(){ var hide_link = $(this) post.children('div').hide() hide_link.hide() - $(' [+]') + $('[+]') .insertAfter($(this).children('p.intro').children('a.post_no')) .click(function() { delete hidden_data[board][id]; From 79b6e6c72ff4d18352bf1844dbd3526b5f89f802 Mon Sep 17 00:00:00 2001 From: wholelotofhs Date: Wed, 7 Jan 2015 00:01:24 -0500 Subject: [PATCH 3/3] forgot ':last' --- js/hide-threads.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/js/hide-threads.js b/js/hide-threads.js index 55d29f10..783b7bec 100644 --- a/js/hide-threads.js +++ b/js/hide-threads.js @@ -84,23 +84,24 @@ $(document).ready(function(){ var board = post.parent().data('board'); $('[–]') - .insertAfter($(this).children('p.intro').children('a.post_no')) + .insertAfter($(this).children('p.intro').children('a.post_no:last')) .click(function() { hidden_data[board][id] = Math.round(Date.now() / 1000); store_data(); - var hide_link = $(this) - post.children('div').hide() - hide_link.hide() + var hide_link = $(this); + post.children('div').hide(); + hide_link.hide(); $('[+]') - .insertAfter($(this).children('p.intro').children('a.post_no')) + .insertAfter($(this).children('p.intro').children('a.post_no:last')) .click(function() { delete hidden_data[board][id]; store_data(); post.children('div').show(); + hide_link.show(); $(this).remove(); - hide_link.show() + }); - }) + }); if (hidden_data[board][id]) post.find('.post-hide-link').click(); } @@ -112,6 +113,6 @@ $(document).ready(function(){ do_hide_threads.call($(post).find('div.post.op')[0]); if($(post).is('div.post.reply')) { $(post).each(do_hide_posts); - } + }; }); });