diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e1bba0b3..56c10344b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +- The button to show a hidden announcement is now inside the header's menu. - Added the `board-replace` setting to Custom Board Navigation ricing. - Added the option `Cooldown Prediction`, enabled by default. - Added the option `Hide Unread Count at (0)`, disabled by default. diff --git a/src/features.coffee b/src/features.coffee index 5ef541518..7a19b85a8 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -790,6 +790,20 @@ PSAHiding = $.addClass doc, 'hide-announcement' + entry = + type: 'header' + el: $.el 'a', + textContent: 'Show announcement.' + className: 'show-announcement' + href: 'javascript:;' + order: 50 + open: -> + if $.id('globalMessage')?.hidden + return true + false + $.event 'AddMenuEntry', entry + + $.on entry.el, 'click', PSAHiding.toggle $.on d, '4chanXInitFinished', @setup setup: -> $.off d, '4chanXInitFinished', PSAHiding.setup @@ -799,12 +813,12 @@ PSAHiding = return PSAHiding.btn = btn = $.el 'a', - title: 'Toggle announcement.' - innerHTML: '' + innerHTML: '[ - ]' + title: 'Hide announcement.' + className: 'hide-announcement' href: 'javascript:;' $.on btn, 'click', PSAHiding.toggle - text = PSAHiding.trim psa $.get 'hiddenPSAs', [], (item) -> PSAHiding.sync item['hiddenPSAs'] $.before psa, btn @@ -817,19 +831,19 @@ PSAHiding = $.get 'hiddenPSAs', [], ({hiddenPSAs}) -> if hide hiddenPSAs.push text + hiddenPSAs = hiddenPSAs[-5..] else + $.event 'CloseMenu' i = hiddenPSAs.indexOf text hiddenPSAs.splice i, 1 - hiddenPSAs = hiddenPSAs[-5..] PSAHiding.sync hiddenPSAs $.set 'hiddenPSAs', hiddenPSAs sync: (hiddenPSAs) -> - {btn} = PSAHiding - psa = $.id 'globalMessage' - [psa.hidden, btn.firstChild.textContent, btn.className] = if PSAHiding.trim(psa) in hiddenPSAs - [true, '[\u00A0+\u00A0]', 'show-announcement'] + psa = $.id 'globalMessage' + psa.hidden = PSAHiding.btn.hidden = if PSAHiding.trim(psa) in hiddenPSAs + true else - [false, '[\u00A0-\u00A0]', 'hide-announcement'] + false trim: (psa) -> psa.textContent.replace(/\W+/g, '').toLowerCase()