diff --git a/4chan_x.coffee b/4chan_x.coffee index 4c11a6edf..ddaf53492 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -808,6 +808,7 @@ request = (url, callback) -> r.onload = -> callback this r.open 'get', url, true r.send() + r updateCallback = (res) -> body = n 'body', innerHTML: res.responseText @@ -835,7 +836,12 @@ updateCallback = (res) -> updateTime = -> span = $ '#updater #timer' time = Number span.textContent - if ++time is 0 then updateNow() + if ++time is 0 + updateNow() + else if time > 10 + time = 0 + g.r.abort() + updateNow() span.textContent = time updateAuto = -> @@ -858,7 +864,7 @@ updateInterval = -> span.textContent = -1 * n updateNow = -> - request location.href, updateCallback + g.r = request location.href, updateCallback updaterMake = -> div = AEOS.makeDialog 'updater', 'topright' @@ -994,6 +1000,9 @@ GM_addStyle ' position: fixed; text-align: right; } + #updater input[type=text] { + width: 50px; + } #watcher { position: absolute; } diff --git a/4chan_x.js b/4chan_x.js index 8beb473aa..8e9021cd6 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1067,7 +1067,8 @@ return callback(this); }; r.open('get', url, true); - return r.send(); + r.send(); + return r; }; updateCallback = function(res) { var body, count, i, id, replies, reply, root, span, table; @@ -1099,6 +1100,10 @@ time = Number(span.textContent); if (++time === 0) { updateNow(); + } else if (time > 10) { + time = 0; + g.r.abort(); + updateNow(); } return span.textContent = time; }; @@ -1126,7 +1131,7 @@ } }; updateNow = function() { - return request(location.href, updateCallback); + return g.r = request(location.href, updateCallback); }; updaterMake = function() { var auto, div, html, interval; @@ -1274,6 +1279,9 @@ position: fixed;\ text-align: right;\ }\ + #updater input[type=text] {\ + width: 50px;\ + }\ #watcher {\ position: absolute;\ }\