thread updating
This commit is contained in:
parent
3cbbb1f851
commit
44e5e5a78e
@ -25,6 +25,7 @@ config =
|
|||||||
'Thread Expansion': [true, 'View all replies']
|
'Thread Expansion': [true, 'View all replies']
|
||||||
'Thread Hiding': [true, 'Hide entire threads']
|
'Thread Hiding': [true, 'Hide entire threads']
|
||||||
'Thread Navigation': [true, 'Navigate to previous / next thread']
|
'Thread Navigation': [true, 'Navigate to previous / next thread']
|
||||||
|
'Thread Updater': [true, 'Update threads']
|
||||||
'Thread Watcher': [true, 'Bookmark threads']
|
'Thread Watcher': [true, 'Bookmark threads']
|
||||||
|
|
||||||
#utility
|
#utility
|
||||||
@ -800,6 +801,41 @@ threadF = (current) ->
|
|||||||
if current.nodeName isnt 'CENTER'
|
if current.nodeName isnt 'CENTER'
|
||||||
threadF(current)
|
threadF(current)
|
||||||
|
|
||||||
|
request = (url, callback) ->
|
||||||
|
r = new XMLHttpRequest()
|
||||||
|
r.onload = -> callback this
|
||||||
|
r.open 'get', url, true
|
||||||
|
r.send()
|
||||||
|
|
||||||
|
updateCallback = (res) ->
|
||||||
|
body = n 'body', innerHTML: res.responseText
|
||||||
|
replies = $$ 'td.reply', body
|
||||||
|
|
||||||
|
root = x './/br[@clear]/preceding::table[1]'
|
||||||
|
id = Number $('td.reply, td.replyhl', root).id
|
||||||
|
i = 0
|
||||||
|
|
||||||
|
while (reply = replies.pop()) and (Number reply.id > id)
|
||||||
|
table = x 'ancestor::table', reply
|
||||||
|
inAfter root, table
|
||||||
|
++i
|
||||||
|
|
||||||
|
$('#updater div.move').textContent = "+#{i}"
|
||||||
|
|
||||||
|
updateNow = ->
|
||||||
|
request location.href, updateCallback
|
||||||
|
|
||||||
|
updaterMake = ->
|
||||||
|
div = AEOS.makeDialog 'updater', 'topright'
|
||||||
|
html = "<div class=move>Thread Updater</div>"
|
||||||
|
html += "<div><label>Update<input type=checkbox></label></div>"
|
||||||
|
html += "<div><input type=button value='Update Now'></div>"
|
||||||
|
div.innerHTML = html
|
||||||
|
|
||||||
|
$('div.move', div).addEventListener 'mousedown', AEOS.move, true
|
||||||
|
$('input[type=button]', div).addEventListener 'click', updateNow, true
|
||||||
|
document.body.appendChild div
|
||||||
|
|
||||||
watch = ->
|
watch = ->
|
||||||
id = @nextSibling.name
|
id = @nextSibling.name
|
||||||
if @src is g.favEmpty
|
if @src is g.favEmpty
|
||||||
@ -913,6 +949,10 @@ if lastChecked < now - 1*DAY
|
|||||||
GM_setValue('lastChecked', now)
|
GM_setValue('lastChecked', now)
|
||||||
|
|
||||||
GM_addStyle '
|
GM_addStyle '
|
||||||
|
#updater {
|
||||||
|
position: fixed;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
#watcher {
|
#watcher {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
@ -1154,6 +1194,8 @@ if getConfig 'Keybinds'
|
|||||||
document.addEventListener 'keypress', keypress, true
|
document.addEventListener 'keypress', keypress, true
|
||||||
|
|
||||||
if g.REPLY
|
if g.REPLY
|
||||||
|
if getConfig 'Thread Updater'
|
||||||
|
updaterMake()
|
||||||
if getConfig('Quick Reply') and getConfig 'Persistent QR'
|
if getConfig('Quick Reply') and getConfig 'Persistent QR'
|
||||||
quickReply()
|
quickReply()
|
||||||
$('#qr input[title=autohide]').click()
|
$('#qr input[title=autohide]').click()
|
||||||
|
|||||||
49
4chan_x.js
49
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, scroll, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, 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, updateCallback, updateNow, 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;
|
||||||
@ -25,6 +25,7 @@
|
|||||||
'Thread Expansion': [true, 'View all replies'],
|
'Thread Expansion': [true, 'View all replies'],
|
||||||
'Thread Hiding': [true, 'Hide entire threads'],
|
'Thread Hiding': [true, 'Hide entire threads'],
|
||||||
'Thread Navigation': [true, 'Navigate to previous / next thread'],
|
'Thread Navigation': [true, 'Navigate to previous / next thread'],
|
||||||
|
'Thread Updater': [true, 'Update threads'],
|
||||||
'Thread Watcher': [true, 'Bookmark threads']
|
'Thread Watcher': [true, 'Bookmark threads']
|
||||||
};
|
};
|
||||||
AEOS = {
|
AEOS = {
|
||||||
@ -1057,6 +1058,45 @@
|
|||||||
return threadF(current);
|
return threadF(current);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
request = function(url, callback) {
|
||||||
|
var r;
|
||||||
|
r = new XMLHttpRequest();
|
||||||
|
r.onload = function() {
|
||||||
|
return callback(this);
|
||||||
|
};
|
||||||
|
r.open('get', url, true);
|
||||||
|
return r.send();
|
||||||
|
};
|
||||||
|
updateCallback = function(res) {
|
||||||
|
var body, i, id, replies, reply, root, table;
|
||||||
|
body = n('body', {
|
||||||
|
innerHTML: res.responseText
|
||||||
|
});
|
||||||
|
replies = $$('td.reply', body);
|
||||||
|
root = x('.//br[@clear]/preceding::table[1]');
|
||||||
|
id = Number($('td.reply, td.replyhl', root).id);
|
||||||
|
i = 0;
|
||||||
|
while ((reply = replies.pop()) && (Number(reply.id > id))) {
|
||||||
|
table = x('ancestor::table', reply);
|
||||||
|
inAfter(root, table);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
return $('#updater div.move').textContent = "+" + i;
|
||||||
|
};
|
||||||
|
updateNow = function() {
|
||||||
|
return request(location.href, updateCallback);
|
||||||
|
};
|
||||||
|
updaterMake = function() {
|
||||||
|
var div, html;
|
||||||
|
div = AEOS.makeDialog('updater', 'topright');
|
||||||
|
html = "<div class=move>Thread Updater</div>";
|
||||||
|
html += "<div><label>Update<input type=checkbox></label></div>";
|
||||||
|
html += "<div><input type=button value='Update Now'></div>";
|
||||||
|
div.innerHTML = html;
|
||||||
|
$('div.move', div).addEventListener('mousedown', AEOS.move, true);
|
||||||
|
$('input[type=button]', div).addEventListener('click', updateNow, true);
|
||||||
|
return document.body.appendChild(div);
|
||||||
|
};
|
||||||
watch = function() {
|
watch = function() {
|
||||||
var id, text, _base, _name;
|
var id, text, _base, _name;
|
||||||
id = this.nextSibling.name;
|
id = this.nextSibling.name;
|
||||||
@ -1180,6 +1220,10 @@
|
|||||||
GM_setValue('lastChecked', now);
|
GM_setValue('lastChecked', now);
|
||||||
}
|
}
|
||||||
GM_addStyle('\
|
GM_addStyle('\
|
||||||
|
#updater {\
|
||||||
|
position: fixed;\
|
||||||
|
text-align: right;\
|
||||||
|
}\
|
||||||
#watcher {\
|
#watcher {\
|
||||||
position: absolute;\
|
position: absolute;\
|
||||||
}\
|
}\
|
||||||
@ -1486,6 +1530,9 @@
|
|||||||
document.addEventListener('keypress', keypress, true);
|
document.addEventListener('keypress', keypress, true);
|
||||||
}
|
}
|
||||||
if (g.REPLY) {
|
if (g.REPLY) {
|
||||||
|
if (getConfig('Thread Updater')) {
|
||||||
|
updaterMake();
|
||||||
|
}
|
||||||
if (getConfig('Quick Reply') && getConfig('Persistent QR')) {
|
if (getConfig('Quick Reply') && getConfig('Persistent QR')) {
|
||||||
quickReply();
|
quickReply();
|
||||||
$('#qr input[title=autohide]').click();
|
$('#qr input[title=autohide]').click();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user