diff --git a/builds/4chan-X.js b/builds/4chan-X.js index 7a6814a15..bc18520ef 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -4167,17 +4167,8 @@ el: el, order: 95 }); - return $.asap((function() { - return d.body; - }), function() { - if (!Main.isThisPageLegit()) { - return; - } - return $.asap((function() { - return $.id('boardNavMobile'); - }), function() { - return CatalogLinks.set(input.checked); - }); + return $.on(d, '4chanXInitFinished', function() { + return CatalogLinks.set(Conf['Header catalog links']); }); }, toggle: function() { @@ -4191,7 +4182,7 @@ var a, board, path, _i, _len, _ref; path = useCatalog ? 'catalog' : ''; - _ref = $$('a', $.id('boardNavDesktop')); + _ref = $$('a', $.id('board-list')); for (_i = 0, _len = _ref.length; _i < _len; _i++) { a = _ref[_i]; board = a.pathname.split('/')[1]; @@ -4698,16 +4689,19 @@ }; }, setBoardList: function() { - var a, btn, customBoardList, fullBoardList, nav; + var a, boardList, btn, customBoardList, fullBoardList, nav; Header.nav = nav = $.id('boardNavDesktop'); nav.id = 'header-bar'; if (a = $("a[href*='/" + g.BOARD + "/']", nav)) { a.className = 'current'; } - fullBoardList = $.el('span', { - id: 'full-board-list' + boardList = $.el('span', { + id: 'board-list' }); + $.add(boardList, fullBoardList = $.el('span', { + id: 'full-board-list' + })); Header.setBarPosition.call({ textContent: "" + Conf['Boards Navigation'] }); @@ -4715,13 +4709,13 @@ Header.setBarVisibility(Conf['Header auto-hide']); $.sync('Header auto-hide', Header.setBarVisibility); $.add(fullBoardList, __slice.call(nav.childNodes)); - $.add(nav, [fullBoardList, Header.shortcuts, Header.bar, Header.toggle]); + $.add(nav, [boardList, Header.shortcuts, Header.bar, Header.toggle]); if (Conf['Custom Board Navigation']) { fullBoardList.hidden = true; customBoardList = $.el('span', { id: 'custom-board-list' }); - $.before(fullBoardList, customBoardList); + $.add(boardList, customBoardList); Header.generateBoardList(Conf['boardnav']); $.sync('boardnav', Header.generateBoardList); btn = $.el('span', { diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 7b2e74c12..bc1aa2a02 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4158,17 +4158,8 @@ el: el, order: 95 }); - return $.asap((function() { - return d.body; - }), function() { - if (!Main.isThisPageLegit()) { - return; - } - return $.asap((function() { - return $.id('boardNavMobile'); - }), function() { - return CatalogLinks.set(input.checked); - }); + return $.on(d, '4chanXInitFinished', function() { + return CatalogLinks.set(Conf['Header catalog links']); }); }, toggle: function() { @@ -4182,7 +4173,7 @@ var a, board, path, _i, _len, _ref; path = useCatalog ? 'catalog' : ''; - _ref = $$('a', $.id('boardNavDesktop')); + _ref = $$('a', $.id('board-list')); for (_i = 0, _len = _ref.length; _i < _len; _i++) { a = _ref[_i]; board = a.pathname.split('/')[1]; @@ -4689,16 +4680,19 @@ }; }, setBoardList: function() { - var a, btn, customBoardList, fullBoardList, nav; + var a, boardList, btn, customBoardList, fullBoardList, nav; Header.nav = nav = $.id('boardNavDesktop'); nav.id = 'header-bar'; if (a = $("a[href*='/" + g.BOARD + "/']", nav)) { a.className = 'current'; } - fullBoardList = $.el('span', { - id: 'full-board-list' + boardList = $.el('span', { + id: 'board-list' }); + $.add(boardList, fullBoardList = $.el('span', { + id: 'full-board-list' + })); Header.setBarPosition.call({ textContent: "" + Conf['Boards Navigation'] }); @@ -4706,13 +4700,13 @@ Header.setBarVisibility(Conf['Header auto-hide']); $.sync('Header auto-hide', Header.setBarVisibility); $.add(fullBoardList, __slice.call(nav.childNodes)); - $.add(nav, [fullBoardList, Header.shortcuts, Header.bar, Header.toggle]); + $.add(nav, [boardList, Header.shortcuts, Header.bar, Header.toggle]); if (Conf['Custom Board Navigation']) { fullBoardList.hidden = true; customBoardList = $.el('span', { id: 'custom-board-list' }); - $.before(fullBoardList, customBoardList); + $.add(boardList, customBoardList); Header.generateBoardList(Conf['boardnav']); $.sync('boardnav', Header.generateBoardList); btn = $.el('span', { diff --git a/builds/crx.crx b/builds/crx.crx index 86fd3b1b8..30b9027aa 100644 Binary files a/builds/crx.crx and b/builds/crx.crx differ diff --git a/builds/crx/script.js b/builds/crx/script.js index 13c630f2e..7978d4e79 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4081,17 +4081,8 @@ el: el, order: 95 }); - return $.asap((function() { - return d.body; - }), function() { - if (!Main.isThisPageLegit()) { - return; - } - return $.asap((function() { - return $.id('boardNavMobile'); - }), function() { - return CatalogLinks.set(input.checked); - }); + return $.on(d, '4chanXInitFinished', function() { + return CatalogLinks.set(Conf['Header catalog links']); }); }, toggle: function() { @@ -4105,7 +4096,7 @@ var a, board, path, _i, _len, _ref; path = useCatalog ? 'catalog' : ''; - _ref = $$('a', $.id('boardNavDesktop')); + _ref = $$('a', $.id('board-list')); for (_i = 0, _len = _ref.length; _i < _len; _i++) { a = _ref[_i]; board = a.pathname.split('/')[1]; @@ -4612,16 +4603,19 @@ }; }, setBoardList: function() { - var a, btn, customBoardList, fullBoardList, nav; + var a, boardList, btn, customBoardList, fullBoardList, nav; Header.nav = nav = $.id('boardNavDesktop'); nav.id = 'header-bar'; if (a = $("a[href*='/" + g.BOARD + "/']", nav)) { a.className = 'current'; } - fullBoardList = $.el('span', { - id: 'full-board-list' + boardList = $.el('span', { + id: 'board-list' }); + $.add(boardList, fullBoardList = $.el('span', { + id: 'full-board-list' + })); Header.setBarPosition.call({ textContent: "" + Conf['Boards Navigation'] }); @@ -4629,13 +4623,13 @@ Header.setBarVisibility(Conf['Header auto-hide']); $.sync('Header auto-hide', Header.setBarVisibility); $.add(fullBoardList, __slice.call(nav.childNodes)); - $.add(nav, [fullBoardList, Header.shortcuts, Header.bar, Header.toggle]); + $.add(nav, [boardList, Header.shortcuts, Header.bar, Header.toggle]); if (Conf['Custom Board Navigation']) { fullBoardList.hidden = true; customBoardList = $.el('span', { id: 'custom-board-list' }); - $.before(fullBoardList, customBoardList); + $.add(boardList, customBoardList); Header.generateBoardList(Conf['boardnav']); $.sync('boardnav', Header.generateBoardList); btn = $.el('span', { diff --git a/src/features/misc/cataloglinks.coffee b/src/features/misc/cataloglinks.coffee index 90ee4ffce..2c67cb29b 100644 --- a/src/features/misc/cataloglinks.coffee +++ b/src/features/misc/cataloglinks.coffee @@ -6,7 +6,7 @@ CatalogLinks = href: 'javascript:;' innerHTML: "Catalog" title: "Turn catalog links #{if Conf['Header catalog links'] then 'off' else 'on'}." - + input = $ 'input', el $.on input, 'change', @toggle $.sync 'Header catalog links', CatalogLinks.set @@ -16,22 +16,18 @@ CatalogLinks = el: el order: 95 - $.asap (-> d.body), -> - return unless Main.isThisPageLegit() - # Wait for #boardNavMobile instead of #boardNavDesktop, - # it might be incomplete otherwise. - $.asap (-> $.id 'boardNavMobile'), -> - # Set links on load. - CatalogLinks.set input.checked + $.on d, '4chanXInitFinished', -> + # Set links on load. + CatalogLinks.set Conf['Header catalog links'] toggle: -> $.event 'CloseMenu' $.set 'Header catalog links', useCatalog = @checked CatalogLinks.set useCatalog - + set: (useCatalog) -> path = if useCatalog then 'catalog' else '' - for a in $$ 'a', $.id('boardNavDesktop') + for a in $$ 'a', $.id('board-list') board = a.pathname.split('/')[1] continue if ['f', 'status', '4chan'].contains(board) or !board if Conf['External Catalog'] diff --git a/src/features/misc/header.coffee b/src/features/misc/header.coffee index db29d6803..d7caf1549 100644 --- a/src/features/misc/header.coffee +++ b/src/features/misc/header.coffee @@ -80,8 +80,11 @@ Header = if a = $ "a[href*='/#{g.BOARD}/']", nav a.className = 'current' - fullBoardList = $.el 'span', - id: 'full-board-list' + boardList = $.el 'span', + id: 'board-list' + + $.add boardList, fullBoardList = $.el 'span', + id: 'full-board-list' Header.setBarPosition.call textContent: "#{Conf['Boards Navigation']}" $.sync 'Boards Navigation', Header.changeBarPosition @@ -90,13 +93,13 @@ Header = $.sync 'Header auto-hide', Header.setBarVisibility $.add fullBoardList, [nav.childNodes...] - $.add nav, [fullBoardList, Header.shortcuts, Header.bar, Header.toggle] + $.add nav, [boardList, Header.shortcuts, Header.bar, Header.toggle] if Conf['Custom Board Navigation'] fullBoardList.hidden = true customBoardList = $.el 'span', - id: 'custom-board-list' - $.before fullBoardList, customBoardList + id: 'custom-board-list' + $.add boardList, customBoardList Header.generateBoardList Conf['boardnav'] $.sync 'boardnav', Header.generateBoardList