configurable update interval
This commit is contained in:
parent
c26e0cd1f6
commit
e49cd5e3c8
@ -829,7 +829,7 @@ updateCallback = (res) ->
|
|||||||
count.className = if i is 0 then '' else 'new'
|
count.className = if i is 0 then '' else 'new'
|
||||||
|
|
||||||
span = $ '#updater #timer'
|
span = $ '#updater #timer'
|
||||||
span.textContent = -10
|
span.textContent = -1 * GM_getValue 'Interval', 10
|
||||||
|
|
||||||
updateTime = ->
|
updateTime = ->
|
||||||
span = $ '#updater #timer'
|
span = $ '#updater #timer'
|
||||||
@ -840,28 +840,42 @@ updateTime = ->
|
|||||||
updateAuto = ->
|
updateAuto = ->
|
||||||
span = $ '#updater #timer'
|
span = $ '#updater #timer'
|
||||||
if @checked
|
if @checked
|
||||||
span.textContent = -10
|
span.textContent = -1 * GM_getValue 'Interval', 10
|
||||||
g.timer = window.setInterval updateTime, 1000
|
g.timer = window.setInterval updateTime, 1000
|
||||||
else
|
else
|
||||||
span.textContent = ''
|
span.textContent = ''
|
||||||
clearInterval g.timer
|
clearInterval g.timer
|
||||||
|
|
||||||
|
updateInterval = ->
|
||||||
|
unless n = Number @value
|
||||||
|
n = 10
|
||||||
|
@value = n
|
||||||
|
GM_setValue 'Interval', n
|
||||||
|
|
||||||
|
span = $ '#updater #timer'
|
||||||
|
if 0 > Number span.textContent
|
||||||
|
span.textContent = -1 * n
|
||||||
|
|
||||||
updateNow = ->
|
updateNow = ->
|
||||||
request location.href, updateCallback
|
request location.href, updateCallback
|
||||||
|
|
||||||
updaterMake = ->
|
updaterMake = ->
|
||||||
div = AEOS.makeDialog 'updater', 'topright'
|
div = AEOS.makeDialog 'updater', 'topright'
|
||||||
html = "<div class=move><span id=count></span> <span id=timer>Thread Updater</span></div>"
|
html = "<div class=move><span id=count></span> <span id=timer>Thread Updater</span></div>"
|
||||||
html += "<div><label>Auto Update<input type=checkbox></label></div>"
|
html += "<div><label>Auto Update<input type=checkbox name=auto></label></div>"
|
||||||
|
html += "<div><label>Interval (s)<input type=text name=interval></label></div>"
|
||||||
html += "<div><input type=button value='Update Now'></div>"
|
html += "<div><input type=button value='Update Now'></div>"
|
||||||
div.innerHTML = html
|
div.innerHTML = html
|
||||||
|
|
||||||
$('div.move', div).addEventListener 'mousedown', AEOS.move, true
|
$('div.move', div).addEventListener 'mousedown', AEOS.move, true
|
||||||
cb = $ 'input[type=checkbox]', div
|
auto = $ 'input[name=auto]', div
|
||||||
cb.addEventListener 'click', updateAuto, true
|
auto.addEventListener 'click', updateAuto, true
|
||||||
|
interval = $ 'input[name=interval]', div
|
||||||
|
interval.value = GM_getValue 'Interval', 10
|
||||||
|
interval.addEventListener 'change', updateInterval, true
|
||||||
$('input[type=button]', div).addEventListener 'click', updateNow, true
|
$('input[type=button]', div).addEventListener 'click', updateNow, true
|
||||||
document.body.appendChild div
|
document.body.appendChild div
|
||||||
if getConfig 'Auto Update' then cb.click()
|
if getConfig 'Auto Update' then auto.click()
|
||||||
|
|
||||||
watch = ->
|
watch = ->
|
||||||
id = @nextSibling.name
|
id = @nextSibling.name
|
||||||
|
|||||||
32
4chan_x.js
32
4chan_x.js
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(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, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, updateAuto, updateCallback, 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, 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 __slice = Array.prototype.slice, __indexOf = Array.prototype.indexOf || function(item) {
|
var __slice = Array.prototype.slice, __indexOf = Array.prototype.indexOf || function(item) {
|
||||||
for (var i = 0, l = this.length; i < l; i++) {
|
for (var i = 0, l = this.length; i < l; i++) {
|
||||||
if (this[i] === item) return i;
|
if (this[i] === item) return i;
|
||||||
@ -1090,7 +1090,7 @@
|
|||||||
count.textContent = "+" + i;
|
count.textContent = "+" + i;
|
||||||
count.className = i === 0 ? '' : 'new';
|
count.className = i === 0 ? '' : 'new';
|
||||||
span = $('#updater #timer');
|
span = $('#updater #timer');
|
||||||
return span.textContent = -10;
|
return span.textContent = -1 * GM_getValue('Interval', 10);
|
||||||
};
|
};
|
||||||
updateTime = function() {
|
updateTime = function() {
|
||||||
var span, time;
|
var span, time;
|
||||||
@ -1105,30 +1105,46 @@
|
|||||||
var span;
|
var span;
|
||||||
span = $('#updater #timer');
|
span = $('#updater #timer');
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
span.textContent = -10;
|
span.textContent = -1 * GM_getValue('Interval', 10);
|
||||||
return g.timer = window.setInterval(updateTime, 1000);
|
return g.timer = window.setInterval(updateTime, 1000);
|
||||||
} else {
|
} else {
|
||||||
span.textContent = '';
|
span.textContent = '';
|
||||||
return clearInterval(g.timer);
|
return clearInterval(g.timer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
updateInterval = function() {
|
||||||
|
var span;
|
||||||
|
if (!(n = Number(this.value))) {
|
||||||
|
n = 10;
|
||||||
|
}
|
||||||
|
this.value = n;
|
||||||
|
GM_setValue('Interval', n);
|
||||||
|
span = $('#updater #timer');
|
||||||
|
if (0 > Number(span.textContent)) {
|
||||||
|
return span.textContent = -1 * n;
|
||||||
|
}
|
||||||
|
};
|
||||||
updateNow = function() {
|
updateNow = function() {
|
||||||
return request(location.href, updateCallback);
|
return request(location.href, updateCallback);
|
||||||
};
|
};
|
||||||
updaterMake = function() {
|
updaterMake = function() {
|
||||||
var cb, div, html;
|
var auto, div, html, interval;
|
||||||
div = AEOS.makeDialog('updater', 'topright');
|
div = AEOS.makeDialog('updater', 'topright');
|
||||||
html = "<div class=move><span id=count></span> <span id=timer>Thread Updater</span></div>";
|
html = "<div class=move><span id=count></span> <span id=timer>Thread Updater</span></div>";
|
||||||
html += "<div><label>Auto Update<input type=checkbox></label></div>";
|
html += "<div><label>Auto Update<input type=checkbox name=auto></label></div>";
|
||||||
|
html += "<div><label>Interval (s)<input type=text name=interval></label></div>";
|
||||||
html += "<div><input type=button value='Update Now'></div>";
|
html += "<div><input type=button value='Update Now'></div>";
|
||||||
div.innerHTML = html;
|
div.innerHTML = html;
|
||||||
$('div.move', div).addEventListener('mousedown', AEOS.move, true);
|
$('div.move', div).addEventListener('mousedown', AEOS.move, true);
|
||||||
cb = $('input[type=checkbox]', div);
|
auto = $('input[name=auto]', div);
|
||||||
cb.addEventListener('click', updateAuto, true);
|
auto.addEventListener('click', updateAuto, true);
|
||||||
|
interval = $('input[name=interval]', div);
|
||||||
|
interval.value = GM_getValue('Interval', 10);
|
||||||
|
interval.addEventListener('change', updateInterval, true);
|
||||||
$('input[type=button]', div).addEventListener('click', updateNow, true);
|
$('input[type=button]', div).addEventListener('click', updateNow, true);
|
||||||
document.body.appendChild(div);
|
document.body.appendChild(div);
|
||||||
if (getConfig('Auto Update')) {
|
if (getConfig('Auto Update')) {
|
||||||
return cb.click();
|
return auto.click();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
watch = function() {
|
watch = function() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user