diff --git a/4chan_x.user.js b/4chan_x.user.js index 27179305b..d4c055183 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3509,11 +3509,22 @@ Unread.replies = Unread.replies.slice(i); return Unread.update(); }, + setTitle: function(count) { + if (this.scheduled) { + clearTimeout(this.scheduled); + delete Unread.scheduled; + this.setTitle(count); + return; + } + return this.scheduled = setTimeout((function() { + return d.title = "(" + count + ") " + Unread.title; + }), 5); + }, update: function(forceUpdate) { var count; if (!g.REPLY) return; count = this.replies.length; - if (conf['Unread Count']) d.title = "(" + count + ") " + this.title; + if (conf['Unread Count']) this.setTitle(count); if (!(conf['Unread Favicon'] && (count < 2 || forceUpdate))) return; Favicon.el.href = g.dead ? count ? Favicon.unreadDead : Favicon.dead : count ? Favicon.unread : Favicon["default"]; return $.add(d.head, Favicon.el); diff --git a/script.coffee b/script.coffee index 3833522cd..46deb2075 100644 --- a/script.coffee +++ b/script.coffee @@ -2877,13 +2877,23 @@ Unread = Unread.replies = Unread.replies[i..] Unread.update() + setTitle: (count) -> + if @scheduled + clearTimeout @scheduled + delete Unread.scheduled + @setTitle count + return + @scheduled = setTimeout (-> + d.title = "(#{count}) #{Unread.title}" + ), 5 + update: (forceUpdate) -> return unless g.REPLY count = @replies.length if conf['Unread Count'] - d.title = "(#{count}) #{@title}" + @setTitle count unless conf['Unread Favicon'] and (count < 2 or forceUpdate) return