rewrite reply hiding
This commit is contained in:
parent
b689e13788
commit
ba0ef9b51f
165
4chan_x.js
165
4chan_x.js
@ -58,7 +58,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, DAY, a, arr, as, autoWatch, callback, changeCheckbox, changeValue, clearHidden, config, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, g, getThread, hideReply, href, html, i, id, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, img, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, log, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyNav, report, request, scroll, scrollThread, showReply, span, src, temp, text, textContent, threadHiding, threads, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updaterMake, watch, watchX, watcher, watcherUpdate, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _len7, _m, _n, _ref, _ref2, _ref3, _ref4;
|
var $, $$, a, arr, as, autoWatch, callback, changeCheckbox, changeValue, clearHidden, config, d, delform, down, editSauce, el, expand, expandComment, expandThread, g, getThread, href, html, i, id, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, img, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, log, navbotr, navtopr, nodeInserted, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyHiding, replyNav, report, request, scroll, scrollThread, span, src, temp, text, textContent, threadHiding, threads, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updaterMake, watch, watchX, watcher, watcherUpdate, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _len7, _m, _n, _ref, _ref2, _ref3, _ref4;
|
||||||
var __slice = Array.prototype.slice;
|
var __slice = Array.prototype.slice;
|
||||||
if (typeof console != "undefined" && console !== null) {
|
if (typeof console != "undefined" && console !== null) {
|
||||||
log = console.log;
|
log = console.log;
|
||||||
@ -449,29 +449,66 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
hideReply = function(reply) {
|
replyHiding = {
|
||||||
var a, div, name, p, table, trip, _ref;
|
init: function() {
|
||||||
if (p = this.parentNode) {
|
return g.callbacks.push(replyHiding.cb.node);
|
||||||
reply = p.nextSibling;
|
},
|
||||||
g.hiddenReplies.push({
|
cb: {
|
||||||
id: reply.id,
|
hide: function(e) {
|
||||||
timestamp: Date.now()
|
var reply;
|
||||||
});
|
reply = e.target.parentNode.nextSibling;
|
||||||
GM_setValue("hiddenReplies/" + g.BOARD + "/", JSON.stringify(g.hiddenReplies));
|
return replyHiding.hide(reply);
|
||||||
}
|
},
|
||||||
name = $('span.commentpostername', reply).textContent;
|
node: function(root) {
|
||||||
trip = ((_ref = $('span.postertrip', reply)) != null ? _ref.textContent : void 0) || '';
|
var a, id, reply, td, tds, _i, _len, _results;
|
||||||
table = $.x('ancestor::table', reply);
|
tds = $$('td.doubledash', root);
|
||||||
$.hide(table);
|
_results = [];
|
||||||
if ($.config('Show Stubs')) {
|
for (_i = 0, _len = tds.length; _i < _len; _i++) {
|
||||||
a = $.el('a', {
|
td = tds[_i];
|
||||||
textContent: "[ + ] " + name + " " + trip,
|
a = $.el('a', {
|
||||||
className: 'pointer'
|
textContent: '[ - ]'
|
||||||
});
|
});
|
||||||
$.bind(a, 'click', showReply);
|
$.bind(a, 'click', replyHiding.cb.hide);
|
||||||
div = $.el('div');
|
$.replace(td.firstChild, a);
|
||||||
$.append(div, a);
|
reply = td.nextSibling;
|
||||||
return $.before(table, div);
|
id = reply.id;
|
||||||
|
_results.push(id in g.hiddenReply ? replyHiding.hide(reply) : void 0);
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
},
|
||||||
|
show: function(e) {
|
||||||
|
var div, table;
|
||||||
|
div = e.target.parentNode;
|
||||||
|
table = div.nextSibling;
|
||||||
|
replyHiding.show(table);
|
||||||
|
return $.remove(div);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hide: function(reply) {
|
||||||
|
var a, div, id, name, table, trip, _ref;
|
||||||
|
table = reply.parentNode.parentNode.parentNode;
|
||||||
|
$.hide(table);
|
||||||
|
if ($.config('Show Stubs')) {
|
||||||
|
name = $('span.commentpostername', reply).textContent;
|
||||||
|
trip = ((_ref = $('span.postertrip', reply)) != null ? _ref.textContent : void 0) || '';
|
||||||
|
a = $.el('a', {
|
||||||
|
textContent: "[ + ] " + name + " " + trip
|
||||||
|
});
|
||||||
|
$.bind(a, 'click', replyHiding.cb.show);
|
||||||
|
div = $.el('div');
|
||||||
|
$.append(div, a);
|
||||||
|
$.before(table, div);
|
||||||
|
}
|
||||||
|
id = reply.id;
|
||||||
|
g.hiddenReply[id] = Date.now();
|
||||||
|
return GM_setValue("hiddenReply/" + g.BOARD + "/", JSON.stringify(g.hiddenReply));
|
||||||
|
},
|
||||||
|
show: function(table) {
|
||||||
|
var id;
|
||||||
|
$.show(table);
|
||||||
|
id = $('td[id]', table).id;
|
||||||
|
delete g.hiddenReply[id];
|
||||||
|
return GM_setValue("hiddenReply/" + g.BOARD + "/", JSON.stringify(g.hiddenReply));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
imageHover = {
|
imageHover = {
|
||||||
@ -1230,16 +1267,6 @@
|
|||||||
}
|
}
|
||||||
return location.hash = hash;
|
return location.hash = hash;
|
||||||
};
|
};
|
||||||
showReply = function() {
|
|
||||||
var div, id, table;
|
|
||||||
div = this.parentNode;
|
|
||||||
table = div.nextSibling;
|
|
||||||
$.show(table);
|
|
||||||
$.remove(div);
|
|
||||||
id = $('td.reply, td.replyhl', table).id;
|
|
||||||
$.slice(g.hiddenReplies, id);
|
|
||||||
return GM_setValue("hiddenReplies/" + g.BOARD + "/", JSON.stringify(g.hiddenReplies));
|
|
||||||
};
|
|
||||||
threadHiding = {
|
threadHiding = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var a, hiddenThreads, id, node, thread, _i, _len, _ref, _results;
|
var a, hiddenThreads, id, node, thread, _i, _len, _ref, _results;
|
||||||
@ -1587,32 +1614,32 @@
|
|||||||
}
|
}
|
||||||
g.hiddenThreads = JSON.parse(GM_getValue("hiddenThreads/" + g.BOARD + "/", '[]'));
|
g.hiddenThreads = JSON.parse(GM_getValue("hiddenThreads/" + g.BOARD + "/", '[]'));
|
||||||
g.hiddenReplies = JSON.parse(GM_getValue("hiddenReplies/" + g.BOARD + "/", '[]'));
|
g.hiddenReplies = JSON.parse(GM_getValue("hiddenReplies/" + g.BOARD + "/", '[]'));
|
||||||
|
g.hiddenReply = JSON.parse(GM_getValue("hiddenReply/" + g.BOARD + "/", '{}'));
|
||||||
tzOffset = (new Date()).getTimezoneOffset() / 60;
|
tzOffset = (new Date()).getTimezoneOffset() / 60;
|
||||||
g.chanOffset = 5 - tzOffset;
|
g.chanOffset = 5 - tzOffset;
|
||||||
if ($.isDST()) {
|
if ($.isDST()) {
|
||||||
g.chanOffset -= 1;
|
g.chanOffset -= 1;
|
||||||
}
|
}
|
||||||
lastChecked = Number(GM_getValue('lastChecked', '0'));
|
/*
|
||||||
now = Date.now();
|
lastChecked = Number GM_getValue('lastChecked', '0')
|
||||||
DAY = 24 * 60 * 60;
|
now = Date.now()
|
||||||
if (lastChecked < now - 1 * DAY) {
|
DAY = 24 * 60 * 60
|
||||||
cutoff = now - 7 * DAY;
|
if lastChecked < now - 1*DAY
|
||||||
while (g.hiddenThreads.length) {
|
cutoff = now - 7*DAY
|
||||||
if (g.hiddenThreads[0].timestamp > cutoff) {
|
while g.hiddenThreads.length
|
||||||
break;
|
if g.hiddenThreads[0].timestamp > cutoff
|
||||||
}
|
break
|
||||||
g.hiddenThreads.shift();
|
g.hiddenThreads.shift()
|
||||||
}
|
|
||||||
while (g.hiddenReplies.length) {
|
while g.hiddenReplies.length
|
||||||
if (g.hiddenReplies[0].timestamp > cutoff) {
|
if g.hiddenReplies[0].timestamp > cutoff
|
||||||
break;
|
break
|
||||||
}
|
g.hiddenReplies.shift()
|
||||||
g.hiddenReplies.shift();
|
|
||||||
}
|
GM_setValue("hiddenThreads/#{g.BOARD}/", JSON.stringify(g.hiddenThreads))
|
||||||
GM_setValue("hiddenThreads/" + g.BOARD + "/", JSON.stringify(g.hiddenThreads));
|
GM_setValue("hiddenReplies/#{g.BOARD}/", JSON.stringify(g.hiddenReplies))
|
||||||
GM_setValue("hiddenReplies/" + g.BOARD + "/", JSON.stringify(g.hiddenReplies));
|
GM_setValue('lastChecked', now.toString())
|
||||||
GM_setValue('lastChecked', now.toString());
|
*/
|
||||||
}
|
|
||||||
$.addStyle('\
|
$.addStyle('\
|
||||||
/* dialog styling */\
|
/* dialog styling */\
|
||||||
div.dialog {\
|
div.dialog {\
|
||||||
@ -1860,33 +1887,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($.config('Reply Hiding')) {
|
if ($.config('Reply Hiding')) {
|
||||||
g.callbacks.push(function(root) {
|
replyHiding.init();
|
||||||
var id, next, obj, td, tds, _i, _len, _results;
|
|
||||||
tds = $$('td.doubledash', root);
|
|
||||||
_results = [];
|
|
||||||
for (_i = 0, _len = tds.length; _i < _len; _i++) {
|
|
||||||
td = tds[_i];
|
|
||||||
a = $.el('a', {
|
|
||||||
textContent: '[ - ]',
|
|
||||||
className: 'pointer'
|
|
||||||
});
|
|
||||||
$.bind(a, 'click', hideReply);
|
|
||||||
$.replace(td.firstChild, a);
|
|
||||||
next = td.nextSibling;
|
|
||||||
id = next.id;
|
|
||||||
_results.push((function() {
|
|
||||||
var _i, _len, _ref, _results;
|
|
||||||
_ref = g.hiddenReplies;
|
|
||||||
_results = [];
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
obj = _ref[_i];
|
|
||||||
_results.push(obj.id === id ? hideReply(next) : void 0);
|
|
||||||
}
|
|
||||||
return _results;
|
|
||||||
})());
|
|
||||||
}
|
|
||||||
return _results;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if ($.config('Quick Reply')) {
|
if ($.config('Quick Reply')) {
|
||||||
qr.init();
|
qr.init();
|
||||||
|
|||||||
101
script.coffee
101
script.coffee
@ -300,26 +300,60 @@ getThread = ->
|
|||||||
if bottom > 0 #we have not scrolled past
|
if bottom > 0 #we have not scrolled past
|
||||||
return [thread, i]
|
return [thread, i]
|
||||||
|
|
||||||
hideReply = (reply) ->
|
replyHiding =
|
||||||
if p = @parentNode
|
init: ->
|
||||||
reply = p.nextSibling
|
g.callbacks.push replyHiding.cb.node
|
||||||
g.hiddenReplies.push {
|
|
||||||
id: reply.id
|
cb:
|
||||||
timestamp: Date.now()
|
hide: (e) ->
|
||||||
}
|
reply = e.target.parentNode.nextSibling
|
||||||
GM_setValue("hiddenReplies/#{g.BOARD}/", JSON.stringify(g.hiddenReplies))
|
replyHiding.hide reply
|
||||||
name = $('span.commentpostername', reply).textContent
|
|
||||||
trip = $('span.postertrip', reply)?.textContent or ''
|
node: (root) ->
|
||||||
table = $.x 'ancestor::table', reply
|
tds = $$('td.doubledash', root)
|
||||||
$.hide table
|
for td in tds
|
||||||
if $.config 'Show Stubs'
|
a = $.el 'a',
|
||||||
a = $.el 'a',
|
textContent: '[ - ]'
|
||||||
textContent: "[ + ] #{name} #{trip}"
|
$.bind a, 'click', replyHiding.cb.hide
|
||||||
className: 'pointer'
|
$.replace td.firstChild, a
|
||||||
$.bind a, 'click', showReply
|
|
||||||
div = $.el 'div'
|
reply = td.nextSibling
|
||||||
$.append div, a
|
id = reply.id
|
||||||
$.before table, div
|
if id of g.hiddenReply
|
||||||
|
replyHiding.hide reply
|
||||||
|
|
||||||
|
show: (e) ->
|
||||||
|
div = e.target.parentNode
|
||||||
|
table = div.nextSibling
|
||||||
|
replyHiding.show table
|
||||||
|
|
||||||
|
$.remove div
|
||||||
|
|
||||||
|
hide: (reply) ->
|
||||||
|
table = reply.parentNode.parentNode.parentNode
|
||||||
|
$.hide table
|
||||||
|
|
||||||
|
if $.config 'Show Stubs'
|
||||||
|
name = $('span.commentpostername', reply).textContent
|
||||||
|
trip = $('span.postertrip', reply)?.textContent or ''
|
||||||
|
a = $.el 'a',
|
||||||
|
textContent: "[ + ] #{name} #{trip}"
|
||||||
|
$.bind a, 'click', replyHiding.cb.show
|
||||||
|
|
||||||
|
div = $.el 'div'
|
||||||
|
$.append div, a
|
||||||
|
$.before table, div
|
||||||
|
|
||||||
|
id = reply.id
|
||||||
|
g.hiddenReply[id] = Date.now()
|
||||||
|
GM_setValue "hiddenReply/#{g.BOARD}/", JSON.stringify g.hiddenReply
|
||||||
|
|
||||||
|
show: (table) ->
|
||||||
|
$.show table
|
||||||
|
|
||||||
|
id = $('td[id]', table).id
|
||||||
|
delete g.hiddenReply[id]
|
||||||
|
GM_setValue "hiddenReply/#{g.BOARD}/", JSON.stringify g.hiddenReply
|
||||||
|
|
||||||
imageHover =
|
imageHover =
|
||||||
init: ->
|
init: ->
|
||||||
@ -909,15 +943,6 @@ scrollThread = (count) ->
|
|||||||
hash = "p#{temp}"
|
hash = "p#{temp}"
|
||||||
location.hash = hash
|
location.hash = hash
|
||||||
|
|
||||||
showReply = ->
|
|
||||||
div = @parentNode
|
|
||||||
table = div.nextSibling
|
|
||||||
$.show table
|
|
||||||
$.remove div
|
|
||||||
id = $('td.reply, td.replyhl', table).id
|
|
||||||
$.slice g.hiddenReplies, id
|
|
||||||
GM_setValue "hiddenReplies/#{g.BOARD}/", JSON.stringify(g.hiddenReplies)
|
|
||||||
|
|
||||||
threadHiding =
|
threadHiding =
|
||||||
init: ->
|
init: ->
|
||||||
node = $ 'form[name=delform] > *'
|
node = $ 'form[name=delform] > *'
|
||||||
@ -1226,11 +1251,13 @@ else
|
|||||||
g.PAGENUM = parseInt(temp) || 0
|
g.PAGENUM = parseInt(temp) || 0
|
||||||
g.hiddenThreads = JSON.parse(GM_getValue("hiddenThreads/#{g.BOARD}/", '[]'))
|
g.hiddenThreads = JSON.parse(GM_getValue("hiddenThreads/#{g.BOARD}/", '[]'))
|
||||||
g.hiddenReplies = JSON.parse(GM_getValue("hiddenReplies/#{g.BOARD}/", '[]'))
|
g.hiddenReplies = JSON.parse(GM_getValue("hiddenReplies/#{g.BOARD}/", '[]'))
|
||||||
|
g.hiddenReply = JSON.parse GM_getValue "hiddenReply/#{g.BOARD}/", '{}'
|
||||||
tzOffset = (new Date()).getTimezoneOffset() / 60
|
tzOffset = (new Date()).getTimezoneOffset() / 60
|
||||||
# GMT -8 is given as +480; would GMT +8 be -480 ?
|
# GMT -8 is given as +480; would GMT +8 be -480 ?
|
||||||
g.chanOffset = 5 - tzOffset# 4chan = EST = GMT -5
|
g.chanOffset = 5 - tzOffset# 4chan = EST = GMT -5
|
||||||
if $.isDST() then g.chanOffset -= 1
|
if $.isDST() then g.chanOffset -= 1
|
||||||
|
|
||||||
|
###
|
||||||
lastChecked = Number GM_getValue('lastChecked', '0')
|
lastChecked = Number GM_getValue('lastChecked', '0')
|
||||||
now = Date.now()
|
now = Date.now()
|
||||||
DAY = 24 * 60 * 60
|
DAY = 24 * 60 * 60
|
||||||
@ -1249,6 +1276,7 @@ if lastChecked < now - 1*DAY
|
|||||||
GM_setValue("hiddenThreads/#{g.BOARD}/", JSON.stringify(g.hiddenThreads))
|
GM_setValue("hiddenThreads/#{g.BOARD}/", JSON.stringify(g.hiddenThreads))
|
||||||
GM_setValue("hiddenReplies/#{g.BOARD}/", JSON.stringify(g.hiddenReplies))
|
GM_setValue("hiddenReplies/#{g.BOARD}/", JSON.stringify(g.hiddenReplies))
|
||||||
GM_setValue('lastChecked', now.toString())
|
GM_setValue('lastChecked', now.toString())
|
||||||
|
###
|
||||||
|
|
||||||
$.addStyle '
|
$.addStyle '
|
||||||
/* dialog styling */
|
/* dialog styling */
|
||||||
@ -1457,20 +1485,7 @@ if $.config 'Sauce'
|
|||||||
i++
|
i++
|
||||||
|
|
||||||
if $.config 'Reply Hiding'
|
if $.config 'Reply Hiding'
|
||||||
g.callbacks.push (root) ->
|
replyHiding.init()
|
||||||
tds = $$('td.doubledash', root)
|
|
||||||
for td in tds
|
|
||||||
a = $.el 'a',
|
|
||||||
textContent: '[ - ]'
|
|
||||||
className: 'pointer'
|
|
||||||
$.bind a, 'click', hideReply
|
|
||||||
$.replace(td.firstChild, a)
|
|
||||||
|
|
||||||
next = td.nextSibling
|
|
||||||
id = next.id
|
|
||||||
for obj in g.hiddenReplies
|
|
||||||
if obj.id is id
|
|
||||||
hideReply(next)
|
|
||||||
|
|
||||||
if $.config 'Quick Reply'
|
if $.config 'Quick Reply'
|
||||||
qr.init()
|
qr.init()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user