diff --git a/4chan_x.coffee b/4chan_x.coffee index d009bcebd..4c11a6edf 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -1085,7 +1085,7 @@ scroll = -> if bottom > height #post is not completely read break g.replies.shift() - document.title = document.title.replace /\d+/, g.replies.length + updateTitle() #major features if getConfig 'Image Expansion' @@ -1243,6 +1243,9 @@ if getConfig 'Keybinds' document.addEventListener 'keydown', keydown, true document.addEventListener 'keypress', keypress, true +updateTitle = -> + document.title = document.title.replace /\d+/, g.replies.length + if g.REPLY if getConfig 'Thread Updater' updaterMake() @@ -1254,6 +1257,13 @@ if g.REPLY text = $('blockquote').textContent if text d.title = "/#{g.BOARD}/ - #{text}" + if getConfig 'Unread Count' + g.replies = [] + document.title = '(0) ' + document.title + document.addEventListener 'scroll', scroll, true + g.callbacks.push (root) -> + g.replies = g.replies.concat $$ 'td.reply, td.replyhl', root + updateTitle() else #not reply if getConfig 'Thread Hiding' @@ -1317,13 +1327,5 @@ else #not reply for a in as a.addEventListener('click', expandComment, true) -if getConfig 'Unread Count' - g.replies = [] - document.title = '(0) ' + document.title - document.addEventListener 'scroll', scroll, true - g.callbacks.push (root) -> - g.replies = g.replies.concat $$ 'td.reply, td.replyhl', root - scroll() - callback() for callback in g.callbacks d.body.addEventListener('DOMNodeInserted', nodeInserted, true) diff --git a/4chan_x.js b/4chan_x.js index 1b30c79e8..8beb473aa 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1,5 +1,5 @@ (function() { - var $, $$, AEOS, DAY, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, i, id, iframe, iframeLoad, imageClick, imageExpandClick, imageFull, imageThumb, imageToggle, img, inAfter, inBefore, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, qrListener, qrText, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, request, scroll, scrollThread, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, updateAuto, updateCallback, updateInterval, updateNow, updateTime, updaterMake, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _ref, _ref2, _ref3, _ref4; + var $, $$, AEOS, DAY, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, i, id, iframe, iframeLoad, imageClick, imageExpandClick, imageFull, imageThumb, imageToggle, img, inAfter, inBefore, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, qrListener, qrText, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, request, scroll, scrollThread, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, updateAuto, updateCallback, updateInterval, updateNow, updateTime, updateTitle, updaterMake, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _ref, _ref2, _ref3, _ref4; var __slice = Array.prototype.slice, __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; @@ -1370,7 +1370,7 @@ } g.replies.shift(); } - return document.title = document.title.replace(/\d+/, g.replies.length); + return updateTitle(); }; if (getConfig('Image Expansion')) { delform = $('form[name=delform]'); @@ -1591,6 +1591,9 @@ document.addEventListener('keydown', keydown, true); document.addEventListener('keypress', keypress, true); } + updateTitle = function() { + return document.title = document.title.replace(/\d+/, g.replies.length); + }; if (g.REPLY) { if (getConfig('Thread Updater')) { updaterMake(); @@ -1607,6 +1610,15 @@ d.title = "/" + g.BOARD + "/ - " + text; } } + if (getConfig('Unread Count')) { + g.replies = []; + document.title = '(0) ' + document.title; + document.addEventListener('scroll', scroll, true); + g.callbacks.push(function(root) { + g.replies = g.replies.concat($$('td.reply, td.replyhl', root)); + return updateTitle(); + }); + } } else { if (getConfig('Thread Hiding')) { delform = $('form[name=delform]'); @@ -1684,15 +1696,6 @@ } } } - if (getConfig('Unread Count')) { - g.replies = []; - document.title = '(0) ' + document.title; - document.addEventListener('scroll', scroll, true); - g.callbacks.push(function(root) { - g.replies = g.replies.concat($$('td.reply, td.replyhl', root)); - return scroll(); - }); - } _ref4 = g.callbacks; for (_m = 0, _len6 = _ref4.length; _m < _len6; _m++) { callback = _ref4[_m];