diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index b2de42b15..9e0fc2da3 100755 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -10338,8 +10338,26 @@ }; Main = { - init: function(items) { - var db, flatten, _i, _len; + init: function() { + var db, flatten, pathname, _i, _len, _ref; + pathname = location.pathname.split('/'); + g.BOARD = new Board(pathname[1]); + if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') { + return; + } + g.VIEW = (function() { + switch (pathname[2]) { + case 'res': + return 'thread'; + case 'catalog': + return 'catalog'; + default: + return 'index'; + } + })(); + if (g.VIEW === 'thread') { + g.THREADID = +pathname[3]; + } flatten = function(parent, obj) { var key, val; if (obj instanceof Array) { @@ -10362,15 +10380,18 @@ } Conf['selectedArchives'] = {}; Conf['CachedTitles'] = []; - $.get(Conf, Main.initFeatures); + Conf['archives'] = Redirect.archives; + $.get(Conf, function(items) { + $.extend(Conf, items); + return Main.initFeatures(); + }); $.on(d, '4chanMainInit', Main.initStyle); return $.asap((function() { return d.head && $('link[rel="shortcut icon"]', d.head) || d.readyState !== 'loading'; }), Main.initStyle); }, - initFeatures: function(items) { + initFeatures: function() { var init, pathname, _ref; - Conf = items; pathname = location.pathname.split('/'); g.BOARD = new Board(pathname[1]); if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') { @@ -10543,9 +10564,7 @@ } return; } - if (!$.hasClass(doc, 'fourchan-x')) { - Main.initStyle(); - } + Main.initStyle(); if (board = $('.board')) { threads = []; posts = []; diff --git a/builds/crx/script.js b/builds/crx/script.js index fc21d7fa3..9a24d2b99 100755 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -10323,8 +10323,26 @@ }; Main = { - init: function(items) { - var db, flatten, _i, _len; + init: function() { + var db, flatten, pathname, _i, _len, _ref; + pathname = location.pathname.split('/'); + g.BOARD = new Board(pathname[1]); + if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') { + return; + } + g.VIEW = (function() { + switch (pathname[2]) { + case 'res': + return 'thread'; + case 'catalog': + return 'catalog'; + default: + return 'index'; + } + })(); + if (g.VIEW === 'thread') { + g.THREADID = +pathname[3]; + } flatten = function(parent, obj) { var key, val; if (obj instanceof Array) { @@ -10347,15 +10365,27 @@ } Conf['selectedArchives'] = {}; Conf['CachedTitles'] = []; - $.get(Conf, Main.initFeatures); + Conf['archives'] = Redirect.archives; + $.get(Conf, function(items) { + $.extend(Conf, items); + if (!items) { + new Notification('error', $.el('span', { + innerHTML: "It seems like your 4chan X settings became corrupted due to a Chrome bug.
\nUnfortunately, you'll have to fix it yourself." + })); + Main.logError({ + message: 'Chrome Storage API bug', + error: new Error(chrome.runtime.lastError.message || 'no lastError.message') + }); + } + return Main.initFeatures(); + }); $.on(d, '4chanMainInit', Main.initStyle); return $.asap((function() { return d.head && $('link[rel="shortcut icon"]', d.head) || d.readyState !== 'loading'; }), Main.initStyle); }, - initFeatures: function(items) { + initFeatures: function() { var init, pathname, _ref; - Conf = items; pathname = location.pathname.split('/'); g.BOARD = new Board(pathname[1]); if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') { @@ -10528,9 +10558,7 @@ } return; } - if (!$.hasClass(doc, 'fourchan-x')) { - Main.initStyle(); - } + Main.initStyle(); if (board = $('.board')) { threads = []; posts = []; diff --git a/src/General/Main.coffee b/src/General/Main.coffee index f79be109b..996f17d97 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -1,5 +1,18 @@ Main = - init: (items) -> + init: -> + pathname = location.pathname.split '/' + g.BOARD = new Board pathname[1] + return if g.BOARD.ID in ['z', 'fk'] + g.VIEW = + switch pathname[2] + when 'res' + 'thread' + when 'catalog' + 'catalog' + else + 'index' + if g.VIEW is 'thread' + g.THREADID = +pathname[3] # flatten Config into Conf # and get saved or default values flatten = (parent, obj) -> @@ -16,15 +29,28 @@ Main = Conf[db] = boards: {} Conf['selectedArchives'] = {} Conf['CachedTitles'] = [] - - $.get Conf, Main.initFeatures + Conf['archives'] = Redirect.archives + $.get Conf, (items) -> + $.extend Conf, items + <% if (type === 'crx') { %> + unless items + new Notification 'error', $.el 'span', + innerHTML: """ + It seems like your <%= meta.name %> settings became corrupted due to a Chrome bug.
+ Unfortunately, you'll have to fix it yourself. + """ + # Track resolution of this bug. + Main.logError + message: 'Chrome Storage API bug' + error: new Error chrome.runtime.lastError.message or 'no lastError.message' + <% } %> + Main.initFeatures() $.on d, '4chanMainInit', Main.initStyle $.asap (-> d.head and $('link[rel="shortcut icon"]', d.head) or d.readyState isnt 'loading'), Main.initStyle - initFeatures: (items) -> - Conf = items + initFeatures: -> pathname = location.pathname.split '/' g.BOARD = new Board pathname[1] @@ -39,7 +65,6 @@ Main = 'index' if g.VIEW is 'thread' g.THREADID = +pathname[3] - switch location.hostname when 'api.4chan.org' return @@ -180,9 +205,8 @@ Main = location.replace href or "/#{g.BOARD}/" return - unless $.hasClass doc, 'fourchan-x' - # Something might have gone wrong! - Main.initStyle() + # Something might have gone wrong! + Main.initStyle() if board = $ '.board' threads = [] diff --git a/src/General/html/Monitoring/ThreadWatcher.html b/src/General/html/Monitoring/ThreadWatcher.html old mode 100644 new mode 100755