Release 4chan X v1.13.15.0.

This commit is contained in:
ccd0 2017-12-11 13:16:24 -08:00
parent fbee3c2df2
commit fed6b34cd9
15 changed files with 467 additions and 242 deletions

View File

@ -2,6 +2,12 @@
-Sometimes the changelog has notes (not comprehensive) acknowledging people's work. This does not mean the changes are their fault, only that their code was used. All changes to the script are chosen by and the fault of the maintainer (ccd0). -Sometimes the changelog has notes (not comprehensive) acknowledging people's work. This does not mean the changes are their fault, only that their code was used. All changes to the script are chosen by and the fault of the maintainer (ccd0).
### v1.13.15
**v1.13.15.0** *(2017-12-11)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.15.0/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.15.0/builds/4chan-X-noupdate.crx)]
- Based on v1.13.14.12.
- Better protection against race conditions that can lead to data loss.
### v1.13.14 ### v1.13.14
**v1.13.14.12** *(2017-12-10)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.14.12/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.14.12/builds/4chan-X-noupdate.crx)] **v1.13.14.12** *(2017-12-10)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.14.12/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.13.14.12/builds/4chan-X-noupdate.crx)]

Binary file not shown.

View File

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

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X beta // @name 4chan X beta
// @version 1.13.14.12 // @version 1.13.15.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -159,7 +159,7 @@ docSet = function() {
}; };
g = { g = {
VERSION: '1.13.14.12', VERSION: '1.13.15.0',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -5621,35 +5621,91 @@ DataBoard = (function() {
$.on(d, '4chanXInitFinished', init); $.on(d, '4chanXInitFinished', init);
} }
DataBoard.prototype.save = function(cb) { DataBoard.prototype.changes = [];
return $.set(this.key, this.data, cb);
DataBoard.prototype.save = function(change, cb) {
var changes, snapshot1;
snapshot1 = JSON.stringify(this.data);
change();
changes = this.changes;
changes.push(change);
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
var c, i, len, snapshot2;
_this.data = items[_this.key];
snapshot2 = JSON.stringify(_this.data);
for (i = 0, len = changes.length; i < len; i++) {
c = changes[i];
c();
}
return $.set(_this.key, _this.data, function() {
_this.changes = [];
if (snapshot1 !== snapshot2) {
if (typeof _this.sync === "function") {
_this.sync();
}
}
return typeof cb === "function" ? cb() : void 0;
});
};
})(this));
};
DataBoard.prototype.forceSync = function(cb) {
var changes, snapshot1;
snapshot1 = JSON.stringify(this.data);
changes = this.changes;
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
var c, i, len, snapshot2;
_this.data = items[_this.key];
snapshot2 = JSON.stringify(_this.data);
for (i = 0, len = changes.length; i < len; i++) {
c = changes[i];
c();
}
if (snapshot1 !== snapshot2) {
if (typeof _this.sync === "function") {
_this.sync();
}
}
return typeof cb === "function" ? cb() : void 0;
};
})(this));
}; };
DataBoard.prototype["delete"] = function(arg) { DataBoard.prototype["delete"] = function(arg) {
var boardID, postID, ref, threadID; var boardID, postID, threadID;
boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID; boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID;
$.forceSync(this.key); return this.save((function(_this) {
if (postID) { return function() {
if (!((ref = this.data.boards[boardID]) != null ? ref[threadID] : void 0)) { var ref;
return; if (postID) {
} if (!((ref = _this.data.boards[boardID]) != null ? ref[threadID] : void 0)) {
delete this.data.boards[boardID][threadID][postID]; return;
this.deleteIfEmpty({ }
boardID: boardID, delete _this.data.boards[boardID][threadID][postID];
threadID: threadID return _this.deleteIfEmpty({
}); boardID: boardID,
} else if (threadID) { threadID: threadID
if (!this.data.boards[boardID]) { });
return; } else if (threadID) {
} if (!_this.data.boards[boardID]) {
delete this.data.boards[boardID][threadID]; return;
this.deleteIfEmpty({ }
boardID: boardID delete _this.data.boards[boardID][threadID];
}); return _this.deleteIfEmpty({
} else { boardID: boardID
delete this.data.boards[boardID]; });
} } else {
return this.save(); return delete _this.data.boards[boardID];
}
};
})(this));
}; };
DataBoard.prototype.deleteIfEmpty = function(arg) { DataBoard.prototype.deleteIfEmpty = function(arg) {
@ -5668,45 +5724,59 @@ DataBoard = (function() {
}; };
DataBoard.prototype.set = function(data, cb) { DataBoard.prototype.set = function(data, cb) {
$.forceSync(this.key); return this.save((function(_this) {
return this.setUnsafe(data, cb); return function() {
return _this.setUnsafe(data);
};
})(this), cb);
}; };
DataBoard.prototype.setUnsafe = function(arg, cb) { DataBoard.prototype.setUnsafe = function(arg) {
var base, base1, base2, boardID, postID, threadID, val; var base, base1, base2, boardID, postID, threadID, val;
boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val; boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val;
if (postID !== void 0) { if (postID !== void 0) {
((base = ((base1 = this.data.boards)[boardID] || (base1[boardID] = {})))[threadID] || (base[threadID] = {}))[postID] = val; return ((base = ((base1 = this.data.boards)[boardID] || (base1[boardID] = {})))[threadID] || (base[threadID] = {}))[postID] = val;
} else if (threadID !== void 0) { } else if (threadID !== void 0) {
((base2 = this.data.boards)[boardID] || (base2[boardID] = {}))[threadID] = val; return ((base2 = this.data.boards)[boardID] || (base2[boardID] = {}))[threadID] = val;
} else { } else {
this.data.boards[boardID] = val; return this.data.boards[boardID] = val;
} }
return this.save(cb);
}; };
DataBoard.prototype.extend = function(arg, cb) { DataBoard.prototype.extend = function(arg, cb) {
var boardID, i, key, len, oldVal, postID, ref, rm, threadID, val; var boardID, postID, rm, threadID, val;
boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val, rm = arg.rm; boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val, rm = arg.rm;
$.forceSync(this.key); return this.save((function(_this) {
oldVal = this.get({ return function() {
boardID: boardID, var i, key, len, oldVal, ref;
threadID: threadID, oldVal = _this.get({
postID: postID, boardID: boardID,
val: {} threadID: threadID,
}); postID: postID,
ref = rm || []; val: {}
for (i = 0, len = ref.length; i < len; i++) { });
key = ref[i]; ref = rm || [];
delete oldVal[key]; for (i = 0, len = ref.length; i < len; i++) {
} key = ref[i];
$.extend(oldVal, val); delete oldVal[key];
return this.setUnsafe({ }
boardID: boardID, $.extend(oldVal, val);
threadID: threadID, return _this.setUnsafe({
postID: postID, boardID: boardID,
val: oldVal threadID: threadID,
}, cb); postID: postID,
val: oldVal
});
};
})(this), cb);
};
DataBoard.prototype.setLastChecked = function() {
return this.save((function(_this) {
return function() {
return _this.data.lastChecked = Date.now();
};
})(this));
}; };
DataBoard.prototype.get = function(arg) { DataBoard.prototype.get = function(arg) {
@ -5732,13 +5802,8 @@ DataBoard = (function() {
return val || defaultValue; return val || defaultValue;
}; };
DataBoard.prototype.forceSync = function() {
return $.forceSync(this.key);
};
DataBoard.prototype.clean = function() { DataBoard.prototype.clean = function() {
var boardID, now, ref, ref1, val; var boardID, now, ref, ref1, val;
$.forceSync(this.key);
ref = this.data.boards; ref = this.data.boards;
for (boardID in ref) { for (boardID in ref) {
val = ref[boardID]; val = ref[boardID];
@ -5804,7 +5869,7 @@ DataBoard = (function() {
this.deleteIfEmpty({ this.deleteIfEmpty({
boardID: boardID boardID: boardID
}); });
return this.save(); return $.set(this.key, this.data);
}; };
DataBoard.prototype.onSync = function(data) { DataBoard.prototype.onSync = function(data) {
@ -19331,8 +19396,7 @@ ThreadWatcher = (function() {
now = Date.now(); now = Date.now();
if (!((now - interval < (ref = db.data.lastChecked || 0) && ref <= now))) { if (!((now - interval < (ref = db.data.lastChecked || 0) && ref <= now))) {
ThreadWatcher.fetchAllStatus(); ThreadWatcher.fetchAllStatus();
db.data.lastChecked = now; db.setLastChecked();
db.save();
} }
return ThreadWatcher.timeout = setTimeout(ThreadWatcher.fetchAuto, interval); return ThreadWatcher.timeout = setTimeout(ThreadWatcher.fetchAuto, interval);
}, },
@ -19344,19 +19408,26 @@ ThreadWatcher = (function() {
} }
}, },
fetchAllStatus: function() { fetchAllStatus: function() {
var i, len, ref, thread, threads; var db, dbs, i, len, n, results;
ThreadWatcher.db.forceSync(); dbs = [ThreadWatcher.db, ThreadWatcher.unreaddb, QuoteYou.db].filter(function(x) {
ThreadWatcher.unreaddb.forceSync(); return x;
if ((ref = QuoteYou.db) != null) { });
ref.forceSync(); n = 0;
} results = [];
if (!(threads = ThreadWatcher.getAll()).length) { for (i = 0, len = dbs.length; i < len; i++) {
return; db = dbs[i];
} results.push(db.forceSync(function() {
for (i = 0, len = threads.length; i < len; i++) { var j, len1, thread, threads;
thread = threads[i]; if ((++n) === dbs.length) {
ThreadWatcher.fetchStatus(thread); threads = ThreadWatcher.getAll();
for (j = 0, len1 = threads.length; j < len1; j++) {
thread = threads[j];
ThreadWatcher.fetchStatus(thread);
}
}
}));
} }
return results;
}, },
fetchStatus: function(thread, force) { fetchStatus: function(thread, force) {
var boardID, data, req, threadID; var boardID, data, req, threadID;
@ -24281,9 +24352,11 @@ QuoteYou = (function() {
return Conf['Remember Your Posts'] = enabled; return Conf['Remember Your Posts'] = enabled;
}); });
$.on(d, 'QRPostSuccessful', function(e) { $.on(d, 'QRPostSuccessful', function(e) {
var boardID, postID, ref, threadID; return $.get('Remember Your Posts', Conf['Remember Your Posts'], function(items) {
$.forceSync('Remember Your Posts'); var boardID, postID, ref, threadID;
if (Conf['Remember Your Posts']) { if (!items['Remember Your Posts']) {
return;
}
ref = e.detail, boardID = ref.boardID, threadID = ref.threadID, postID = ref.postID; ref = e.detail, boardID = ref.boardID, threadID = ref.threadID, postID = ref.postID;
return QuoteYou.db.set({ return QuoteYou.db.set({
boardID: boardID, boardID: boardID,
@ -24291,7 +24364,7 @@ QuoteYou = (function() {
postID: postID, postID: postID,
val: true val: true
}); });
} });
}); });
if ((ref = g.VIEW) !== 'index' && ref !== 'thread' && ref !== 'archive') { if ((ref = g.VIEW) !== 'index' && ref !== 'thread' && ref !== 'archive') {
return; return;

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.13.14.12 // @version 1.13.15.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -159,7 +159,7 @@ docSet = function() {
}; };
g = { g = {
VERSION: '1.13.14.12', VERSION: '1.13.15.0',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -5621,35 +5621,91 @@ DataBoard = (function() {
$.on(d, '4chanXInitFinished', init); $.on(d, '4chanXInitFinished', init);
} }
DataBoard.prototype.save = function(cb) { DataBoard.prototype.changes = [];
return $.set(this.key, this.data, cb);
DataBoard.prototype.save = function(change, cb) {
var changes, snapshot1;
snapshot1 = JSON.stringify(this.data);
change();
changes = this.changes;
changes.push(change);
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
var c, i, len, snapshot2;
_this.data = items[_this.key];
snapshot2 = JSON.stringify(_this.data);
for (i = 0, len = changes.length; i < len; i++) {
c = changes[i];
c();
}
return $.set(_this.key, _this.data, function() {
_this.changes = [];
if (snapshot1 !== snapshot2) {
if (typeof _this.sync === "function") {
_this.sync();
}
}
return typeof cb === "function" ? cb() : void 0;
});
};
})(this));
};
DataBoard.prototype.forceSync = function(cb) {
var changes, snapshot1;
snapshot1 = JSON.stringify(this.data);
changes = this.changes;
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
var c, i, len, snapshot2;
_this.data = items[_this.key];
snapshot2 = JSON.stringify(_this.data);
for (i = 0, len = changes.length; i < len; i++) {
c = changes[i];
c();
}
if (snapshot1 !== snapshot2) {
if (typeof _this.sync === "function") {
_this.sync();
}
}
return typeof cb === "function" ? cb() : void 0;
};
})(this));
}; };
DataBoard.prototype["delete"] = function(arg) { DataBoard.prototype["delete"] = function(arg) {
var boardID, postID, ref, threadID; var boardID, postID, threadID;
boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID; boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID;
$.forceSync(this.key); return this.save((function(_this) {
if (postID) { return function() {
if (!((ref = this.data.boards[boardID]) != null ? ref[threadID] : void 0)) { var ref;
return; if (postID) {
} if (!((ref = _this.data.boards[boardID]) != null ? ref[threadID] : void 0)) {
delete this.data.boards[boardID][threadID][postID]; return;
this.deleteIfEmpty({ }
boardID: boardID, delete _this.data.boards[boardID][threadID][postID];
threadID: threadID return _this.deleteIfEmpty({
}); boardID: boardID,
} else if (threadID) { threadID: threadID
if (!this.data.boards[boardID]) { });
return; } else if (threadID) {
} if (!_this.data.boards[boardID]) {
delete this.data.boards[boardID][threadID]; return;
this.deleteIfEmpty({ }
boardID: boardID delete _this.data.boards[boardID][threadID];
}); return _this.deleteIfEmpty({
} else { boardID: boardID
delete this.data.boards[boardID]; });
} } else {
return this.save(); return delete _this.data.boards[boardID];
}
};
})(this));
}; };
DataBoard.prototype.deleteIfEmpty = function(arg) { DataBoard.prototype.deleteIfEmpty = function(arg) {
@ -5668,45 +5724,59 @@ DataBoard = (function() {
}; };
DataBoard.prototype.set = function(data, cb) { DataBoard.prototype.set = function(data, cb) {
$.forceSync(this.key); return this.save((function(_this) {
return this.setUnsafe(data, cb); return function() {
return _this.setUnsafe(data);
};
})(this), cb);
}; };
DataBoard.prototype.setUnsafe = function(arg, cb) { DataBoard.prototype.setUnsafe = function(arg) {
var base, base1, base2, boardID, postID, threadID, val; var base, base1, base2, boardID, postID, threadID, val;
boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val; boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val;
if (postID !== void 0) { if (postID !== void 0) {
((base = ((base1 = this.data.boards)[boardID] || (base1[boardID] = {})))[threadID] || (base[threadID] = {}))[postID] = val; return ((base = ((base1 = this.data.boards)[boardID] || (base1[boardID] = {})))[threadID] || (base[threadID] = {}))[postID] = val;
} else if (threadID !== void 0) { } else if (threadID !== void 0) {
((base2 = this.data.boards)[boardID] || (base2[boardID] = {}))[threadID] = val; return ((base2 = this.data.boards)[boardID] || (base2[boardID] = {}))[threadID] = val;
} else { } else {
this.data.boards[boardID] = val; return this.data.boards[boardID] = val;
} }
return this.save(cb);
}; };
DataBoard.prototype.extend = function(arg, cb) { DataBoard.prototype.extend = function(arg, cb) {
var boardID, i, key, len, oldVal, postID, ref, rm, threadID, val; var boardID, postID, rm, threadID, val;
boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val, rm = arg.rm; boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val, rm = arg.rm;
$.forceSync(this.key); return this.save((function(_this) {
oldVal = this.get({ return function() {
boardID: boardID, var i, key, len, oldVal, ref;
threadID: threadID, oldVal = _this.get({
postID: postID, boardID: boardID,
val: {} threadID: threadID,
}); postID: postID,
ref = rm || []; val: {}
for (i = 0, len = ref.length; i < len; i++) { });
key = ref[i]; ref = rm || [];
delete oldVal[key]; for (i = 0, len = ref.length; i < len; i++) {
} key = ref[i];
$.extend(oldVal, val); delete oldVal[key];
return this.setUnsafe({ }
boardID: boardID, $.extend(oldVal, val);
threadID: threadID, return _this.setUnsafe({
postID: postID, boardID: boardID,
val: oldVal threadID: threadID,
}, cb); postID: postID,
val: oldVal
});
};
})(this), cb);
};
DataBoard.prototype.setLastChecked = function() {
return this.save((function(_this) {
return function() {
return _this.data.lastChecked = Date.now();
};
})(this));
}; };
DataBoard.prototype.get = function(arg) { DataBoard.prototype.get = function(arg) {
@ -5732,13 +5802,8 @@ DataBoard = (function() {
return val || defaultValue; return val || defaultValue;
}; };
DataBoard.prototype.forceSync = function() {
return $.forceSync(this.key);
};
DataBoard.prototype.clean = function() { DataBoard.prototype.clean = function() {
var boardID, now, ref, ref1, val; var boardID, now, ref, ref1, val;
$.forceSync(this.key);
ref = this.data.boards; ref = this.data.boards;
for (boardID in ref) { for (boardID in ref) {
val = ref[boardID]; val = ref[boardID];
@ -5804,7 +5869,7 @@ DataBoard = (function() {
this.deleteIfEmpty({ this.deleteIfEmpty({
boardID: boardID boardID: boardID
}); });
return this.save(); return $.set(this.key, this.data);
}; };
DataBoard.prototype.onSync = function(data) { DataBoard.prototype.onSync = function(data) {
@ -19331,8 +19396,7 @@ ThreadWatcher = (function() {
now = Date.now(); now = Date.now();
if (!((now - interval < (ref = db.data.lastChecked || 0) && ref <= now))) { if (!((now - interval < (ref = db.data.lastChecked || 0) && ref <= now))) {
ThreadWatcher.fetchAllStatus(); ThreadWatcher.fetchAllStatus();
db.data.lastChecked = now; db.setLastChecked();
db.save();
} }
return ThreadWatcher.timeout = setTimeout(ThreadWatcher.fetchAuto, interval); return ThreadWatcher.timeout = setTimeout(ThreadWatcher.fetchAuto, interval);
}, },
@ -19344,19 +19408,26 @@ ThreadWatcher = (function() {
} }
}, },
fetchAllStatus: function() { fetchAllStatus: function() {
var i, len, ref, thread, threads; var db, dbs, i, len, n, results;
ThreadWatcher.db.forceSync(); dbs = [ThreadWatcher.db, ThreadWatcher.unreaddb, QuoteYou.db].filter(function(x) {
ThreadWatcher.unreaddb.forceSync(); return x;
if ((ref = QuoteYou.db) != null) { });
ref.forceSync(); n = 0;
} results = [];
if (!(threads = ThreadWatcher.getAll()).length) { for (i = 0, len = dbs.length; i < len; i++) {
return; db = dbs[i];
} results.push(db.forceSync(function() {
for (i = 0, len = threads.length; i < len; i++) { var j, len1, thread, threads;
thread = threads[i]; if ((++n) === dbs.length) {
ThreadWatcher.fetchStatus(thread); threads = ThreadWatcher.getAll();
for (j = 0, len1 = threads.length; j < len1; j++) {
thread = threads[j];
ThreadWatcher.fetchStatus(thread);
}
}
}));
} }
return results;
}, },
fetchStatus: function(thread, force) { fetchStatus: function(thread, force) {
var boardID, data, req, threadID; var boardID, data, req, threadID;
@ -24281,9 +24352,11 @@ QuoteYou = (function() {
return Conf['Remember Your Posts'] = enabled; return Conf['Remember Your Posts'] = enabled;
}); });
$.on(d, 'QRPostSuccessful', function(e) { $.on(d, 'QRPostSuccessful', function(e) {
var boardID, postID, ref, threadID; return $.get('Remember Your Posts', Conf['Remember Your Posts'], function(items) {
$.forceSync('Remember Your Posts'); var boardID, postID, ref, threadID;
if (Conf['Remember Your Posts']) { if (!items['Remember Your Posts']) {
return;
}
ref = e.detail, boardID = ref.boardID, threadID = ref.threadID, postID = ref.postID; ref = e.detail, boardID = ref.boardID, threadID = ref.threadID, postID = ref.postID;
return QuoteYou.db.set({ return QuoteYou.db.set({
boardID: boardID, boardID: boardID,
@ -24291,7 +24364,7 @@ QuoteYou = (function() {
postID: postID, postID: postID,
val: true val: true
}); });
} });
}); });
if ((ref = g.VIEW) !== 'index' && ref !== 'thread' && ref !== 'archive') { if ((ref = g.VIEW) !== 'index' && ref !== 'thread' && ref !== 'archive') {
return; return;

Binary file not shown.

View File

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

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.13.14.12 // @version 1.13.15.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -159,7 +159,7 @@ docSet = function() {
}; };
g = { g = {
VERSION: '1.13.14.12', VERSION: '1.13.15.0',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
boards: {} boards: {}
}; };
@ -5621,35 +5621,91 @@ DataBoard = (function() {
$.on(d, '4chanXInitFinished', init); $.on(d, '4chanXInitFinished', init);
} }
DataBoard.prototype.save = function(cb) { DataBoard.prototype.changes = [];
return $.set(this.key, this.data, cb);
DataBoard.prototype.save = function(change, cb) {
var changes, snapshot1;
snapshot1 = JSON.stringify(this.data);
change();
changes = this.changes;
changes.push(change);
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
var c, i, len, snapshot2;
_this.data = items[_this.key];
snapshot2 = JSON.stringify(_this.data);
for (i = 0, len = changes.length; i < len; i++) {
c = changes[i];
c();
}
return $.set(_this.key, _this.data, function() {
_this.changes = [];
if (snapshot1 !== snapshot2) {
if (typeof _this.sync === "function") {
_this.sync();
}
}
return typeof cb === "function" ? cb() : void 0;
});
};
})(this));
};
DataBoard.prototype.forceSync = function(cb) {
var changes, snapshot1;
snapshot1 = JSON.stringify(this.data);
changes = this.changes;
return $.get(this.key, {
boards: {}
}, (function(_this) {
return function(items) {
var c, i, len, snapshot2;
_this.data = items[_this.key];
snapshot2 = JSON.stringify(_this.data);
for (i = 0, len = changes.length; i < len; i++) {
c = changes[i];
c();
}
if (snapshot1 !== snapshot2) {
if (typeof _this.sync === "function") {
_this.sync();
}
}
return typeof cb === "function" ? cb() : void 0;
};
})(this));
}; };
DataBoard.prototype["delete"] = function(arg) { DataBoard.prototype["delete"] = function(arg) {
var boardID, postID, ref, threadID; var boardID, postID, threadID;
boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID; boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID;
$.forceSync(this.key); return this.save((function(_this) {
if (postID) { return function() {
if (!((ref = this.data.boards[boardID]) != null ? ref[threadID] : void 0)) { var ref;
return; if (postID) {
} if (!((ref = _this.data.boards[boardID]) != null ? ref[threadID] : void 0)) {
delete this.data.boards[boardID][threadID][postID]; return;
this.deleteIfEmpty({ }
boardID: boardID, delete _this.data.boards[boardID][threadID][postID];
threadID: threadID return _this.deleteIfEmpty({
}); boardID: boardID,
} else if (threadID) { threadID: threadID
if (!this.data.boards[boardID]) { });
return; } else if (threadID) {
} if (!_this.data.boards[boardID]) {
delete this.data.boards[boardID][threadID]; return;
this.deleteIfEmpty({ }
boardID: boardID delete _this.data.boards[boardID][threadID];
}); return _this.deleteIfEmpty({
} else { boardID: boardID
delete this.data.boards[boardID]; });
} } else {
return this.save(); return delete _this.data.boards[boardID];
}
};
})(this));
}; };
DataBoard.prototype.deleteIfEmpty = function(arg) { DataBoard.prototype.deleteIfEmpty = function(arg) {
@ -5668,45 +5724,59 @@ DataBoard = (function() {
}; };
DataBoard.prototype.set = function(data, cb) { DataBoard.prototype.set = function(data, cb) {
$.forceSync(this.key); return this.save((function(_this) {
return this.setUnsafe(data, cb); return function() {
return _this.setUnsafe(data);
};
})(this), cb);
}; };
DataBoard.prototype.setUnsafe = function(arg, cb) { DataBoard.prototype.setUnsafe = function(arg) {
var base, base1, base2, boardID, postID, threadID, val; var base, base1, base2, boardID, postID, threadID, val;
boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val; boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val;
if (postID !== void 0) { if (postID !== void 0) {
((base = ((base1 = this.data.boards)[boardID] || (base1[boardID] = {})))[threadID] || (base[threadID] = {}))[postID] = val; return ((base = ((base1 = this.data.boards)[boardID] || (base1[boardID] = {})))[threadID] || (base[threadID] = {}))[postID] = val;
} else if (threadID !== void 0) { } else if (threadID !== void 0) {
((base2 = this.data.boards)[boardID] || (base2[boardID] = {}))[threadID] = val; return ((base2 = this.data.boards)[boardID] || (base2[boardID] = {}))[threadID] = val;
} else { } else {
this.data.boards[boardID] = val; return this.data.boards[boardID] = val;
} }
return this.save(cb);
}; };
DataBoard.prototype.extend = function(arg, cb) { DataBoard.prototype.extend = function(arg, cb) {
var boardID, i, key, len, oldVal, postID, ref, rm, threadID, val; var boardID, postID, rm, threadID, val;
boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val, rm = arg.rm; boardID = arg.boardID, threadID = arg.threadID, postID = arg.postID, val = arg.val, rm = arg.rm;
$.forceSync(this.key); return this.save((function(_this) {
oldVal = this.get({ return function() {
boardID: boardID, var i, key, len, oldVal, ref;
threadID: threadID, oldVal = _this.get({
postID: postID, boardID: boardID,
val: {} threadID: threadID,
}); postID: postID,
ref = rm || []; val: {}
for (i = 0, len = ref.length; i < len; i++) { });
key = ref[i]; ref = rm || [];
delete oldVal[key]; for (i = 0, len = ref.length; i < len; i++) {
} key = ref[i];
$.extend(oldVal, val); delete oldVal[key];
return this.setUnsafe({ }
boardID: boardID, $.extend(oldVal, val);
threadID: threadID, return _this.setUnsafe({
postID: postID, boardID: boardID,
val: oldVal threadID: threadID,
}, cb); postID: postID,
val: oldVal
});
};
})(this), cb);
};
DataBoard.prototype.setLastChecked = function() {
return this.save((function(_this) {
return function() {
return _this.data.lastChecked = Date.now();
};
})(this));
}; };
DataBoard.prototype.get = function(arg) { DataBoard.prototype.get = function(arg) {
@ -5732,13 +5802,8 @@ DataBoard = (function() {
return val || defaultValue; return val || defaultValue;
}; };
DataBoard.prototype.forceSync = function() {
return $.forceSync(this.key);
};
DataBoard.prototype.clean = function() { DataBoard.prototype.clean = function() {
var boardID, now, ref, ref1, val; var boardID, now, ref, ref1, val;
$.forceSync(this.key);
ref = this.data.boards; ref = this.data.boards;
for (boardID in ref) { for (boardID in ref) {
val = ref[boardID]; val = ref[boardID];
@ -5804,7 +5869,7 @@ DataBoard = (function() {
this.deleteIfEmpty({ this.deleteIfEmpty({
boardID: boardID boardID: boardID
}); });
return this.save(); return $.set(this.key, this.data);
}; };
DataBoard.prototype.onSync = function(data) { DataBoard.prototype.onSync = function(data) {
@ -19331,8 +19396,7 @@ ThreadWatcher = (function() {
now = Date.now(); now = Date.now();
if (!((now - interval < (ref = db.data.lastChecked || 0) && ref <= now))) { if (!((now - interval < (ref = db.data.lastChecked || 0) && ref <= now))) {
ThreadWatcher.fetchAllStatus(); ThreadWatcher.fetchAllStatus();
db.data.lastChecked = now; db.setLastChecked();
db.save();
} }
return ThreadWatcher.timeout = setTimeout(ThreadWatcher.fetchAuto, interval); return ThreadWatcher.timeout = setTimeout(ThreadWatcher.fetchAuto, interval);
}, },
@ -19344,19 +19408,26 @@ ThreadWatcher = (function() {
} }
}, },
fetchAllStatus: function() { fetchAllStatus: function() {
var i, len, ref, thread, threads; var db, dbs, i, len, n, results;
ThreadWatcher.db.forceSync(); dbs = [ThreadWatcher.db, ThreadWatcher.unreaddb, QuoteYou.db].filter(function(x) {
ThreadWatcher.unreaddb.forceSync(); return x;
if ((ref = QuoteYou.db) != null) { });
ref.forceSync(); n = 0;
} results = [];
if (!(threads = ThreadWatcher.getAll()).length) { for (i = 0, len = dbs.length; i < len; i++) {
return; db = dbs[i];
} results.push(db.forceSync(function() {
for (i = 0, len = threads.length; i < len; i++) { var j, len1, thread, threads;
thread = threads[i]; if ((++n) === dbs.length) {
ThreadWatcher.fetchStatus(thread); threads = ThreadWatcher.getAll();
for (j = 0, len1 = threads.length; j < len1; j++) {
thread = threads[j];
ThreadWatcher.fetchStatus(thread);
}
}
}));
} }
return results;
}, },
fetchStatus: function(thread, force) { fetchStatus: function(thread, force) {
var boardID, data, req, threadID; var boardID, data, req, threadID;
@ -24281,9 +24352,11 @@ QuoteYou = (function() {
return Conf['Remember Your Posts'] = enabled; return Conf['Remember Your Posts'] = enabled;
}); });
$.on(d, 'QRPostSuccessful', function(e) { $.on(d, 'QRPostSuccessful', function(e) {
var boardID, postID, ref, threadID; return $.get('Remember Your Posts', Conf['Remember Your Posts'], function(items) {
$.forceSync('Remember Your Posts'); var boardID, postID, ref, threadID;
if (Conf['Remember Your Posts']) { if (!items['Remember Your Posts']) {
return;
}
ref = e.detail, boardID = ref.boardID, threadID = ref.threadID, postID = ref.postID; ref = e.detail, boardID = ref.boardID, threadID = ref.threadID, postID = ref.postID;
return QuoteYou.db.set({ return QuoteYou.db.set({
boardID: boardID, boardID: boardID,
@ -24291,7 +24364,7 @@ QuoteYou = (function() {
postID: postID, postID: postID,
val: true val: true
}); });
} });
}); });
if ((ref = g.VIEW) !== 'index' && ref !== 'thread' && ref !== 'archive') { if ((ref = g.VIEW) !== 'index' && ref !== 'thread' && ref !== 'archive') {
return; return;

Binary file not shown.

View File

@ -3,7 +3,7 @@
"4chan-x@4chan-x.net": { "4chan-x@4chan-x.net": {
"updates": [ "updates": [
{ {
"version": "1.13.14.12", "version": "1.13.15.0",
"update_link": "https://www.4chan-x.net/builds/4chan-X-beta.crx" "update_link": "https://www.4chan-x.net/builds/4chan-X-beta.crx"
} }
] ]

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://www.4chan-x.net/builds/4chan-X-beta.crx' version='1.13.14.12' /> <updatecheck codebase='https://www.4chan-x.net/builds/4chan-X-beta.crx' version='1.13.15.0' />
</app> </app>
</gupdate> </gupdate>

View File

@ -3,7 +3,7 @@
"4chan-x@4chan-x.net": { "4chan-x@4chan-x.net": {
"updates": [ "updates": [
{ {
"version": "1.13.14.12", "version": "1.13.15.0",
"update_link": "https://www.4chan-x.net/builds/4chan-X.crx" "update_link": "https://www.4chan-x.net/builds/4chan-X.crx"
} }
] ]

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://www.4chan-x.net/builds/4chan-X.crx' version='1.13.14.12' /> <updatecheck codebase='https://www.4chan-x.net/builds/4chan-X.crx' version='1.13.15.0' />
</app> </app>
</gupdate> </gupdate>

View File

@ -1,4 +1,4 @@
{ {
"version": "1.13.14.12", "version": "1.13.15.0",
"date": "2017-12-10T05:43:12.525Z" "date": "2017-12-11T19:32:54.527Z"
} }