diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 8fdcc0ace..84e2e89a3 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -9010,15 +9010,19 @@ } }, setInterval: function() { - var cur, i, j; + var cur, i, j, limit; - i = ThreadUpdater.interval; - j = (cur = ThreadUpdater.outdateCount < 10) ? cur : 10; - if (!d.hidden) { - j = j < 7 ? j : 7; + i = ThreadUpdater.interval + 1; + if (Conf['Optional Increase']) { + cur = ThreadUpdater.outdateCount || 1; + limit = d.hidden ? 7 : 10; + j = cur <= limit ? cur : limit; + cur = ((i * 0.1).floor() || 1) * j * j; + ThreadUpdater.seconds = cur > i ? cur <= 300 ? cur : 300 : i; + } else { + ThreadUpdater.seconds = i; } - ThreadUpdater.seconds = Conf['Optional Increase'] ? (cur = [0, 5, 10, 15, 20, 30, 60, 90, 120, 240, 300][j] > i) ? cur : i : i; - ThreadUpdater.set('timer', ThreadUpdater.seconds++); + ThreadUpdater.set('timer', ThreadUpdater.seconds); return ThreadUpdater.count(true); }, intervalShortcut: function() { diff --git a/builds/crx/script.js b/builds/crx/script.js index ce225ef1f..92bc2dc4a 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -8995,15 +8995,19 @@ } }, setInterval: function() { - var cur, i, j; + var cur, i, j, limit; - i = ThreadUpdater.interval; - j = (cur = ThreadUpdater.outdateCount < 10) ? cur : 10; - if (!d.hidden) { - j = j < 7 ? j : 7; + i = ThreadUpdater.interval + 1; + if (Conf['Optional Increase']) { + cur = ThreadUpdater.outdateCount || 1; + limit = d.hidden ? 7 : 10; + j = cur <= limit ? cur : limit; + cur = ((i * 0.1).floor() || 1) * j * j; + ThreadUpdater.seconds = cur > i ? cur <= 300 ? cur : 300 : i; + } else { + ThreadUpdater.seconds = i; } - ThreadUpdater.seconds = Conf['Optional Increase'] ? (cur = [0, 5, 10, 15, 20, 30, 60, 90, 120, 240, 300][j] > i) ? cur : i : i; - ThreadUpdater.set('timer', ThreadUpdater.seconds++); + ThreadUpdater.set('timer', ThreadUpdater.seconds); return ThreadUpdater.count(true); }, intervalShortcut: function() { diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee index 2bb8b9549..ff7e5ab01 100755 --- a/src/Monitoring/ThreadUpdater.coffee +++ b/src/Monitoring/ThreadUpdater.coffee @@ -148,18 +148,28 @@ ThreadUpdater = ThreadUpdater.cb.checkpost() setInterval: -> - i = ThreadUpdater.interval - # Math.min/max is provably slow: http://jsperf.com/math-s-min-max-vs-homemade/5 - j = if cur = ThreadUpdater.outdateCount < 10 then cur else 10 - unless d.hidden + i = ThreadUpdater.interval + 1 + + if Conf['Optional Increase'] # Lower the max refresh rate limit on visible tabs. - j = if j < 7 then j else 7 - ThreadUpdater.seconds = - if Conf['Optional Increase'] - if cur = [0, 5, 10, 15, 20, 30, 60, 90, 120, 240, 300][j] > i then cur else i - else - i - ThreadUpdater.set 'timer', ThreadUpdater.seconds++ + cur = ThreadUpdater.outdateCount or 1 + limit = if d.hidden then 7 else 10 + j = if cur <= limit then cur else limit + + # 1 second to 100, 30 to 300. + cur = ((i * 0.1).floor() or 1) * j * j + ThreadUpdater.seconds = + if cur > i + if cur <= 300 + cur + else + 300 + else + i + else + ThreadUpdater.seconds = i + + ThreadUpdater.set 'timer', ThreadUpdater.seconds ThreadUpdater.count true intervalShortcut: ->