diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index da1dd0b73..a3fbdf62d 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -156,7 +156,8 @@ 'Color User IDs': [false, 'Assign unique colors to user IDs on boards that use them'], 'Remove Spoilers': [false, 'Remove all spoilers in text.'], 'Reveal Spoilers': [false, 'Indicate spoilers if Remove Spoilers is enabled, or make the text appear hovered if Remove Spoiler is disabled.'], - 'Show Support Message': [true, 'Warn if your browser is unsupported. 4chan X may not operate correctly on unsupported browser versions.'] + 'Show Support Message': [true, 'Warn if your browser is unsupported. 4chan X may not operate correctly on unsupported browser versions.'], + 'Announcement Hiding': [true, 'Enable announcements to be hidden.'] }, 'Linkification': { 'Linkify': [true, 'Convert text into links where applicable.'], @@ -14946,6 +14947,9 @@ PSAHiding = { init: function() { + if (!Conf['Announcement Hiding']) { + return; + } $.addClass(doc, 'hide-announcement'); return $.on(d, '4chanXInitFinished', this.setup); }, diff --git a/builds/crx/script.js b/builds/crx/script.js index 3c2d285b1..1e872d26c 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -131,7 +131,8 @@ 'Color User IDs': [false, 'Assign unique colors to user IDs on boards that use them'], 'Remove Spoilers': [false, 'Remove all spoilers in text.'], 'Reveal Spoilers': [false, 'Indicate spoilers if Remove Spoilers is enabled, or make the text appear hovered if Remove Spoiler is disabled.'], - 'Show Support Message': [true, 'Warn if your browser is unsupported. 4chan X may not operate correctly on unsupported browser versions.'] + 'Show Support Message': [true, 'Warn if your browser is unsupported. 4chan X may not operate correctly on unsupported browser versions.'], + 'Announcement Hiding': [true, 'Enable announcements to be hidden.'] }, 'Linkification': { 'Linkify': [true, 'Convert text into links where applicable.'], @@ -14960,6 +14961,9 @@ PSAHiding = { init: function() { + if (!Conf['Announcement Hiding']) { + return; + } $.addClass(doc, 'hide-announcement'); return $.on(d, '4chanXInitFinished', this.setup); }, diff --git a/src/General/Config.coffee b/src/General/Config.coffee index d8c4f68b6..ff7685542 100644 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -77,6 +77,10 @@ Config = true 'Warn if your browser is unsupported. 4chan X may not operate correctly on unsupported browser versions.' ] + 'Announcement Hiding': [ + true + 'Enable announcements to be hidden.' + ] 'Linkification': 'Linkify': [ diff --git a/src/Miscellaneous/AnnouncementHiding.coffee b/src/Miscellaneous/AnnouncementHiding.coffee index bce09ede3..23d86cc56 100755 --- a/src/Miscellaneous/AnnouncementHiding.coffee +++ b/src/Miscellaneous/AnnouncementHiding.coffee @@ -1,5 +1,6 @@ PSAHiding = init: -> + return unless Conf['Announcement Hiding'] $.addClass doc, 'hide-announcement' $.on d, '4chanXInitFinished', @setup @@ -34,6 +35,7 @@ PSAHiding = $.rmClass doc, 'hide-announcement' $.sync 'hiddenPSA', PSAHiding.sync + toggle: (e) -> if $.hasClass @, 'hide-announcement' UTC = +$.id('globalMessage').dataset.utc @@ -42,6 +44,7 @@ PSAHiding = $.event 'CloseMenu' $.delete 'hiddenPSA' PSAHiding.sync UTC + sync: (UTC) -> psa = $.id 'globalMessage' psa.hidden = PSAHiding.btn.hidden = if UTC and UTC >= +psa.dataset.utc