Release 4chan X v1.9.3.4.

This commit is contained in:
ccd0 2014-09-18 11:58:57 -07:00
parent 99464b77dd
commit 7221e1b2de
14 changed files with 198 additions and 207 deletions

View File

@ -3,6 +3,12 @@ The attributions below are for work that has been incorporated into the script a
The links to individual versions below are to copies of the script with the update URL removed. If you want automatic updates, install the script from the links on the [main page](https://github.com/ccd0/4chan-x). The links to individual versions below are to copies of the script with the update URL removed. If you want automatic updates, install the script from the links on the [main page](https://github.com/ccd0/4chan-x).
<!-- v1.9.3.x --> <!-- v1.9.3.x -->
### v1.9.3.4
*2014-09-18* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.3.4/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.3.4/builds/4chan-X-noupdate.crx "Chromium version")]
**ccd0**
- Archived thread related bugfixes.
### v1.9.3.3 ### v1.9.3.3
*2014-09-17* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.3.3/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.3.3/builds/4chan-X-noupdate.crx "Chromium version")] *2014-09-17* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.3.3/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.3.3/builds/4chan-X-noupdate.crx "Chromium version")]

View File

@ -1,5 +1,5 @@
/* /*
* 4chan X - Version 1.9.3.3 * 4chan X - Version 1.9.3.4
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X beta // @name 4chan X beta
// @version 1.9.3.3 // @version 1.9.3.4
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript // Generated by CoffeeScript
// ==UserScript== // ==UserScript==
// @name 4chan X beta // @name 4chan X beta
// @version 1.9.3.3 // @version 1.9.3.4
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -24,7 +24,7 @@
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.9.3.3 * 4chan X - Version 1.9.3.4
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -267,7 +267,7 @@
'Current Board': [false, 'Only show watched threads from the current board.'], 'Current Board': [false, 'Only show watched threads from the current board.'],
'Auto Watch': [true, 'Automatically watch threads you start.'], 'Auto Watch': [true, 'Automatically watch threads you start.'],
'Auto Watch Reply': [false, 'Automatically watch threads you reply to.'], 'Auto Watch Reply': [false, 'Automatically watch threads you reply to.'],
'Auto Prune': [false, 'Automatically prune 404\'d threads.'], 'Auto Prune': [false, 'Automatically prune dead threads.'],
'Show Unread Count': [true, 'Show number of unread posts in watched threads.'] 'Show Unread Count': [true, 'Show number of unread posts in watched threads.']
}, },
filter: { filter: {
@ -376,7 +376,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.9.3.3', VERSION: '1.9.3.4',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
NAME: '4chan X', NAME: '4chan X',
FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions', FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions',
@ -1501,7 +1501,7 @@
}; };
DataBoard.prototype.clean = function() { DataBoard.prototype.clean = function() {
var boardID, now, val, _ref; var boardID, now, threadID, val, _ref;
_ref = this.data.boards; _ref = this.data.boards;
for (boardID in _ref) { for (boardID in _ref) {
val = _ref[boardID]; val = _ref[boardID];
@ -1513,44 +1513,29 @@
if ((this.data.lastChecked || 0) < now - 2 * $.HOUR) { if ((this.data.lastChecked || 0) < now - 2 * $.HOUR) {
this.data.lastChecked = now; this.data.lastChecked = now;
for (boardID in this.data.boards) { for (boardID in this.data.boards) {
this.ajaxClean(boardID); for (threadID in this.data.boards[boardID]) {
this.ajaxClean(boardID, threadID);
}
} }
} }
return this.save(); return this.save();
}; };
DataBoard.prototype.ajaxClean = function(boardID) { DataBoard.prototype.ajaxClean = function(boardID, threadID) {
return $.cache("//a.4cdn.org/" + boardID + "/threads.json", (function(_this) { return $.ajax("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", {
return function(e) { onloadend: (function(_this) {
var board, page, thread, threads, _i, _j, _len, _len1, _ref, _ref1; return function(e) {
if (e.target.status !== 200) {
if (e.target.status === 404) { if (e.target.status === 404) {
_this["delete"]({ return _this["delete"]({
boardID: boardID boardID: boardID,
threadID: threadID
}); });
} }
return; };
} })(this)
board = _this.data.boards[boardID]; }, {
threads = {}; type: 'head'
_ref = e.target.response; });
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
page = _ref[_i];
_ref1 = page.threads;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
thread = _ref1[_j];
if (thread.no in board) {
threads[thread.no] = board[thread.no];
}
}
}
_this.data.boards[boardID] = threads;
_this.deleteIfEmpty({
boardID: boardID
});
return _this.save();
};
})(this));
}; };
DataBoard.prototype.onSync = function(data) { DataBoard.prototype.onSync = function(data) {
@ -5971,7 +5956,12 @@
} }
}, },
statusCheck: function() { statusCheck: function() {
if (g.DEAD) { var thread;
if (!QR.nodes) {
return;
}
thread = QR.posts[0].thread;
if (thread !== 'new' && g.threads["" + g.BOARD + "." + thread].isDead) {
return QR.abort(); return QR.abort();
} else { } else {
return QR.status(); return QR.status();
@ -10129,7 +10119,7 @@
$.on(window, 'online offline', ThreadUpdater.cb.online); $.on(window, 'online offline', ThreadUpdater.cb.online);
$.on(d, 'QRPostSuccessful', ThreadUpdater.cb.checkpost); $.on(d, 'QRPostSuccessful', ThreadUpdater.cb.checkpost);
$.on(d, 'visibilitychange', ThreadUpdater.cb.visibility); $.on(d, 'visibilitychange', ThreadUpdater.cb.visibility);
if (g.DEAD) { if (ThreadUpdater.thread.isArchived) {
return ThreadUpdater.set('status', 'Archived', 'warning'); return ThreadUpdater.set('status', 'Archived', 'warning');
} else { } else {
return ThreadUpdater.cb.online(); return ThreadUpdater.cb.online();
@ -10143,7 +10133,7 @@
beep: 'data:audio/wav;base64,UklGRjQDAABXQVZFZm10IBAAAAABAAEAgD4AAIA+AAABAAgAc21wbDwAAABBAAADAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABkYXRhzAIAAGMms8em0tleMV4zIpLVo8nhfSlcPR102Ki+5JspVEkdVtKzs+K1NEhUIT7DwKrcy0g6WygsrM2k1NpiLl0zIY/WpMrjgCdbPhxw2Kq+5Z4qUkkdU9K1s+K5NkVTITzBwqnczko3WikrqM+l1NxlLF0zIIvXpsnjgydZPhxs2ay95aIrUEkdUdC3suK8N0NUIjq+xKrcz002WioppdGm091pK1w0IIjYp8jkhydXPxxq2K295aUrTkoeTs65suK+OUFUIzi7xqrb0VA0WSoootKm0t5tKlo1H4TYqMfkiydWQBxm16+85actTEseS8y7seHAPD9TIza5yKra01QyWSson9On0d5wKVk2H4DYqcfkjidUQB1j1rG75KsvSkseScu8seDCPz1TJDW2yara1FYxWSwnm9Sn0N9zKVg2H33ZqsXkkihSQR1g1bK65K0wSEsfR8i+seDEQTxUJTOzy6rY1VowWC0mmNWoz993KVc3H3rYq8TklSlRQh1d1LS647AyR0wgRMbAsN/GRDpTJTKwzKrX1l4vVy4lldWpzt97KVY4IXbUr8LZljVPRCxhw7W3z6ZISkw1VK+4sMWvXEhSPk6buay9sm5JVkZNiLWqtrJ+TldNTnquqbCwilZXU1BwpKirrpNgWFhTaZmnpquZbFlbVmWO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TaZmnpquZbFlbVmWOpaOonHZcXlljhaGhpZ1+YWBdYn2cn6GdhmdhYGN3lp2enIttY2Jjco+bnJuOdGZlZXCImJqakHpoZ2Zug5WYmZJ/bGlobX6RlpeSg3BqaW16jZSVkoZ0bGtteImSk5KIeG5tbnaFkJKRinxxbm91gY2QkIt/c3BwdH6Kj4+LgnZxcXR8iI2OjIR5c3J0e4WLjYuFe3VzdHmCioyLhn52dHR5gIiKioeAeHV1eH+GiYqHgXp2dnh9hIiJh4J8eHd4fIKHiIeDfXl4eHyBhoeHhH96eHmA',
cb: { cb: {
online: function() { online: function() {
if (g.DEAD) { if (ThreadUpdater.thread.isDead) {
return; return;
} }
if (ThreadUpdater.online = navigator.onLine) { if (ThreadUpdater.online = navigator.onLine) {
@ -10173,7 +10163,7 @@
ThreadUpdater.outdateCount = 0; ThreadUpdater.outdateCount = 0;
ThreadUpdater.set('timer', '...'); ThreadUpdater.set('timer', '...');
} }
if (!(g.DEAD || ThreadUpdater.foundPost || ThreadUpdater.checkPostCount >= 5)) { if (!(ThreadUpdater.thread.isDead || ThreadUpdater.foundPost || ThreadUpdater.checkPostCount >= 5)) {
return setTimeout(ThreadUpdater.update, ++ThreadUpdater.checkPostCount * $.SECOND); return setTimeout(ThreadUpdater.update, ++ThreadUpdater.checkPostCount * $.SECOND);
} }
ThreadUpdater.setInterval(); ThreadUpdater.setInterval();
@ -10211,9 +10201,9 @@
req = ThreadUpdater.req; req = ThreadUpdater.req;
switch (req.status) { switch (req.status) {
case 200: case 200:
g.DEAD = !!+req.response.posts[0].archived;
ThreadUpdater.parse(req.response.posts); ThreadUpdater.parse(req.response.posts);
if (g.DEAD) { if (!!req.response.posts[0].archived) {
ThreadUpdater.thread.isArchived = true;
ThreadUpdater.set('status', 'Archived', 'warning'); ThreadUpdater.set('status', 'Archived', 'warning');
ThreadUpdater.kill(); ThreadUpdater.kill();
} else { } else {
@ -10242,7 +10232,6 @@
confirmed = false; confirmed = false;
} }
if (confirmed) { if (confirmed) {
g.DEAD = true;
ThreadUpdater.set('status', '404', 'warning'); ThreadUpdater.set('status', '404', 'warning');
return ThreadUpdater.kill(); return ThreadUpdater.kill();
} else { } else {
@ -10601,7 +10590,6 @@
}); });
} else { } else {
data.isDead = true; data.isDead = true;
delete data.unread;
ThreadWatcher.db.set({ ThreadWatcher.db.set({
boardID: boardID, boardID: boardID,
threadID: threadID, threadID: threadID,
@ -10641,7 +10629,7 @@
fetchStatus: function(_arg) { fetchStatus: function(_arg) {
var boardID, data, fetchCount, threadID; var boardID, data, fetchCount, threadID;
boardID = _arg.boardID, threadID = _arg.threadID, data = _arg.data; boardID = _arg.boardID, threadID = _arg.threadID, data = _arg.data;
if (data.isDead) { if (data.isDead && !Conf['Show Unread Count']) {
return; return;
} }
fetchCount = ThreadWatcher.fetchCount; fetchCount = ThreadWatcher.fetchCount;
@ -10652,7 +10640,7 @@
fetchCount.fetching++; fetchCount.fetching++;
return $.ajax("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", { return $.ajax("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", {
onloadend: function() { onloadend: function() {
var lastReadPost, postObj, status, unread, _i, _len, _ref, _ref1; var isDead, lastReadPost, postObj, status, unread, _i, _len, _ref, _ref1;
fetchCount.fetched++; fetchCount.fetched++;
if (fetchCount.fetched === fetchCount.fetching) { if (fetchCount.fetched === fetchCount.fetching) {
fetchCount.fetched = 0; fetchCount.fetched = 0;
@ -10664,6 +10652,15 @@
} }
ThreadWatcher.status.textContent = status; ThreadWatcher.status.textContent = status;
if (this.status === 200 && this.response) { if (this.status === 200 && this.response) {
isDead = !!this.response.posts[0].archived;
if (isDead && Conf['Auto Prune']) {
ThreadWatcher.db["delete"]({
boardID: boardID,
threadID: threadID
});
ThreadWatcher.refresh();
return;
}
lastReadPost = ThreadWatcher.unreaddb.get({ lastReadPost = ThreadWatcher.unreaddb.get({
boardID: boardID, boardID: boardID,
threadID: threadID, threadID: threadID,
@ -10681,7 +10678,8 @@
unread++; unread++;
} }
} }
if (unread !== data.unread) { if (isDead !== data.isDead || unread !== data.unread) {
data.isDead = isDead;
data.unread = unread; data.unread = unread;
ThreadWatcher.db.set({ ThreadWatcher.db.set({
boardID: boardID, boardID: boardID,
@ -10708,8 +10706,6 @@
return ThreadWatcher.refresh(); return ThreadWatcher.refresh();
} }
} }
}, {
type: Conf['Show Unread Count'] ? 'get' : 'head'
}); });
}, },
getAll: function() { getAll: function() {
@ -10733,7 +10729,7 @@
return all; return all;
}, },
makeLine: function(boardID, threadID, data) { makeLine: function(boardID, threadID, data) {
var count, div, fullID, href, link, title, x; var count, div, fullID, link, title, x;
x = $.el('a', { x = $.el('a', {
className: 'fa fa-times', className: 'fa fa-times',
href: 'javascript:;' href: 'javascript:;'
@ -10747,14 +10743,8 @@
textContent: Conf['Show Unread Count'] && (data.unread != null) ? "\u00A0(" + data.unread + ")" : '', textContent: Conf['Show Unread Count'] && (data.unread != null) ? "\u00A0(" + data.unread + ")" : '',
className: 'watcher-unread' className: 'watcher-unread'
}); });
if (Conf['404 Redirect'] && data.isDead) {
href = Redirect.to('thread', {
boardID: boardID,
threadID: threadID
});
}
link = $.el('a', { link = $.el('a', {
href: href || ("/" + boardID + "/thread/" + threadID), href: "/" + boardID + "/thread/" + threadID,
title: data.excerpt, title: data.excerpt,
className: 'watcher-link' className: 'watcher-link'
}); });
@ -10837,7 +10827,7 @@
val: data val: data
}); });
ThreadWatcher.refresh(); ThreadWatcher.refresh();
if (Conf['Show Unread Count'] && !data.isDead) { if (Conf['Show Unread Count']) {
return ThreadWatcher.fetchStatus({ return ThreadWatcher.fetchStatus({
boardID: boardID, boardID: boardID,
threadID: threadID, threadID: threadID,
@ -10921,7 +10911,7 @@
cb: ThreadWatcher.cb.pruneDeads, cb: ThreadWatcher.cb.pruneDeads,
entry: { entry: {
el: $.el('a', { el: $.el('a', {
textContent: 'Prune 404\'d threads' textContent: 'Prune dead threads'
}) })
}, },
refresh: function() { refresh: function() {
@ -11202,7 +11192,7 @@
} }
}), }),
saveLastReadPost: $.debounce(2 * $.SECOND, function() { saveLastReadPost: $.debounce(2 * $.SECOND, function() {
if (Unread.thread.isDead) { if (Unread.thread.isDead && !Unread.thread.isArchived) {
return; return;
} }
return Unread.db.set({ return Unread.db.set({
@ -11224,16 +11214,19 @@
} }
}, },
update: function() { update: function() {
var count, countQuotingYou; var count, countQuotingYou, titleCount, titleDead, titleQuotingYou;
count = Unread.posts.length; count = Unread.posts.length;
countQuotingYou = Object.keys(Unread.postsQuotingYou).length; countQuotingYou = Object.keys(Unread.postsQuotingYou).length;
if (Conf['Unread Count']) { if (Conf['Unread Count']) {
d.title = "" + (Conf['Quoted Title'] && countQuotingYou ? '(!) ' : '') + (count || !Conf['Hide Unread Count at (0)'] ? "(" + count + ") " : '') + (g.DEAD ? Unread.title.replace('-', '- 404 -') : Unread.title); titleQuotingYou = Conf['Quoted Title'] && countQuotingYou ? '(!) ' : '';
titleCount = count || !Conf['Hide Unread Count at (0)'] ? "(" + count + ") " : '';
titleDead = Unread.thread.isDead ? Unread.title.replace('-', (Unread.thread.isArchived ? '- Archived -' : '- 404 -')) : Unread.title;
d.title = "" + titleQuotingYou + titleCount + titleDead;
} }
if (!Conf['Unread Favicon']) { if (!Conf['Unread Favicon']) {
return; return;
} }
Favicon.el.href = g.DEAD ? countQuotingYou ? Favicon.unreadDeadY : count ? Favicon.unreadDead : Favicon.dead : count ? countQuotingYou ? Favicon.unreadY : Favicon.unread : Favicon["default"]; Favicon.el.href = Unread.thread.isDead ? countQuotingYou ? Favicon.unreadDeadY : count ? Favicon.unreadDead : Favicon.dead : count ? countQuotingYou ? Favicon.unreadY : Favicon.unread : Favicon["default"];
return $.add(d.head, Favicon.el); return $.add(d.head, Favicon.el);
} }
}; };
@ -12884,7 +12877,7 @@
className: 'dialog' className: 'dialog'
}); });
$.extend(dialog, { $.extend(dialog, {
innerHTML: "<nav><div class=sections-list></div><p class='imp-exp-result warning'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href='https://github.com/ccd0/4chan-x' target=_blank>4chan X</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md' target=_blank>1.9.3.3</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/issues' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class='close fa fa-times' title=Close></a></div></nav><div class=section-container><section></section></div>" innerHTML: "<nav><div class=sections-list></div><p class='imp-exp-result warning'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href='https://github.com/ccd0/4chan-x' target=_blank>4chan X</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md' target=_blank>1.9.3.4</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/issues' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class='close fa fa-times' title=Close></a></div></nav><div class=section-container><section></section></div>"
}); });
$.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.export', Settings.dialog), 'click', Settings["export"]);
$.on($('.import', Settings.dialog), 'click', Settings["import"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]);
@ -13693,14 +13686,16 @@
}, },
initThread: function() { initThread: function() {
var board, err, errors, postRoot, posts, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1, _ref2; var board, err, errors, postRoot, posts, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1, _ref2;
g.DEAD = !!((_ref = $('.closed')) != null ? _ref.textContent.match(/Thread archived/) : void 0);
if (board = $('.board')) { if (board = $('.board')) {
threads = []; threads = [];
posts = []; posts = [];
_ref1 = $$('.board > .thread', board); _ref = $$('.board > .thread', board);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
threadRoot = _ref1[_i]; threadRoot = _ref[_i];
thread = new Thread(+threadRoot.id.slice(1), g.BOARD); thread = new Thread(+threadRoot.id.slice(1), g.BOARD);
if (g.VIEW === 'thread') {
thread.isDead = thread.isArchived = !!((_ref1 = $('.closed')) != null ? _ref1.textContent.match(/Thread archived/) : void 0);
}
threads.push(thread); threads.push(thread);
_ref2 = $$('.thread > .postContainer', threadRoot); _ref2 = $$('.thread > .postContainer', threadRoot);
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {

Binary file not shown.

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript // Generated by CoffeeScript
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.9.3.3 // @version 1.9.3.4
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -23,7 +23,7 @@
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.9.3.3 * 4chan X - Version 1.9.3.4
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -266,7 +266,7 @@
'Current Board': [false, 'Only show watched threads from the current board.'], 'Current Board': [false, 'Only show watched threads from the current board.'],
'Auto Watch': [true, 'Automatically watch threads you start.'], 'Auto Watch': [true, 'Automatically watch threads you start.'],
'Auto Watch Reply': [false, 'Automatically watch threads you reply to.'], 'Auto Watch Reply': [false, 'Automatically watch threads you reply to.'],
'Auto Prune': [false, 'Automatically prune 404\'d threads.'], 'Auto Prune': [false, 'Automatically prune dead threads.'],
'Show Unread Count': [true, 'Show number of unread posts in watched threads.'] 'Show Unread Count': [true, 'Show number of unread posts in watched threads.']
}, },
filter: { filter: {
@ -375,7 +375,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.9.3.3', VERSION: '1.9.3.4',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
NAME: '4chan X', NAME: '4chan X',
FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions', FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions',
@ -1500,7 +1500,7 @@
}; };
DataBoard.prototype.clean = function() { DataBoard.prototype.clean = function() {
var boardID, now, val, _ref; var boardID, now, threadID, val, _ref;
_ref = this.data.boards; _ref = this.data.boards;
for (boardID in _ref) { for (boardID in _ref) {
val = _ref[boardID]; val = _ref[boardID];
@ -1512,44 +1512,29 @@
if ((this.data.lastChecked || 0) < now - 2 * $.HOUR) { if ((this.data.lastChecked || 0) < now - 2 * $.HOUR) {
this.data.lastChecked = now; this.data.lastChecked = now;
for (boardID in this.data.boards) { for (boardID in this.data.boards) {
this.ajaxClean(boardID); for (threadID in this.data.boards[boardID]) {
this.ajaxClean(boardID, threadID);
}
} }
} }
return this.save(); return this.save();
}; };
DataBoard.prototype.ajaxClean = function(boardID) { DataBoard.prototype.ajaxClean = function(boardID, threadID) {
return $.cache("//a.4cdn.org/" + boardID + "/threads.json", (function(_this) { return $.ajax("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", {
return function(e) { onloadend: (function(_this) {
var board, page, thread, threads, _i, _j, _len, _len1, _ref, _ref1; return function(e) {
if (e.target.status !== 200) {
if (e.target.status === 404) { if (e.target.status === 404) {
_this["delete"]({ return _this["delete"]({
boardID: boardID boardID: boardID,
threadID: threadID
}); });
} }
return; };
} })(this)
board = _this.data.boards[boardID]; }, {
threads = {}; type: 'head'
_ref = e.target.response; });
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
page = _ref[_i];
_ref1 = page.threads;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
thread = _ref1[_j];
if (thread.no in board) {
threads[thread.no] = board[thread.no];
}
}
}
_this.data.boards[boardID] = threads;
_this.deleteIfEmpty({
boardID: boardID
});
return _this.save();
};
})(this));
}; };
DataBoard.prototype.onSync = function(data) { DataBoard.prototype.onSync = function(data) {
@ -5970,7 +5955,12 @@
} }
}, },
statusCheck: function() { statusCheck: function() {
if (g.DEAD) { var thread;
if (!QR.nodes) {
return;
}
thread = QR.posts[0].thread;
if (thread !== 'new' && g.threads["" + g.BOARD + "." + thread].isDead) {
return QR.abort(); return QR.abort();
} else { } else {
return QR.status(); return QR.status();
@ -10128,7 +10118,7 @@
$.on(window, 'online offline', ThreadUpdater.cb.online); $.on(window, 'online offline', ThreadUpdater.cb.online);
$.on(d, 'QRPostSuccessful', ThreadUpdater.cb.checkpost); $.on(d, 'QRPostSuccessful', ThreadUpdater.cb.checkpost);
$.on(d, 'visibilitychange', ThreadUpdater.cb.visibility); $.on(d, 'visibilitychange', ThreadUpdater.cb.visibility);
if (g.DEAD) { if (ThreadUpdater.thread.isArchived) {
return ThreadUpdater.set('status', 'Archived', 'warning'); return ThreadUpdater.set('status', 'Archived', 'warning');
} else { } else {
return ThreadUpdater.cb.online(); return ThreadUpdater.cb.online();
@ -10142,7 +10132,7 @@
beep: 'data:audio/wav;base64,UklGRjQDAABXQVZFZm10IBAAAAABAAEAgD4AAIA+AAABAAgAc21wbDwAAABBAAADAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABkYXRhzAIAAGMms8em0tleMV4zIpLVo8nhfSlcPR102Ki+5JspVEkdVtKzs+K1NEhUIT7DwKrcy0g6WygsrM2k1NpiLl0zIY/WpMrjgCdbPhxw2Kq+5Z4qUkkdU9K1s+K5NkVTITzBwqnczko3WikrqM+l1NxlLF0zIIvXpsnjgydZPhxs2ay95aIrUEkdUdC3suK8N0NUIjq+xKrcz002WioppdGm091pK1w0IIjYp8jkhydXPxxq2K295aUrTkoeTs65suK+OUFUIzi7xqrb0VA0WSoootKm0t5tKlo1H4TYqMfkiydWQBxm16+85actTEseS8y7seHAPD9TIza5yKra01QyWSson9On0d5wKVk2H4DYqc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9On0d5wKVk2H4DYqcfkjidUQB1j1rG75KsvSkseScu8seDCPz1TJDW2yara1FYxWSwnm9Sn0N9zKVg2H33ZqsXkkihSQR1g1bK65K0wSEsfR8i+seDEQTxUJTOzy6rY1VowWC0mmNWoz993KVc3H3rYq8TklSlRQh1d1LS647AyR0wgRMbAsN/GRDpTJTKwzKrX1l4vVy4lldWpzt97KVY4IXbUr8LZljVPRCxhw7W3z6ZISkw1VK+4sMWvXEhSPk6buay9sm5JVkZNiLWqtrJ+TldNTnquqbCwilZXU1BwpKirrpNgWFhTaZmnpquZbFlbVmWOpaOonHZcXlljhaGhpZ1+YWBdYn2cn6GdhmdhYGN3lp2enIttY2Jjco+bnJuOdGZlZXCImJqakHpoZ2Zug5WYmZJ/bGlobX6RlpeSg3BqaW16jZSVkoZ0bGtteImSk5KIeG5tbnaFkJKRinxxbm91gY2QkIt/c3BwdH6Kj4+LgnZxcXR8iI2OjIR5c3J0e4WLjYuFe3VzdHmCioyLhn52dHR5gIiKioeAeHV1eH+GiYqHgXp2dnh9hIiJh4J8eHd4fIKHiIeDfXl4eHyBhoeHhH96eHmA',
cb: { cb: {
online: function() { online: function() {
if (g.DEAD) { if (ThreadUpdater.thread.isDead) {
return; return;
} }
if (ThreadUpdater.online = navigator.onLine) { if (ThreadUpdater.online = navigator.onLine) {
@ -10172,7 +10162,7 @@
ThreadUpdater.outdateCount = 0; ThreadUpdater.outdateCount = 0;
ThreadUpdater.set('timer', '...'); ThreadUpdater.set('timer', '...');
} }
if (!(g.DEAD || ThreadUpdater.foundPost || ThreadUpdater.checkPostCount >= 5)) { if (!(ThreadUpdater.thread.isDead || ThreadUpdater.foundPost || ThreadUpdater.checkPostCount >= 5)) {
return setTimeout(ThreadUpdater.update, ++ThreadUpdater.checkPostCount * $.SECOND); return setTimeout(ThreadUpdater.update, ++ThreadUpdater.checkPostCount * $.SECOND);
} }
ThreadUpdater.setInterval(); ThreadUpdater.setInterval();
@ -10210,9 +10200,9 @@
req = ThreadUpdater.req; req = ThreadUpdater.req;
switch (req.status) { switch (req.status) {
case 200: case 200:
g.DEAD = !!+req.response.posts[0].archived;
ThreadUpdater.parse(req.response.posts); ThreadUpdater.parse(req.response.posts);
if (g.DEAD) { if (!!req.response.posts[0].archived) {
ThreadUpdater.thread.isArchived = true;
ThreadUpdater.set('status', 'Archived', 'warning'); ThreadUpdater.set('status', 'Archived', 'warning');
ThreadUpdater.kill(); ThreadUpdater.kill();
} else { } else {
@ -10241,7 +10231,6 @@
confirmed = false; confirmed = false;
} }
if (confirmed) { if (confirmed) {
g.DEAD = true;
ThreadUpdater.set('status', '404', 'warning'); ThreadUpdater.set('status', '404', 'warning');
return ThreadUpdater.kill(); return ThreadUpdater.kill();
} else { } else {
@ -10600,7 +10589,6 @@
}); });
} else { } else {
data.isDead = true; data.isDead = true;
delete data.unread;
ThreadWatcher.db.set({ ThreadWatcher.db.set({
boardID: boardID, boardID: boardID,
threadID: threadID, threadID: threadID,
@ -10640,7 +10628,7 @@
fetchStatus: function(_arg) { fetchStatus: function(_arg) {
var boardID, data, fetchCount, threadID; var boardID, data, fetchCount, threadID;
boardID = _arg.boardID, threadID = _arg.threadID, data = _arg.data; boardID = _arg.boardID, threadID = _arg.threadID, data = _arg.data;
if (data.isDead) { if (data.isDead && !Conf['Show Unread Count']) {
return; return;
} }
fetchCount = ThreadWatcher.fetchCount; fetchCount = ThreadWatcher.fetchCount;
@ -10651,7 +10639,7 @@
fetchCount.fetching++; fetchCount.fetching++;
return $.ajax("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", { return $.ajax("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", {
onloadend: function() { onloadend: function() {
var lastReadPost, postObj, status, unread, _i, _len, _ref, _ref1; var isDead, lastReadPost, postObj, status, unread, _i, _len, _ref, _ref1;
fetchCount.fetched++; fetchCount.fetched++;
if (fetchCount.fetched === fetchCount.fetching) { if (fetchCount.fetched === fetchCount.fetching) {
fetchCount.fetched = 0; fetchCount.fetched = 0;
@ -10663,6 +10651,15 @@
} }
ThreadWatcher.status.textContent = status; ThreadWatcher.status.textContent = status;
if (this.status === 200 && this.response) { if (this.status === 200 && this.response) {
isDead = !!this.response.posts[0].archived;
if (isDead && Conf['Auto Prune']) {
ThreadWatcher.db["delete"]({
boardID: boardID,
threadID: threadID
});
ThreadWatcher.refresh();
return;
}
lastReadPost = ThreadWatcher.unreaddb.get({ lastReadPost = ThreadWatcher.unreaddb.get({
boardID: boardID, boardID: boardID,
threadID: threadID, threadID: threadID,
@ -10680,7 +10677,8 @@
unread++; unread++;
} }
} }
if (unread !== data.unread) { if (isDead !== data.isDead || unread !== data.unread) {
data.isDead = isDead;
data.unread = unread; data.unread = unread;
ThreadWatcher.db.set({ ThreadWatcher.db.set({
boardID: boardID, boardID: boardID,
@ -10707,8 +10705,6 @@
return ThreadWatcher.refresh(); return ThreadWatcher.refresh();
} }
} }
}, {
type: Conf['Show Unread Count'] ? 'get' : 'head'
}); });
}, },
getAll: function() { getAll: function() {
@ -10732,7 +10728,7 @@
return all; return all;
}, },
makeLine: function(boardID, threadID, data) { makeLine: function(boardID, threadID, data) {
var count, div, fullID, href, link, title, x; var count, div, fullID, link, title, x;
x = $.el('a', { x = $.el('a', {
className: 'fa fa-times', className: 'fa fa-times',
href: 'javascript:;' href: 'javascript:;'
@ -10746,14 +10742,8 @@
textContent: Conf['Show Unread Count'] && (data.unread != null) ? "\u00A0(" + data.unread + ")" : '', textContent: Conf['Show Unread Count'] && (data.unread != null) ? "\u00A0(" + data.unread + ")" : '',
className: 'watcher-unread' className: 'watcher-unread'
}); });
if (Conf['404 Redirect'] && data.isDead) {
href = Redirect.to('thread', {
boardID: boardID,
threadID: threadID
});
}
link = $.el('a', { link = $.el('a', {
href: href || ("/" + boardID + "/thread/" + threadID), href: "/" + boardID + "/thread/" + threadID,
title: data.excerpt, title: data.excerpt,
className: 'watcher-link' className: 'watcher-link'
}); });
@ -10836,7 +10826,7 @@
val: data val: data
}); });
ThreadWatcher.refresh(); ThreadWatcher.refresh();
if (Conf['Show Unread Count'] && !data.isDead) { if (Conf['Show Unread Count']) {
return ThreadWatcher.fetchStatus({ return ThreadWatcher.fetchStatus({
boardID: boardID, boardID: boardID,
threadID: threadID, threadID: threadID,
@ -10920,7 +10910,7 @@
cb: ThreadWatcher.cb.pruneDeads, cb: ThreadWatcher.cb.pruneDeads,
entry: { entry: {
el: $.el('a', { el: $.el('a', {
textContent: 'Prune 404\'d threads' textContent: 'Prune dead threads'
}) })
}, },
refresh: function() { refresh: function() {
@ -11201,7 +11191,7 @@
} }
}), }),
saveLastReadPost: $.debounce(2 * $.SECOND, function() { saveLastReadPost: $.debounce(2 * $.SECOND, function() {
if (Unread.thread.isDead) { if (Unread.thread.isDead && !Unread.thread.isArchived) {
return; return;
} }
return Unread.db.set({ return Unread.db.set({
@ -11223,16 +11213,19 @@
} }
}, },
update: function() { update: function() {
var count, countQuotingYou; var count, countQuotingYou, titleCount, titleDead, titleQuotingYou;
count = Unread.posts.length; count = Unread.posts.length;
countQuotingYou = Object.keys(Unread.postsQuotingYou).length; countQuotingYou = Object.keys(Unread.postsQuotingYou).length;
if (Conf['Unread Count']) { if (Conf['Unread Count']) {
d.title = "" + (Conf['Quoted Title'] && countQuotingYou ? '(!) ' : '') + (count || !Conf['Hide Unread Count at (0)'] ? "(" + count + ") " : '') + (g.DEAD ? Unread.title.replace('-', '- 404 -') : Unread.title); titleQuotingYou = Conf['Quoted Title'] && countQuotingYou ? '(!) ' : '';
titleCount = count || !Conf['Hide Unread Count at (0)'] ? "(" + count + ") " : '';
titleDead = Unread.thread.isDead ? Unread.title.replace('-', (Unread.thread.isArchived ? '- Archived -' : '- 404 -')) : Unread.title;
d.title = "" + titleQuotingYou + titleCount + titleDead;
} }
if (!Conf['Unread Favicon']) { if (!Conf['Unread Favicon']) {
return; return;
} }
Favicon.el.href = g.DEAD ? countQuotingYou ? Favicon.unreadDeadY : count ? Favicon.unreadDead : Favicon.dead : count ? countQuotingYou ? Favicon.unreadY : Favicon.unread : Favicon["default"]; Favicon.el.href = Unread.thread.isDead ? countQuotingYou ? Favicon.unreadDeadY : count ? Favicon.unreadDead : Favicon.dead : count ? countQuotingYou ? Favicon.unreadY : Favicon.unread : Favicon["default"];
return $.add(d.head, Favicon.el); return $.add(d.head, Favicon.el);
} }
}; };
@ -12883,7 +12876,7 @@
className: 'dialog' className: 'dialog'
}); });
$.extend(dialog, { $.extend(dialog, {
innerHTML: "<nav><div class=sections-list></div><p class='imp-exp-result warning'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href='https://github.com/ccd0/4chan-x' target=_blank>4chan X</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md' target=_blank>1.9.3.3</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/issues' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class='close fa fa-times' title=Close></a></div></nav><div class=section-container><section></section></div>" innerHTML: "<nav><div class=sections-list></div><p class='imp-exp-result warning'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href='https://github.com/ccd0/4chan-x' target=_blank>4chan X</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md' target=_blank>1.9.3.4</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/issues' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class='close fa fa-times' title=Close></a></div></nav><div class=section-container><section></section></div>"
}); });
$.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.export', Settings.dialog), 'click', Settings["export"]);
$.on($('.import', Settings.dialog), 'click', Settings["import"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]);
@ -13692,14 +13685,16 @@
}, },
initThread: function() { initThread: function() {
var board, err, errors, postRoot, posts, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1, _ref2; var board, err, errors, postRoot, posts, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1, _ref2;
g.DEAD = !!((_ref = $('.closed')) != null ? _ref.textContent.match(/Thread archived/) : void 0);
if (board = $('.board')) { if (board = $('.board')) {
threads = []; threads = [];
posts = []; posts = [];
_ref1 = $$('.board > .thread', board); _ref = $$('.board > .thread', board);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
threadRoot = _ref1[_i]; threadRoot = _ref[_i];
thread = new Thread(+threadRoot.id.slice(1), g.BOARD); thread = new Thread(+threadRoot.id.slice(1), g.BOARD);
if (g.VIEW === 'thread') {
thread.isDead = thread.isArchived = !!((_ref1 = $('.closed')) != null ? _ref1.textContent.match(/Thread archived/) : void 0);
}
threads.push(thread); threads.push(thread);
_ref2 = $$('.thread > .postContainer', threadRoot); _ref2 = $$('.thread > .postContainer', threadRoot);
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.9.3.3 // @version 1.9.3.4
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript // Generated by CoffeeScript
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.9.3.3 // @version 1.9.3.4
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -24,7 +24,7 @@
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.9.3.3 * 4chan X - Version 1.9.3.4
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -267,7 +267,7 @@
'Current Board': [false, 'Only show watched threads from the current board.'], 'Current Board': [false, 'Only show watched threads from the current board.'],
'Auto Watch': [true, 'Automatically watch threads you start.'], 'Auto Watch': [true, 'Automatically watch threads you start.'],
'Auto Watch Reply': [false, 'Automatically watch threads you reply to.'], 'Auto Watch Reply': [false, 'Automatically watch threads you reply to.'],
'Auto Prune': [false, 'Automatically prune 404\'d threads.'], 'Auto Prune': [false, 'Automatically prune dead threads.'],
'Show Unread Count': [true, 'Show number of unread posts in watched threads.'] 'Show Unread Count': [true, 'Show number of unread posts in watched threads.']
}, },
filter: { filter: {
@ -376,7 +376,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.9.3.3', VERSION: '1.9.3.4',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
NAME: '4chan X', NAME: '4chan X',
FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions', FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions',
@ -1501,7 +1501,7 @@
}; };
DataBoard.prototype.clean = function() { DataBoard.prototype.clean = function() {
var boardID, now, val, _ref; var boardID, now, threadID, val, _ref;
_ref = this.data.boards; _ref = this.data.boards;
for (boardID in _ref) { for (boardID in _ref) {
val = _ref[boardID]; val = _ref[boardID];
@ -1513,44 +1513,29 @@
if ((this.data.lastChecked || 0) < now - 2 * $.HOUR) { if ((this.data.lastChecked || 0) < now - 2 * $.HOUR) {
this.data.lastChecked = now; this.data.lastChecked = now;
for (boardID in this.data.boards) { for (boardID in this.data.boards) {
this.ajaxClean(boardID); for (threadID in this.data.boards[boardID]) {
this.ajaxClean(boardID, threadID);
}
} }
} }
return this.save(); return this.save();
}; };
DataBoard.prototype.ajaxClean = function(boardID) { DataBoard.prototype.ajaxClean = function(boardID, threadID) {
return $.cache("//a.4cdn.org/" + boardID + "/threads.json", (function(_this) { return $.ajax("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", {
return function(e) { onloadend: (function(_this) {
var board, page, thread, threads, _i, _j, _len, _len1, _ref, _ref1; return function(e) {
if (e.target.status !== 200) {
if (e.target.status === 404) { if (e.target.status === 404) {
_this["delete"]({ return _this["delete"]({
boardID: boardID boardID: boardID,
threadID: threadID
}); });
} }
return; };
} })(this)
board = _this.data.boards[boardID]; }, {
threads = {}; type: 'head'
_ref = e.target.response; });
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
page = _ref[_i];
_ref1 = page.threads;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
thread = _ref1[_j];
if (thread.no in board) {
threads[thread.no] = board[thread.no];
}
}
}
_this.data.boards[boardID] = threads;
_this.deleteIfEmpty({
boardID: boardID
});
return _this.save();
};
})(this));
}; };
DataBoard.prototype.onSync = function(data) { DataBoard.prototype.onSync = function(data) {
@ -5971,7 +5956,12 @@
} }
}, },
statusCheck: function() { statusCheck: function() {
if (g.DEAD) { var thread;
if (!QR.nodes) {
return;
}
thread = QR.posts[0].thread;
if (thread !== 'new' && g.threads["" + g.BOARD + "." + thread].isDead) {
return QR.abort(); return QR.abort();
} else { } else {
return QR.status(); return QR.status();
@ -10129,7 +10119,7 @@
$.on(window, 'online offline', ThreadUpdater.cb.online); $.on(window, 'online offline', ThreadUpdater.cb.online);
$.on(d, 'QRPostSuccessful', ThreadUpdater.cb.checkpost); $.on(d, 'QRPostSuccessful', ThreadUpdater.cb.checkpost);
$.on(d, 'visibilitychange', ThreadUpdater.cb.visibility); $.on(d, 'visibilitychange', ThreadUpdater.cb.visibility);
if (g.DEAD) { if (ThreadUpdater.thread.isArchived) {
return ThreadUpdater.set('status', 'Archived', 'warning'); return ThreadUpdater.set('status', 'Archived', 'warning');
} else { } else {
return ThreadUpdater.cb.online(); return ThreadUpdater.cb.online();
@ -10143,7 +10133,7 @@
beep: 'data:audio/wav;base64,UklGRjQDAABXQVZFZm10IBAAAAABAAEAgD4AAIA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AAAAABAAEAgD4AAIA+AAABAAgAc21wbDwAAABBAAADAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABkYXRhzAIAAGMms8em0tleMV4zIpLVo8nhfSlcPR102Ki+5JspVEkdVtKzs+K1NEhUIT7DwKrcy0g6WygsrM2k1NpiLl0zIY/WpMrjgCdbPhxw2Kq+5Z4qUkkdU9K1s+K5NkVTITzBwqnczko3WikrqM+l1NxlLF0zIIvXpsnjgydZPhxs2ay95aIrUEkdUdC3suK8N0NUIjq+xKrcz002WioppdGm091pK1w0IIjYp8jkhydXPxxq2K295aUrTkoeTs65suK+OUFUIzi7xqrb0VA0WSoootKm0t5tKlo1H4TYqMfkiydWQBxm16+85actTEseS8y7seHAPD9TIza5yKra01QyWSson9On0d5wKVk2H4DYqcfkjidUQB1j1rG75KsvSkseScu8seDCPz1TJDW2yara1FYxWSwnm9Sn0N9zKVg2H33ZqsXkkihSQR1g1bK65K0wSEsfR8i+seDEQTxUJTOzy6rY1VowWC0mmNWoz993KVc3H3rYq8TklSlRQh1d1LS647AyR0wgRMbAsN/GRDpTJTKwzKrX1l4vVy4lldWpzt97KVY4IXbUr8LZljVPRCxhw7W3z6ZISkw1VK+4sMWvXEhSPk6buay9sm5JVkZNiLWqtrJ+TldNTnquqbCwilZXU1BwpKirrpNgWFhTaZmnpquZbFlbVmWOpaOonHZcXlljhaGhpZ1+YWBdYn2cn6GdhmdhYGN3lp2enIttY2Jjco+bnJuOdGZlZXCImJqakHpoZ2Zug5WYmZJ/bGlobX6RlpeSg3BqaW16jZSVkoZ0bGtteImSk5KIeG5tbnaFkJKRinxxbm91gY2QkIt/c3BwdH6Kj4+LgnZxcXR8iI2OjIR5c3J0e4WLjYuFe3VzdHmCioyLhn52dHR5gIiKioeAeHV1eH+GiYqHgXp2dnh9hIiJh4J8eHd4fIKHiIeDfXl4eHyBhoeHhH96eHmA',
cb: { cb: {
online: function() { online: function() {
if (g.DEAD) { if (ThreadUpdater.thread.isDead) {
return; return;
} }
if (ThreadUpdater.online = navigator.onLine) { if (ThreadUpdater.online = navigator.onLine) {
@ -10173,7 +10163,7 @@
ThreadUpdater.outdateCount = 0; ThreadUpdater.outdateCount = 0;
ThreadUpdater.set('timer', '...'); ThreadUpdater.set('timer', '...');
} }
if (!(g.DEAD || ThreadUpdater.foundPost || ThreadUpdater.checkPostCount >= 5)) { if (!(ThreadUpdater.thread.isDead || ThreadUpdater.foundPost || ThreadUpdater.checkPostCount >= 5)) {
return setTimeout(ThreadUpdater.update, ++ThreadUpdater.checkPostCount * $.SECOND); return setTimeout(ThreadUpdater.update, ++ThreadUpdater.checkPostCount * $.SECOND);
} }
ThreadUpdater.setInterval(); ThreadUpdater.setInterval();
@ -10211,9 +10201,9 @@
req = ThreadUpdater.req; req = ThreadUpdater.req;
switch (req.status) { switch (req.status) {
case 200: case 200:
g.DEAD = !!+req.response.posts[0].archived;
ThreadUpdater.parse(req.response.posts); ThreadUpdater.parse(req.response.posts);
if (g.DEAD) { if (!!req.response.posts[0].archived) {
ThreadUpdater.thread.isArchived = true;
ThreadUpdater.set('status', 'Archived', 'warning'); ThreadUpdater.set('status', 'Archived', 'warning');
ThreadUpdater.kill(); ThreadUpdater.kill();
} else { } else {
@ -10242,7 +10232,6 @@
confirmed = false; confirmed = false;
} }
if (confirmed) { if (confirmed) {
g.DEAD = true;
ThreadUpdater.set('status', '404', 'warning'); ThreadUpdater.set('status', '404', 'warning');
return ThreadUpdater.kill(); return ThreadUpdater.kill();
} else { } else {
@ -10601,7 +10590,6 @@
}); });
} else { } else {
data.isDead = true; data.isDead = true;
delete data.unread;
ThreadWatcher.db.set({ ThreadWatcher.db.set({
boardID: boardID, boardID: boardID,
threadID: threadID, threadID: threadID,
@ -10641,7 +10629,7 @@
fetchStatus: function(_arg) { fetchStatus: function(_arg) {
var boardID, data, fetchCount, threadID; var boardID, data, fetchCount, threadID;
boardID = _arg.boardID, threadID = _arg.threadID, data = _arg.data; boardID = _arg.boardID, threadID = _arg.threadID, data = _arg.data;
if (data.isDead) { if (data.isDead && !Conf['Show Unread Count']) {
return; return;
} }
fetchCount = ThreadWatcher.fetchCount; fetchCount = ThreadWatcher.fetchCount;
@ -10652,7 +10640,7 @@
fetchCount.fetching++; fetchCount.fetching++;
return $.ajax("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", { return $.ajax("//a.4cdn.org/" + boardID + "/thread/" + threadID + ".json", {
onloadend: function() { onloadend: function() {
var lastReadPost, postObj, status, unread, _i, _len, _ref, _ref1; var isDead, lastReadPost, postObj, status, unread, _i, _len, _ref, _ref1;
fetchCount.fetched++; fetchCount.fetched++;
if (fetchCount.fetched === fetchCount.fetching) { if (fetchCount.fetched === fetchCount.fetching) {
fetchCount.fetched = 0; fetchCount.fetched = 0;
@ -10664,6 +10652,15 @@
} }
ThreadWatcher.status.textContent = status; ThreadWatcher.status.textContent = status;
if (this.status === 200 && this.response) { if (this.status === 200 && this.response) {
isDead = !!this.response.posts[0].archived;
if (isDead && Conf['Auto Prune']) {
ThreadWatcher.db["delete"]({
boardID: boardID,
threadID: threadID
});
ThreadWatcher.refresh();
return;
}
lastReadPost = ThreadWatcher.unreaddb.get({ lastReadPost = ThreadWatcher.unreaddb.get({
boardID: boardID, boardID: boardID,
threadID: threadID, threadID: threadID,
@ -10681,7 +10678,8 @@
unread++; unread++;
} }
} }
if (unread !== data.unread) { if (isDead !== data.isDead || unread !== data.unread) {
data.isDead = isDead;
data.unread = unread; data.unread = unread;
ThreadWatcher.db.set({ ThreadWatcher.db.set({
boardID: boardID, boardID: boardID,
@ -10708,8 +10706,6 @@
return ThreadWatcher.refresh(); return ThreadWatcher.refresh();
} }
} }
}, {
type: Conf['Show Unread Count'] ? 'get' : 'head'
}); });
}, },
getAll: function() { getAll: function() {
@ -10733,7 +10729,7 @@
return all; return all;
}, },
makeLine: function(boardID, threadID, data) { makeLine: function(boardID, threadID, data) {
var count, div, fullID, href, link, title, x; var count, div, fullID, link, title, x;
x = $.el('a', { x = $.el('a', {
className: 'fa fa-times', className: 'fa fa-times',
href: 'javascript:;' href: 'javascript:;'
@ -10747,14 +10743,8 @@
textContent: Conf['Show Unread Count'] && (data.unread != null) ? "\u00A0(" + data.unread + ")" : '', textContent: Conf['Show Unread Count'] && (data.unread != null) ? "\u00A0(" + data.unread + ")" : '',
className: 'watcher-unread' className: 'watcher-unread'
}); });
if (Conf['404 Redirect'] && data.isDead) {
href = Redirect.to('thread', {
boardID: boardID,
threadID: threadID
});
}
link = $.el('a', { link = $.el('a', {
href: href || ("/" + boardID + "/thread/" + threadID), href: "/" + boardID + "/thread/" + threadID,
title: data.excerpt, title: data.excerpt,
className: 'watcher-link' className: 'watcher-link'
}); });
@ -10837,7 +10827,7 @@
val: data val: data
}); });
ThreadWatcher.refresh(); ThreadWatcher.refresh();
if (Conf['Show Unread Count'] && !data.isDead) { if (Conf['Show Unread Count']) {
return ThreadWatcher.fetchStatus({ return ThreadWatcher.fetchStatus({
boardID: boardID, boardID: boardID,
threadID: threadID, threadID: threadID,
@ -10921,7 +10911,7 @@
cb: ThreadWatcher.cb.pruneDeads, cb: ThreadWatcher.cb.pruneDeads,
entry: { entry: {
el: $.el('a', { el: $.el('a', {
textContent: 'Prune 404\'d threads' textContent: 'Prune dead threads'
}) })
}, },
refresh: function() { refresh: function() {
@ -11202,7 +11192,7 @@
} }
}), }),
saveLastReadPost: $.debounce(2 * $.SECOND, function() { saveLastReadPost: $.debounce(2 * $.SECOND, function() {
if (Unread.thread.isDead) { if (Unread.thread.isDead && !Unread.thread.isArchived) {
return; return;
} }
return Unread.db.set({ return Unread.db.set({
@ -11224,16 +11214,19 @@
} }
}, },
update: function() { update: function() {
var count, countQuotingYou; var count, countQuotingYou, titleCount, titleDead, titleQuotingYou;
count = Unread.posts.length; count = Unread.posts.length;
countQuotingYou = Object.keys(Unread.postsQuotingYou).length; countQuotingYou = Object.keys(Unread.postsQuotingYou).length;
if (Conf['Unread Count']) { if (Conf['Unread Count']) {
d.title = "" + (Conf['Quoted Title'] && countQuotingYou ? '(!) ' : '') + (count || !Conf['Hide Unread Count at (0)'] ? "(" + count + ") " : '') + (g.DEAD ? Unread.title.replace('-', '- 404 -') : Unread.title); titleQuotingYou = Conf['Quoted Title'] && countQuotingYou ? '(!) ' : '';
titleCount = count || !Conf['Hide Unread Count at (0)'] ? "(" + count + ") " : '';
titleDead = Unread.thread.isDead ? Unread.title.replace('-', (Unread.thread.isArchived ? '- Archived -' : '- 404 -')) : Unread.title;
d.title = "" + titleQuotingYou + titleCount + titleDead;
} }
if (!Conf['Unread Favicon']) { if (!Conf['Unread Favicon']) {
return; return;
} }
Favicon.el.href = g.DEAD ? countQuotingYou ? Favicon.unreadDeadY : count ? Favicon.unreadDead : Favicon.dead : count ? countQuotingYou ? Favicon.unreadY : Favicon.unread : Favicon["default"]; Favicon.el.href = Unread.thread.isDead ? countQuotingYou ? Favicon.unreadDeadY : count ? Favicon.unreadDead : Favicon.dead : count ? countQuotingYou ? Favicon.unreadY : Favicon.unread : Favicon["default"];
return $.add(d.head, Favicon.el); return $.add(d.head, Favicon.el);
} }
}; };
@ -12884,7 +12877,7 @@
className: 'dialog' className: 'dialog'
}); });
$.extend(dialog, { $.extend(dialog, {
innerHTML: "<nav><div class=sections-list></div><p class='imp-exp-result warning'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href='https://github.com/ccd0/4chan-x' target=_blank>4chan X</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md' target=_blank>1.9.3.3</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/issues' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class='close fa fa-times' title=Close></a></div></nav><div class=section-container><section></section></div>" innerHTML: "<nav><div class=sections-list></div><p class='imp-exp-result warning'></p><div class=credits><a class=export>Export</a>&nbsp|&nbsp<a class=import>Import</a>&nbsp|&nbsp<a class=reset>Reset Settings</a>&nbsp|&nbsp<input type=file hidden><a href='https://github.com/ccd0/4chan-x' target=_blank>4chan X</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md' target=_blank>1.9.3.4</a>&nbsp|&nbsp<a href='https://github.com/ccd0/4chan-x/issues' target=_blank>Issues</a>&nbsp|&nbsp<a href=javascript:; class='close fa fa-times' title=Close></a></div></nav><div class=section-container><section></section></div>"
}); });
$.on($('.export', Settings.dialog), 'click', Settings["export"]); $.on($('.export', Settings.dialog), 'click', Settings["export"]);
$.on($('.import', Settings.dialog), 'click', Settings["import"]); $.on($('.import', Settings.dialog), 'click', Settings["import"]);
@ -13693,14 +13686,16 @@
}, },
initThread: function() { initThread: function() {
var board, err, errors, postRoot, posts, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1, _ref2; var board, err, errors, postRoot, posts, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1, _ref2;
g.DEAD = !!((_ref = $('.closed')) != null ? _ref.textContent.match(/Thread archived/) : void 0);
if (board = $('.board')) { if (board = $('.board')) {
threads = []; threads = [];
posts = []; posts = [];
_ref1 = $$('.board > .thread', board); _ref = $$('.board > .thread', board);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
threadRoot = _ref1[_i]; threadRoot = _ref[_i];
thread = new Thread(+threadRoot.id.slice(1), g.BOARD); thread = new Thread(+threadRoot.id.slice(1), g.BOARD);
if (g.VIEW === 'thread') {
thread.isDead = thread.isArchived = !!((_ref1 = $('.closed')) != null ? _ref1.textContent.match(/Thread archived/) : void 0);
}
threads.push(thread); threads.push(thread);
_ref2 = $$('.thread > .postContainer', threadRoot); _ref2 = $$('.thread > .postContainer', threadRoot);
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {

Binary file not shown.

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'> <app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X-beta.crx' version='1.9.3.3' /> <updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X-beta.crx' version='1.9.3.4' />
</app> </app>
</gupdate> </gupdate>

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'> <app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X.crx' version='1.9.3.3' /> <updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X.crx' version='1.9.3.4' />
</app> </app>
</gupdate> </gupdate>

View File

@ -3,7 +3,7 @@
"description": "Cross-browser userscript for maximum lurking on 4chan.", "description": "Cross-browser userscript for maximum lurking on 4chan.",
"meta": { "meta": {
"name": "4chan X", "name": "4chan X",
"version": "1.9.3.3", "version": "1.9.3.4",
"repo": "https://github.com/ccd0/4chan-x/", "repo": "https://github.com/ccd0/4chan-x/",
"page": "https://github.com/ccd0/4chan-x", "page": "https://github.com/ccd0/4chan-x",
"downloads": "https://ccd0.github.io/4chan-x/builds/", "downloads": "https://ccd0.github.io/4chan-x/builds/",