Merge Mayhem X
This commit is contained in:
commit
f4db0a60ff
@ -1308,12 +1308,18 @@
|
||||
};
|
||||
|
||||
DataBoard.prototype.clean = function() {
|
||||
var boardID, now;
|
||||
var boardID, now, val, _ref;
|
||||
|
||||
for (boardID in this.data.boards) {
|
||||
this.deleteIfEmpty({
|
||||
boardID: boardID
|
||||
});
|
||||
_ref = this.data.boards;
|
||||
for (boardID in _ref) {
|
||||
val = _ref[boardID];
|
||||
if (!val) {
|
||||
delete this.data.boards[boardID];
|
||||
} else {
|
||||
this.deleteIfEmpty({
|
||||
boardID: boardID
|
||||
});
|
||||
}
|
||||
}
|
||||
now = Date.now();
|
||||
if ((this.data.lastChecked || 0) < now - 2 * $.HOUR) {
|
||||
@ -2681,6 +2687,10 @@
|
||||
}
|
||||
for (key in Config.filter) {
|
||||
this.filters[key] = [];
|
||||
if (Conf[key] === void 0) {
|
||||
$["delete"](key);
|
||||
continue;
|
||||
}
|
||||
_ref = Conf[key].split('\n');
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
filter = _ref[_i];
|
||||
@ -9186,7 +9196,7 @@
|
||||
|
||||
Sauce = {
|
||||
init: function() {
|
||||
var link, links, _i, _len, _ref;
|
||||
var err, link, links, _i, _len, _ref;
|
||||
|
||||
if (g.VIEW === 'catalog' || !Conf['Sauce']) {
|
||||
return;
|
||||
@ -9198,7 +9208,12 @@
|
||||
if (link[0] === '#') {
|
||||
continue;
|
||||
}
|
||||
links.push(this.createSauceLink(link.trim()));
|
||||
try {
|
||||
links.push(this.createSauceLink(link.trim()));
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!links.length) {
|
||||
return;
|
||||
@ -9578,6 +9593,7 @@
|
||||
};
|
||||
}
|
||||
$.get(Conf, function(Conf) {
|
||||
delete Conf['archives'];
|
||||
data.Conf = Conf;
|
||||
return Settings["export"](now, data);
|
||||
});
|
||||
@ -10035,10 +10051,11 @@
|
||||
}
|
||||
Conf['selectedArchives'] = {};
|
||||
$.get(Conf, Main.initFeatures);
|
||||
$.on(d, '4chanMainInit', Main.initStyle);
|
||||
return $.asap((function() {
|
||||
var _ref;
|
||||
|
||||
return d.head && $('link[rel="shortcut icon"]', d.head) || ((_ref = d.readyState) === 'interactive' || _ref === 'complete');
|
||||
return d.head && $('title', d.head) || ((_ref = d.readyState) === 'interactive' || _ref === 'complete');
|
||||
}), Main.initStyle);
|
||||
},
|
||||
initFeatures: function(items) {
|
||||
@ -10047,6 +10064,9 @@
|
||||
Conf = items;
|
||||
pathname = location.pathname.split('/');
|
||||
g.BOARD = new Board(pathname[1]);
|
||||
if (g.BOARD.ID === 'z') {
|
||||
return;
|
||||
}
|
||||
g.VIEW = (function() {
|
||||
switch (pathname[2]) {
|
||||
case 'res':
|
||||
@ -10162,7 +10182,8 @@
|
||||
initStyle: function() {
|
||||
var MutationObserver, mainStyleSheet, observer, setStyle, style, styleSheets, _ref;
|
||||
|
||||
if (!Main.isThisPageLegit()) {
|
||||
$.off(d, '4chanMainInit', Main.initStyle);
|
||||
if (!Main.isThisPageLegit() || $.hasClass(doc, 'fourchan-x')) {
|
||||
return;
|
||||
}
|
||||
if ((_ref = $('link[href*=mobile]', d.head)) != null) {
|
||||
@ -10274,6 +10295,12 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
localStorage.getItem('4chan-settings');
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
new Notification('warning', 'Cookies need to be enabled on 4chan for 4chan X to properly function.', 30);
|
||||
}
|
||||
$.event('4chanXInitFinished');
|
||||
return Main.checkUpdate();
|
||||
},
|
||||
|
||||
@ -1304,12 +1304,18 @@
|
||||
};
|
||||
|
||||
DataBoard.prototype.clean = function() {
|
||||
var boardID, now;
|
||||
var boardID, now, val, _ref;
|
||||
|
||||
for (boardID in this.data.boards) {
|
||||
this.deleteIfEmpty({
|
||||
boardID: boardID
|
||||
});
|
||||
_ref = this.data.boards;
|
||||
for (boardID in _ref) {
|
||||
val = _ref[boardID];
|
||||
if (!val) {
|
||||
delete this.data.boards[boardID];
|
||||
} else {
|
||||
this.deleteIfEmpty({
|
||||
boardID: boardID
|
||||
});
|
||||
}
|
||||
}
|
||||
now = Date.now();
|
||||
if ((this.data.lastChecked || 0) < now - 2 * $.HOUR) {
|
||||
@ -2677,6 +2683,10 @@
|
||||
}
|
||||
for (key in Config.filter) {
|
||||
this.filters[key] = [];
|
||||
if (Conf[key] === void 0) {
|
||||
$["delete"](key);
|
||||
continue;
|
||||
}
|
||||
_ref = Conf[key].split('\n');
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
filter = _ref[_i];
|
||||
@ -9195,7 +9205,7 @@
|
||||
|
||||
Sauce = {
|
||||
init: function() {
|
||||
var link, links, _i, _len, _ref;
|
||||
var err, link, links, _i, _len, _ref;
|
||||
|
||||
if (g.VIEW === 'catalog' || !Conf['Sauce']) {
|
||||
return;
|
||||
@ -9207,7 +9217,12 @@
|
||||
if (link[0] === '#') {
|
||||
continue;
|
||||
}
|
||||
links.push(this.createSauceLink(link.trim()));
|
||||
try {
|
||||
links.push(this.createSauceLink(link.trim()));
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!links.length) {
|
||||
return;
|
||||
@ -9587,6 +9602,7 @@
|
||||
};
|
||||
}
|
||||
$.get(Conf, function(Conf) {
|
||||
delete Conf['archives'];
|
||||
data.Conf = Conf;
|
||||
return Settings["export"](now, data);
|
||||
});
|
||||
@ -10046,10 +10062,11 @@
|
||||
}
|
||||
Conf['selectedArchives'] = {};
|
||||
$.get(Conf, Main.initFeatures);
|
||||
$.on(d, '4chanMainInit', Main.initStyle);
|
||||
return $.asap((function() {
|
||||
var _ref;
|
||||
|
||||
return d.head && $('link[rel="shortcut icon"]', d.head) || ((_ref = d.readyState) === 'interactive' || _ref === 'complete');
|
||||
return d.head && $('title', d.head) || ((_ref = d.readyState) === 'interactive' || _ref === 'complete');
|
||||
}), Main.initStyle);
|
||||
},
|
||||
initFeatures: function(items) {
|
||||
@ -10058,6 +10075,9 @@
|
||||
Conf = items;
|
||||
pathname = location.pathname.split('/');
|
||||
g.BOARD = new Board(pathname[1]);
|
||||
if (g.BOARD.ID === 'z') {
|
||||
return;
|
||||
}
|
||||
g.VIEW = (function() {
|
||||
switch (pathname[2]) {
|
||||
case 'res':
|
||||
@ -10173,7 +10193,8 @@
|
||||
initStyle: function() {
|
||||
var MutationObserver, mainStyleSheet, observer, setStyle, style, styleSheets, _ref;
|
||||
|
||||
if (!Main.isThisPageLegit()) {
|
||||
$.off(d, '4chanMainInit', Main.initStyle);
|
||||
if (!Main.isThisPageLegit() || $.hasClass(doc, 'fourchan-x')) {
|
||||
return;
|
||||
}
|
||||
if ((_ref = $('link[href*=mobile]', d.head)) != null) {
|
||||
@ -10285,6 +10306,12 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
localStorage.getItem('4chan-settings');
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
new Notification('warning', 'Cookies need to be enabled on 4chan for 4chan X to properly function.', 30);
|
||||
}
|
||||
$.event('4chanXInitFinished');
|
||||
return Main.checkUpdate();
|
||||
},
|
||||
|
||||
@ -1306,12 +1306,18 @@
|
||||
};
|
||||
|
||||
DataBoard.prototype.clean = function() {
|
||||
var boardID, now;
|
||||
var boardID, now, val, _ref;
|
||||
|
||||
for (boardID in this.data.boards) {
|
||||
this.deleteIfEmpty({
|
||||
boardID: boardID
|
||||
});
|
||||
_ref = this.data.boards;
|
||||
for (boardID in _ref) {
|
||||
val = _ref[boardID];
|
||||
if (!val) {
|
||||
delete this.data.boards[boardID];
|
||||
} else {
|
||||
this.deleteIfEmpty({
|
||||
boardID: boardID
|
||||
});
|
||||
}
|
||||
}
|
||||
now = Date.now();
|
||||
if ((this.data.lastChecked || 0) < now - 2 * $.HOUR) {
|
||||
@ -2679,6 +2685,10 @@
|
||||
}
|
||||
for (key in Config.filter) {
|
||||
this.filters[key] = [];
|
||||
if (Conf[key] === void 0) {
|
||||
$["delete"](key);
|
||||
continue;
|
||||
}
|
||||
_ref = Conf[key].split('\n');
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
filter = _ref[_i];
|
||||
@ -9178,7 +9188,7 @@
|
||||
|
||||
Sauce = {
|
||||
init: function() {
|
||||
var link, links, _i, _len, _ref;
|
||||
var err, link, links, _i, _len, _ref;
|
||||
|
||||
if (g.VIEW === 'catalog' || !Conf['Sauce']) {
|
||||
return;
|
||||
@ -9190,7 +9200,12 @@
|
||||
if (link[0] === '#') {
|
||||
continue;
|
||||
}
|
||||
links.push(this.createSauceLink(link.trim()));
|
||||
try {
|
||||
links.push(this.createSauceLink(link.trim()));
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!links.length) {
|
||||
return;
|
||||
@ -9570,6 +9585,7 @@
|
||||
};
|
||||
}
|
||||
$.get(Conf, function(Conf) {
|
||||
delete Conf['archives'];
|
||||
data.Conf = Conf;
|
||||
return Settings["export"](now, data);
|
||||
});
|
||||
@ -10027,10 +10043,11 @@
|
||||
}
|
||||
Conf['selectedArchives'] = {};
|
||||
$.get(Conf, Main.initFeatures);
|
||||
$.on(d, '4chanMainInit', Main.initStyle);
|
||||
return $.asap((function() {
|
||||
var _ref;
|
||||
|
||||
return d.head && $('link[rel="shortcut icon"]', d.head) || ((_ref = d.readyState) === 'interactive' || _ref === 'complete');
|
||||
return d.head && $('title', d.head) || ((_ref = d.readyState) === 'interactive' || _ref === 'complete');
|
||||
}), Main.initStyle);
|
||||
},
|
||||
initFeatures: function(items) {
|
||||
@ -10039,6 +10056,9 @@
|
||||
Conf = items;
|
||||
pathname = location.pathname.split('/');
|
||||
g.BOARD = new Board(pathname[1]);
|
||||
if (g.BOARD.ID === 'z') {
|
||||
return;
|
||||
}
|
||||
g.VIEW = (function() {
|
||||
switch (pathname[2]) {
|
||||
case 'res':
|
||||
@ -10154,7 +10174,8 @@
|
||||
initStyle: function() {
|
||||
var MutationObserver, mainStyleSheet, observer, setStyle, style, styleSheets, _ref;
|
||||
|
||||
if (!Main.isThisPageLegit()) {
|
||||
$.off(d, '4chanMainInit', Main.initStyle);
|
||||
if (!Main.isThisPageLegit() || $.hasClass(doc, 'fourchan-x')) {
|
||||
return;
|
||||
}
|
||||
if ((_ref = $('link[href*=mobile]', d.head)) != null) {
|
||||
@ -10267,6 +10288,12 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
localStorage.getItem('4chan-settings');
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
new Notification('warning', 'Cookies need to be enabled on 4chan for 4chan X to properly function.', 30);
|
||||
}
|
||||
$.event('4chanXInitFinished');
|
||||
return Main.checkUpdate();
|
||||
},
|
||||
|
||||
@ -8,6 +8,11 @@ Filter =
|
||||
|
||||
for key of Config.filter
|
||||
@filters[key] = []
|
||||
if Conf[key] is undefined
|
||||
# XXX hopefully tmp fix for the rare people getting this mysterious error:
|
||||
# "Filter" initialization crashed. TypeError: Cannot call method 'split' of undefined
|
||||
$.delete key
|
||||
continue
|
||||
for filter in Conf[key].split '\n'
|
||||
continue if filter[0] is '#'
|
||||
|
||||
@ -272,4 +277,4 @@ Filter =
|
||||
ta = $ 'textarea', section
|
||||
tl = ta.textLength
|
||||
ta.setSelectionRange tl, tl
|
||||
ta.focus()
|
||||
ta.focus()
|
||||
|
||||
@ -18,7 +18,8 @@ Main =
|
||||
|
||||
$.get Conf, Main.initFeatures
|
||||
|
||||
$.asap (-> d.head and $('link[rel="shortcut icon"]', d.head) or d.readyState in ['interactive', 'complete']),\
|
||||
$.on d, '4chanMainInit', Main.initStyle
|
||||
$.asap (-> d.head and $('title', d.head) or d.readyState in ['interactive', 'complete']),
|
||||
Main.initStyle
|
||||
|
||||
initFeatures: (items) ->
|
||||
@ -26,6 +27,7 @@ Main =
|
||||
|
||||
pathname = location.pathname.split '/'
|
||||
g.BOARD = new Board pathname[1]
|
||||
return if g.BOARD.ID is 'z'
|
||||
g.VIEW =
|
||||
switch pathname[2]
|
||||
when 'res'
|
||||
@ -131,7 +133,8 @@ Main =
|
||||
$.ready Main.initReady
|
||||
|
||||
initStyle: ->
|
||||
return unless Main.isThisPageLegit()
|
||||
$.off d, '4chanMainInit', Main.initStyle
|
||||
return if !Main.isThisPageLegit() or $.hasClass doc, 'fourchan-x'
|
||||
# disable the mobile layout
|
||||
$('link[href*=mobile]', d.head)?.disabled = true
|
||||
<% if (type === 'crx') { %>
|
||||
@ -223,6 +226,10 @@ Main =
|
||||
|
||||
return
|
||||
|
||||
try
|
||||
localStorage.getItem '4chan-settings'
|
||||
catch err
|
||||
new Notification 'warning', 'Cookies need to be enabled on 4chan for <%= meta.name %> to properly function.', 30
|
||||
|
||||
$.event '4chanXInitFinished'
|
||||
Main.checkUpdate()
|
||||
|
||||
@ -154,6 +154,8 @@ Settings =
|
||||
Conf[db] = boards: {}
|
||||
# Make sure to export the most recent data.
|
||||
$.get Conf, (Conf) ->
|
||||
# XXX don't export archives.
|
||||
delete Conf['archives']
|
||||
data.Conf = Conf
|
||||
Settings.export now, data
|
||||
return
|
||||
|
||||
@ -59,8 +59,13 @@ class DataBoard
|
||||
val or defaultValue
|
||||
|
||||
clean: ->
|
||||
for boardID of @data.boards
|
||||
@deleteIfEmpty {boardID}
|
||||
for boardID, val of @data.boards
|
||||
# XXX tmp fix for users that had the `null`
|
||||
# value for a board with the Unread features:
|
||||
unless val
|
||||
delete @data.boards[boardID]
|
||||
else
|
||||
@deleteIfEmpty {boardID}
|
||||
|
||||
now = Date.now()
|
||||
if (@data.lastChecked or 0) < now - 2 * $.HOUR
|
||||
|
||||
@ -5,7 +5,11 @@ Sauce =
|
||||
links = []
|
||||
for link in Conf['sauces'].split '\n'
|
||||
continue if link[0] is '#'
|
||||
links.push @createSauceLink link.trim()
|
||||
try
|
||||
links.push @createSauceLink link.trim()
|
||||
catch err
|
||||
# Don't add random text plz.
|
||||
continue
|
||||
return unless links.length
|
||||
@links = links
|
||||
@link = $.el 'a', target: '_blank'
|
||||
@ -39,4 +43,4 @@ Sauce =
|
||||
for link in Sauce.links
|
||||
# \u00A0 is nbsp
|
||||
nodes.push $.tn('\u00A0'), link @, Sauce.link.cloneNode true
|
||||
$.add @file.info, nodes
|
||||
$.add @file.info, nodes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user