From 1272da97e5eb79508e53c33694c2eeeab350f311 Mon Sep 17 00:00:00 2001 From: discomrade Date: Sat, 15 Jan 2022 03:09:10 -0100 Subject: [PATCH] Allow users to disable and clear (You)s Credit to based anon https://leftypol.org/tech/res/6724.html#12776 --- js/show-own-posts.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/js/show-own-posts.js b/js/show-own-posts.js index e26f5abd..1402a606 100644 --- a/js/show-own-posts.js +++ b/js/show-own-posts.js @@ -17,6 +17,28 @@ +function(){ +if (typeof localStorage.own_posts_tracking === 'undefined') { + localStorage.own_posts_tracking = 'true'; // set default +} + +const addgui = function () { + if (!(window.Options && Options.get_tab ('general'))) { return; } + const prefix = "showownposts_"; + const gui = '
(You)s' + + '' + + ' ' + + '
'; + Options.extend_tab ("general", gui); + const cb = Options.get_tab ('general').content.find ('#' + prefix + 'track'); + cb.prop ('checked', localStorage.own_posts_tracking === 'true'); + cb.on ("change", function (ev) { + const cb = ev.target; + localStorage.own_posts_tracking = cb.checked ? 'true' : 'false'; + }); + Options.get_tab ('general').content.find ('#' + prefix + 'clear').on ("click", function () { + localStorage.own_posts = '{}'; + }); +} var update_own = function() { if ($(this).is('.you')) return; @@ -61,9 +83,11 @@ $(function() { board = $('input[name="board"]').first().val(); update_all(); + addgui(); }); $(document).on('ajax_after_post', function(e, r) { + if (localStorage.own_posts_tracking !== 'true') { return; } var posts = JSON.parse(localStorage.own_posts || '{}'); posts[board] = posts[board] || []; posts[board].push(r.id);