This commit is contained in:
James Campos 2011-04-25 00:57:22 -07:00
parent 4c7b1d8335
commit ee9276f6fe
2 changed files with 70 additions and 69 deletions

View File

@ -561,7 +561,7 @@
$.replace(td.firstChild, a); $.replace(td.firstChild, a);
reply = td.nextSibling; reply = td.nextSibling;
id = reply.id; id = reply.id;
_results.push(id in g.hiddenReply ? replyHiding.hide(reply) : void 0); _results.push(id in g.hiddenReplies ? replyHiding.hide(reply) : void 0);
} }
return _results; return _results;
}, },
@ -589,15 +589,15 @@
$.before(table, div); $.before(table, div);
} }
id = reply.id; id = reply.id;
g.hiddenReply[id] = Date.now(); g.hiddenReplies[id] = Date.now();
return $.setValue("hiddenReply/" + g.BOARD + "/", g.hiddenReply); return $.setValue("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
}, },
show: function(table) { show: function(table) {
var id; var id;
$.show(table); $.show(table);
id = $('td[id]', table).id; id = $('td[id]', table).id;
delete g.hiddenReply[id]; delete g.hiddenReplies[id];
return $.setValue("hiddenReply/" + g.BOARD + "/", g.hiddenReply); return $.setValue("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
} }
}; };
keybinds = { keybinds = {
@ -860,7 +860,7 @@
} }
}, },
dialog: function() { dialog: function() {
var checked, conf, dialog, hiddenNum, hiddenThread, html, input, name, title, _i, _len, _ref; var checked, conf, dialog, hiddenNum, hiddenThreads, html, input, name, title, _i, _len, _ref;
html = "<div class=move>Options <a name=close>X</a></div>"; html = "<div class=move>Options <a name=close>X</a></div>";
conf = config.main.checkbox; conf = config.main.checkbox;
for (name in conf) { for (name in conf) {
@ -870,8 +870,8 @@
} }
html += "<div><a name=flavors>Flavors</a></div>"; html += "<div><a name=flavors>Flavors</a></div>";
html += "<div><textarea style=\"display: none;\" name=flavors>" + ($.config('flavors').join('\n')) + "</textarea></div>"; html += "<div><textarea style=\"display: none;\" name=flavors>" + ($.config('flavors').join('\n')) + "</textarea></div>";
hiddenThread = $.getValue("hiddenThread/" + g.BOARD + "/", {}); hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {});
hiddenNum = Object.keys(g.hiddenReply).length + Object.keys(hiddenThread).length; hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length;
html += "<div><input type=\"button\" value=\"hidden: " + hiddenNum + "\"></div>"; html += "<div><input type=\"button\" value=\"hidden: " + hiddenNum + "\"></div>";
html += "<hr>"; html += "<hr>";
html += "<div><a href=\"http://chat.now.im/x/aeos\">support throd</a></div>"; html += "<div><a href=\"http://chat.now.im/x/aeos\">support throd</a></div>";
@ -901,8 +901,8 @@
}, },
cb: { cb: {
clearHidden: function(e) { clearHidden: function(e) {
$.deleteValue("hiddenReply/" + g.BOARD + "/"); $.deleteValue("hiddenReplies/" + g.BOARD + "/");
$.deleteValue("hiddenThread/" + g.BOARD + "/"); $.deleteValue("hiddenThreads/" + g.BOARD + "/");
this.value = "hidden: 0"; this.value = "hidden: 0";
return g.hiddenReplies = {}; return g.hiddenReplies = {};
} }
@ -1174,7 +1174,7 @@
threadHiding = { threadHiding = {
init: function() { init: function() {
var a, hiddenThreads, op, thread, _i, _len, _ref, _results; var a, hiddenThreads, op, thread, _i, _len, _ref, _results;
hiddenThreads = $.getValue("hiddenThread/" + g.BOARD + "/", {}); hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {});
_ref = $$('div.thread'); _ref = $$('div.thread');
_results = []; _results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -1212,9 +1212,9 @@
var hiddenThreads, id; var hiddenThreads, id;
threadHiding.hideHide(thread); threadHiding.hideHide(thread);
id = thread.firstChild.id; id = thread.firstChild.id;
hiddenThreads = $.getValue("hiddenThread/" + g.BOARD + "/", {}); hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {});
hiddenThreads[id] = Date.now(); hiddenThreads[id] = Date.now();
return $.setValue("hiddenThread/" + g.BOARD + "/", hiddenThreads); return $.setValue("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
}, },
hideHide: function(thread) { hideHide: function(thread) {
var a, div, name, num, span, text, trip, _ref; var a, div, name, num, span, text, trip, _ref;
@ -1250,9 +1250,9 @@
$.show(thread); $.show(thread);
$.show(thread.nextSibling); $.show(thread.nextSibling);
id = thread.firstChild.id; id = thread.firstChild.id;
hiddenThreads = $.getValue("hiddenThread/" + g.BOARD + "/", {}); hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {});
delete hiddenThreads[id]; delete hiddenThreads[id];
return $.setValue("hiddenThread/" + g.BOARD + "/", hiddenThreads); return $.setValue("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
} }
}; };
updater = { updater = {
@ -1993,7 +1993,7 @@
}; };
main = { main = {
init: function() { init: function() {
var callback, navtopr, pathname, temp, tzOffset, _i, _len, _ref2; var DAY, callback, cutoff, hiddenThreads, id, lastChecked, navtopr, now, pathname, temp, timestamp, tzOffset, _i, _len, _ref2, _ref3;
Favicon.halo = /ws/.test(Favicon["default"]) ? Favicon.haloSFW : Favicon.haloNSFW; Favicon.halo = /ws/.test(Favicon["default"]) ? Favicon.haloSFW : Favicon.haloNSFW;
pathname = location.pathname.substring(1).split('/'); pathname = location.pathname.substring(1).split('/');
g.BOARD = pathname[0], temp = pathname[1]; g.BOARD = pathname[0], temp = pathname[1];
@ -2003,32 +2003,35 @@
} else { } else {
g.PAGENUM = parseInt(temp) || 0; g.PAGENUM = parseInt(temp) || 0;
} }
g.hiddenReply = $.getValue("hiddenReply/" + g.BOARD + "/", {}); g.hiddenReplies = $.getValue("hiddenReplies/" + 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 = $.getValue('lastChecked', 0);
lastChecked = Number GM_getValue('lastChecked', '0') now = Date.now();
now = Date.now() DAY = 1000 * 60 * 60 * 24;
DAY = 1000 * 60 * 60 * 24 if (lastChecked < now - 1 * DAY) {
if lastChecked < now - 1*DAY cutoff = now - 7 * DAY;
cutoff = now - 7*DAY hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {});
while g.hiddenThreads.length for (id in hiddenThreads) {
if g.hiddenThreads[0].timestamp > cutoff timestamp = hiddenThreads[id];
break if (timestamp < cutoff) {
g.hiddenThreads.shift() delete hiddenThreads[id];
}
while g.hiddenReplies.length }
if g.hiddenReplies[0].timestamp > cutoff _ref2 = g.hiddenReplies;
break for (id in _ref2) {
g.hiddenReplies.shift() timestamp = _ref2[id];
if (timestamp < cutoff) {
GM_setValue("hiddenThreads/#{g.BOARD}/", JSON.stringify(g.hiddenThreads)) delete g.hiddenReplies[id];
GM_setValue("hiddenReplies/#{g.BOARD}/", JSON.stringify(g.hiddenReplies)) }
GM_setValue('lastChecked', now.toString()) }
*/ $.setValue("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
$.setValue("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
$.setValue('lastChecked', now);
}
$.addStyle(main.css); $.addStyle(main.css);
if (location.hostname === 'sys.4chan.org') { if (location.hostname === 'sys.4chan.org') {
qr.sys(); qr.sys();
@ -2110,9 +2113,9 @@
expandComment.init(); expandComment.init();
} }
} }
_ref2 = g.callbacks; _ref3 = g.callbacks;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
callback = _ref2[_i]; callback = _ref3[_i];
callback(); callback();
} }
return $.bind(d.body, 'DOMNodeInserted', nodeInserted); return $.bind(d.body, 'DOMNodeInserted', nodeInserted);

View File

@ -383,7 +383,7 @@ replyHiding =
reply = td.nextSibling reply = td.nextSibling
id = reply.id id = reply.id
if id of g.hiddenReply if id of g.hiddenReplies
replyHiding.hide reply replyHiding.hide reply
show: (e) -> show: (e) ->
@ -409,15 +409,15 @@ replyHiding =
$.before table, div $.before table, div
id = reply.id id = reply.id
g.hiddenReply[id] = Date.now() g.hiddenReplies[id] = Date.now()
$.setValue "hiddenReply/#{g.BOARD}/", g.hiddenReply $.setValue "hiddenReplies/#{g.BOARD}/", g.hiddenReplies
show: (table) -> show: (table) ->
$.show table $.show table
id = $('td[id]', table).id id = $('td[id]', table).id
delete g.hiddenReply[id] delete g.hiddenReplies[id]
$.setValue "hiddenReply/#{g.BOARD}/", g.hiddenReply $.setValue "hiddenReplies/#{g.BOARD}/", g.hiddenReplies
keybinds = keybinds =
init: -> init: ->
@ -651,8 +651,8 @@ options =
html += "<div><a name=flavors>Flavors</a></div>" html += "<div><a name=flavors>Flavors</a></div>"
html += "<div><textarea style=\"display: none;\" name=flavors>#{$.config('flavors').join '\n'}</textarea></div>" html += "<div><textarea style=\"display: none;\" name=flavors>#{$.config('flavors').join '\n'}</textarea></div>"
hiddenThread = $.getValue "hiddenThread/#{g.BOARD}/", {} hiddenThreads = $.getValue "hiddenThreads/#{g.BOARD}/", {}
hiddenNum = Object.keys(g.hiddenReply).length + Object.keys(hiddenThread).length hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length
html += "<div><input type=\"button\" value=\"hidden: #{hiddenNum}\"></div>" html += "<div><input type=\"button\" value=\"hidden: #{hiddenNum}\"></div>"
html += "<hr>" html += "<hr>"
@ -675,8 +675,8 @@ options =
clearHidden: (e) -> clearHidden: (e) ->
#'hidden' might be misleading; it's the number of IDs we're *looking* for, #'hidden' might be misleading; it's the number of IDs we're *looking* for,
# not the number of posts actually hidden on the page. # not the number of posts actually hidden on the page.
$.deleteValue "hiddenReply/#{g.BOARD}/" $.deleteValue "hiddenReplies/#{g.BOARD}/"
$.deleteValue "hiddenThread/#{g.BOARD}/" $.deleteValue "hiddenThreads/#{g.BOARD}/"
@value = "hidden: 0" @value = "hidden: 0"
g.hiddenReplies = {} g.hiddenReplies = {}
@ -907,7 +907,7 @@ threading =
threadHiding = threadHiding =
init: -> init: ->
hiddenThreads = $.getValue "hiddenThread/#{g.BOARD}/", {} hiddenThreads = $.getValue "hiddenThreads/#{g.BOARD}/", {}
for thread in $$ 'div.thread' for thread in $$ 'div.thread'
op = thread.firstChild op = thread.firstChild
a = $.el 'a', a = $.el 'a',
@ -937,9 +937,9 @@ threadHiding =
id = thread.firstChild.id id = thread.firstChild.id
hiddenThreads = $.getValue "hiddenThread/#{g.BOARD}/", {} hiddenThreads = $.getValue "hiddenThreads/#{g.BOARD}/", {}
hiddenThreads[id] = Date.now() hiddenThreads[id] = Date.now()
$.setValue "hiddenThread/#{g.BOARD}/", hiddenThreads $.setValue "hiddenThreads/#{g.BOARD}/", hiddenThreads
hideHide: (thread) -> hideHide: (thread) ->
if $.config 'Show Stubs' if $.config 'Show Stubs'
@ -974,9 +974,9 @@ threadHiding =
id = thread.firstChild.id id = thread.firstChild.id
hiddenThreads = $.getValue "hiddenThread/#{g.BOARD}/", {} hiddenThreads = $.getValue "hiddenThreads/#{g.BOARD}/", {}
delete hiddenThreads[id] delete hiddenThreads[id]
$.setValue "hiddenThread/#{g.BOARD}/", hiddenThreads $.setValue "hiddenThreads/#{g.BOARD}/", hiddenThreads
updater = updater =
init: -> init: ->
@ -1526,32 +1526,30 @@ main =
g.THREAD_ID = pathname[2] g.THREAD_ID = pathname[2]
else else
g.PAGENUM = parseInt(temp) || 0 g.PAGENUM = parseInt(temp) || 0
g.hiddenReply = $.getValue "hiddenReply/#{g.BOARD}/", {} g.hiddenReplies = $.getValue "hiddenReplies/#{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 = $.getValue 'lastChecked', 0
lastChecked = Number GM_getValue('lastChecked', '0')
now = Date.now() now = Date.now()
DAY = 1000 * 60 * 60 * 24 DAY = 1000 * 60 * 60 * 24
if lastChecked < now - 1*DAY if lastChecked < now - 1*DAY
cutoff = now - 7*DAY cutoff = now - 7*DAY
while g.hiddenThreads.length hiddenThreads = $.getValue "hiddenThreads/#{g.BOARD}/", {}
if g.hiddenThreads[0].timestamp > cutoff
break
g.hiddenThreads.shift()
while g.hiddenReplies.length for id, timestamp of hiddenThreads
if g.hiddenReplies[0].timestamp > cutoff if timestamp < cutoff
break delete hiddenThreads[id]
g.hiddenReplies.shift()
GM_setValue("hiddenThreads/#{g.BOARD}/", JSON.stringify(g.hiddenThreads)) for id, timestamp of g.hiddenReplies
GM_setValue("hiddenReplies/#{g.BOARD}/", JSON.stringify(g.hiddenReplies)) if timestamp < cutoff
GM_setValue('lastChecked', now.toString()) delete g.hiddenReplies[id]
###
$.setValue "hiddenThreads/#{g.BOARD}/", hiddenThreads
$.setValue "hiddenReplies/#{g.BOARD}/", g.hiddenReplies
$.setValue 'lastChecked', now
$.addStyle main.css $.addStyle main.css