diff --git a/CHANGELOG.md b/CHANGELOG.md index 7165c02a3..d38a8cd67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ seaweedchan: - Fix emoji and favicon previews not updating on change. +MayhemYDG: +- Fix bug where a thread would freeze on load. + ### 1.1.1 - 2013-04-26 zixaphir: - Fix script on Opera @@ -80,4 +83,4 @@ zixaphir: - Fix unread post count for filtered posts - Fix issues when switching from ihavenoface's fork - Fix backlinks not receiving filtered class -- Fix QR position not saving on refresh \ No newline at end of file +- Fix QR position not saving on refresh diff --git a/builds/4chan-X.js b/builds/4chan-X.js index 4f7cda08d..cc36717b5 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -188,7 +188,7 @@ 'Remember Subject': [false, 'Remember the subject field, instead of resetting after posting.'], 'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.'], 'Hide Original Post Form': [true, 'Hide the normal post form.'], - 'Cooldown': [true, 'Prevent "flood detected" errors.'], + 'Cooldown': [true, 'Indicate the remaining time before posting again.'], 'Cooldown Prediction': [true, 'Decrease the cooldown time by taking into account upload speed. Disable it if it\'s inaccurate for you.'] }, 'Quote Links': { @@ -4305,7 +4305,7 @@ psa = $.id('globalMessage'); psa.hidden = PSAHiding.btn.hidden = (_ref = PSAHiding.trim(psa), __indexOf.call(hiddenPSAs, _ref) >= 0) ? true : false; - if (hr = $.x('following-sibling::hr', psa)) { + if ((hr = psa.nextElementSibling) && hr.nodeName === 'HR') { return hr.hidden = psa.hidden; } }, @@ -6758,24 +6758,14 @@ }); }, node: function() { - var ID, post, posts, _ref; - Unread.thread = this; Unread.title = d.title; - posts = []; - _ref = this.posts; - for (ID in _ref) { - post = _ref[ID]; - if (post.isReply) { - posts.push(post); - } - } Unread.lastReadPost = Unread.db.get({ boardID: this.board.ID, threadID: this.ID, defaultValue: 0 }); - Unread.addPosts(posts); + $.on(d, '4chanXInitFinished', Unread.ready); $.on(d, 'ThreadUpdate', Unread.onUpdate); $.on(d, 'scroll visibilitychange', Unread.read); if (Conf['Unread Line']) { @@ -6785,15 +6775,35 @@ return $.on(window, 'load', Unread.scroll); } }, + ready: function() { + var ID, post, posts, _ref; + + $.off(d, '4chanXInitFinished', Unread.ready); + posts = []; + _ref = Unread.thread.posts; + for (ID in _ref) { + post = _ref[ID]; + if (post.isReply) { + posts.push(post); + } + } + return Unread.addPosts(posts); + }, scroll: function() { - var hash, posts, root; + var hash, post, posts, prevID, root; if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) { return; } if (Unread.posts.length) { + prevID = 0; while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { - if (!(Get.postFromRoot(root)).isHidden) { + post = Get.postFromRoot(root); + if (prevID === post.ID) { + break; + } + prevID = post.ID; + if (!post.isHidden) { break; } } @@ -9389,7 +9399,7 @@ Settings[key].call(input); } }); - $.on($('input[name=Interval]', section), 'input', ThreadUpdater.cb.interval); + $.on($('input[name=Interval]', section), 'change', ThreadUpdater.cb.interval); $.on($('input[name="Custom CSS"]', section), 'change', Settings.togglecss); return $.on($.id('apply-css'), 'click', Settings.usercss); }, diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index ae889f517..39bdef7a7 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -189,7 +189,7 @@ 'Remember QR Size': [false, 'Remember the size of the Quick reply.'], 'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.'], 'Hide Original Post Form': [true, 'Hide the normal post form.'], - 'Cooldown': [true, 'Prevent "flood detected" errors.'], + 'Cooldown': [true, 'Indicate the remaining time before posting again.'], 'Cooldown Prediction': [true, 'Decrease the cooldown time by taking into account upload speed. Disable it if it\'s inaccurate for you.'] }, 'Quote Links': { @@ -4301,7 +4301,7 @@ psa = $.id('globalMessage'); psa.hidden = PSAHiding.btn.hidden = (_ref = PSAHiding.trim(psa), __indexOf.call(hiddenPSAs, _ref) >= 0) ? true : false; - if (hr = $.x('following-sibling::hr', psa)) { + if ((hr = psa.nextElementSibling) && hr.nodeName === 'HR') { return hr.hidden = psa.hidden; } }, @@ -6754,24 +6754,14 @@ }); }, node: function() { - var ID, post, posts, _ref; - Unread.thread = this; Unread.title = d.title; - posts = []; - _ref = this.posts; - for (ID in _ref) { - post = _ref[ID]; - if (post.isReply) { - posts.push(post); - } - } Unread.lastReadPost = Unread.db.get({ boardID: this.board.ID, threadID: this.ID, defaultValue: 0 }); - Unread.addPosts(posts); + $.on(d, '4chanXInitFinished', Unread.ready); $.on(d, 'ThreadUpdate', Unread.onUpdate); $.on(d, 'scroll visibilitychange', Unread.read); if (Conf['Unread Line']) { @@ -6781,15 +6771,35 @@ return $.on(window, 'load', Unread.scroll); } }, + ready: function() { + var ID, post, posts, _ref; + + $.off(d, '4chanXInitFinished', Unread.ready); + posts = []; + _ref = Unread.thread.posts; + for (ID in _ref) { + post = _ref[ID]; + if (post.isReply) { + posts.push(post); + } + } + return Unread.addPosts(posts); + }, scroll: function() { - var hash, posts, root; + var hash, post, posts, prevID, root; if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) { return; } if (Unread.posts.length) { + prevID = 0; while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { - if (!(Get.postFromRoot(root)).isHidden) { + post = Get.postFromRoot(root); + if (prevID === post.ID) { + break; + } + prevID = post.ID; + if (!post.isHidden) { break; } } @@ -9412,7 +9422,7 @@ Settings[key].call(input); } }); - $.on($('input[name=Interval]', section), 'input', ThreadUpdater.cb.interval); + $.on($('input[name=Interval]', section), 'change', ThreadUpdater.cb.interval); $.on($('input[name="Custom CSS"]', section), 'change', Settings.togglecss); return $.on($.id('apply-css'), 'click', Settings.usercss); }, diff --git a/builds/crx/script.js b/builds/crx/script.js index 2aee518ff..bad35abf9 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -81,7 +81,7 @@ 'Remember Subject': [false, 'Remember the subject field, instead of resetting after posting.'], 'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.'], 'Hide Original Post Form': [true, 'Hide the normal post form.'], - 'Cooldown': [true, 'Prevent "flood detected" errors.'], + 'Cooldown': [true, 'Indicate the remaining time before posting again.'], 'Cooldown Prediction': [true, 'Decrease the cooldown time by taking into account upload speed. Disable it if it\'s inaccurate for you.'] }, 'Quote Links': { @@ -4214,7 +4214,7 @@ psa = $.id('globalMessage'); psa.hidden = PSAHiding.btn.hidden = (_ref = PSAHiding.trim(psa), __indexOf.call(hiddenPSAs, _ref) >= 0) ? true : false; - if (hr = $.x('following-sibling::hr', psa)) { + if ((hr = psa.nextElementSibling) && hr.nodeName === 'HR') { return hr.hidden = psa.hidden; } }, @@ -6667,24 +6667,14 @@ }); }, node: function() { - var ID, post, posts, _ref; - Unread.thread = this; Unread.title = d.title; - posts = []; - _ref = this.posts; - for (ID in _ref) { - post = _ref[ID]; - if (post.isReply) { - posts.push(post); - } - } Unread.lastReadPost = Unread.db.get({ boardID: this.board.ID, threadID: this.ID, defaultValue: 0 }); - Unread.addPosts(posts); + $.on(d, '4chanXInitFinished', Unread.ready); $.on(d, 'ThreadUpdate', Unread.onUpdate); $.on(d, 'scroll visibilitychange', Unread.read); if (Conf['Unread Line']) { @@ -6694,15 +6684,35 @@ return $.on(window, 'load', Unread.scroll); } }, + ready: function() { + var ID, post, posts, _ref; + + $.off(d, '4chanXInitFinished', Unread.ready); + posts = []; + _ref = Unread.thread.posts; + for (ID in _ref) { + post = _ref[ID]; + if (post.isReply) { + posts.push(post); + } + } + return Unread.addPosts(posts); + }, scroll: function() { - var hash, posts, root; + var hash, post, posts, prevID, root; if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) { return; } if (Unread.posts.length) { + prevID = 0; while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { - if (!(Get.postFromRoot(root)).isHidden) { + post = Get.postFromRoot(root); + if (prevID === post.ID) { + break; + } + prevID = post.ID; + if (!post.isHidden) { break; } } @@ -9304,7 +9314,7 @@ Settings[key].call(input); } }); - $.on($('input[name=Interval]', section), 'input', ThreadUpdater.cb.interval); + $.on($('input[name=Interval]', section), 'change', ThreadUpdater.cb.interval); $.on($('input[name="Custom CSS"]', section), 'change', Settings.togglecss); return $.on($.id('apply-css'), 'click', Settings.usercss); }, diff --git a/img/changelog/3.2.0/0.png b/img/changelog/3.2.0/0.png deleted file mode 100644 index d73ba75fe..000000000 Binary files a/img/changelog/3.2.0/0.png and /dev/null differ diff --git a/src/config.coffee b/src/config.coffee index e61cedb8a..759a1701d 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -267,7 +267,7 @@ Config = ] 'Cooldown': [ true - 'Prevent "flood detected" errors.' + 'Indicate the remaining time before posting again.' ] 'Cooldown Prediction': [ true diff --git a/src/features/misc/announcementhiding.coffee b/src/features/misc/announcementhiding.coffee index be60550b5..8462bdcf9 100644 --- a/src/features/misc/announcementhiding.coffee +++ b/src/features/misc/announcementhiding.coffee @@ -61,7 +61,7 @@ PSAHiding = true else false - if hr = $.x 'following-sibling::hr', psa - hr.hidden = psa.hidden + if (hr = psa.nextElementSibling) and hr.nodeName is 'HR' + hr.hidden = psa.hidden trim: (psa) -> - psa.textContent.replace(/\W+/g, '').toLowerCase() \ No newline at end of file + psa.textContent.replace(/\W+/g, '').toLowerCase() diff --git a/src/features/monitoring/unread.coffee b/src/features/monitoring/unread.coffee index 738742ab8..03d01c48f 100644 --- a/src/features/monitoring/unread.coffee +++ b/src/features/monitoring/unread.coffee @@ -15,26 +15,34 @@ Unread = node: -> Unread.thread = @ Unread.title = d.title - posts = [] - for ID, post of @posts - posts.push post if post.isReply Unread.lastReadPost = Unread.db.get boardID: @board.ID threadID: @ID defaultValue: 0 - Unread.addPosts posts + $.on d, '4chanXInitFinished', Unread.ready $.on d, 'ThreadUpdate', Unread.onUpdate $.on d, 'scroll visibilitychange', Unread.read $.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line'] $.on window, 'load', Unread.scroll if Conf['Scroll to Last Read Post'] + ready: -> + $.off d, '4chanXInitFinished', Unread.ready + posts = [] + for ID, post of Unread.thread.posts + posts.push post if post.isReply + Unread.addPosts posts + scroll: -> # Let the header's onload callback handle it. return if (hash = location.hash.match /\d+/) and hash[0] of Unread.thread.posts if Unread.posts.length # Scroll to before the first unread post. + prevID = 0 while root = $.x 'preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root - break unless (Get.postFromRoot root).isHidden + post = Get.postFromRoot root + break if prevID is post.ID + prevID = post.ID + break unless post.isHidden root.scrollIntoView false return # Scroll to the last read post. @@ -175,4 +183,4 @@ Unread = # `favicon.href = href` isn't enough on Opera. # Opera won't always update the favicon if the href didn't change. $.add d.head, Favicon.el - <% } %> \ No newline at end of file + <% } %> diff --git a/src/settings.coffee b/src/settings.coffee index 6ffbe4c01..b2e12f342 100644 --- a/src/settings.coffee +++ b/src/settings.coffee @@ -508,7 +508,7 @@ Settings = Settings[key].call input return - $.on $('input[name=Interval]', section), 'input', ThreadUpdater.cb.interval + $.on $('input[name=Interval]', section), 'change', ThreadUpdater.cb.interval $.on $('input[name="Custom CSS"]', section), 'change', Settings.togglecss $.on $.id('apply-css'), 'click', Settings.usercss boardnav: ->