diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 1a9a82b48..1c07afd98 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -11997,7 +11997,7 @@ g.BOARD = new Board(boardID); req = null; onload = function(e) { - var board, mainStyleSheet, newStyleSheet, style, type, _ref; + var board, findStyle, mainStyleSheet, newStyleSheet, sfw, style, type, _ref; if (e.type === 'abort') { req.onloadend = null; return; @@ -12030,10 +12030,20 @@ return; } Navigate.updateTitle(board); - _ref = board.ws_board ? [(d.cookie.match(/ws\_style\=([^;]+)/) || ['', 'Yotsuba B New'])[1], 'ws_style'] : [(d.cookie.match(/nws\_style\=([^;]+)/) || ['', 'Yotsuba New'])[1], 'nws_style'], style = _ref[0], type = _ref[1]; + sfw = !!board.ws_board; + findStyle = function(regex, base) { + var style; + style = d.cookie.match(regex); + return (style ? style[1] : base); + }; + _ref = sfw ? [findStyle(/ws\_style\=([^;]+)/, 'Yotsuba B New'), 'ws_style'] : [findStyle(/nws\_style\=([^;]+)/, 'Yotsuba New'), 'nws_style'], style = _ref[0], type = _ref[1]; $.globalEval("var style_group = '" + type + "'"); mainStyleSheet = $('link[title=switch]', d.head); newStyleSheet = $("link[title='" + style + "']", d.head); + Favicon.SFW = sfw; + Favicon.el.href = "//s.4cdn.org/image/favicon" + (sfw ? '-ws' : '') + ".ico"; + $.add(d.head, Favicon.el); + Favicon["switch"](); mainStyleSheet.href = newStyleSheet.href; return Main.setClass(); }; diff --git a/builds/crx/script.js b/builds/crx/script.js index ec27b5be6..0f6628edd 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -11986,7 +11986,7 @@ g.BOARD = new Board(boardID); req = null; onload = function(e) { - var board, mainStyleSheet, newStyleSheet, style, type, _ref; + var board, findStyle, mainStyleSheet, newStyleSheet, sfw, style, type, _ref; if (e.type === 'abort') { req.onloadend = null; return; @@ -12019,10 +12019,20 @@ return; } Navigate.updateTitle(board); - _ref = board.ws_board ? [(d.cookie.match(/ws\_style\=([^;]+)/) || ['', 'Yotsuba B New'])[1], 'ws_style'] : [(d.cookie.match(/nws\_style\=([^;]+)/) || ['', 'Yotsuba New'])[1], 'nws_style'], style = _ref[0], type = _ref[1]; + sfw = !!board.ws_board; + findStyle = function(regex, base) { + var style; + style = d.cookie.match(regex); + return (style ? style[1] : base); + }; + _ref = sfw ? [findStyle(/ws\_style\=([^;]+)/, 'Yotsuba B New'), 'ws_style'] : [findStyle(/nws\_style\=([^;]+)/, 'Yotsuba New'), 'nws_style'], style = _ref[0], type = _ref[1]; $.globalEval("var style_group = '" + type + "'"); mainStyleSheet = $('link[title=switch]', d.head); newStyleSheet = $("link[title='" + style + "']", d.head); + Favicon.SFW = sfw; + Favicon.el.href = "//s.4cdn.org/image/favicon" + (sfw ? '-ws' : '') + ".ico"; + $.add(d.head, Favicon.el); + Favicon["switch"](); mainStyleSheet.href = newStyleSheet.href; return Main.setClass(); }; diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index 0000c5d7b..539c60977 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -135,11 +135,16 @@ Navigate = return unless board Navigate.updateTitle board - [style, type] = if board.ws_board then [ - (d.cookie.match(/ws\_style\=([^;]+)/) or ['', 'Yotsuba B New'])[1] + sfw = !!board.ws_board + findStyle = (regex, base) -> + style = d.cookie.match regex + return (if style then style[1] else base) + + [style, type] = if sfw then [ + findStyle /ws\_style\=([^;]+)/, 'Yotsuba B New' 'ws_style' ] else [ - (d.cookie.match(/nws\_style\=([^;]+)/) or ['', 'Yotsuba New'])[1] + findStyle /nws\_style\=([^;]+)/, 'Yotsuba New' 'nws_style' ] @@ -148,7 +153,12 @@ Navigate = mainStyleSheet = $ 'link[title=switch]', d.head newStyleSheet = $ "link[title='#{style}']", d.head - mainStyleSheet.href = newStyleSheet.href + Favicon.SFW = sfw + Favicon.el.href = "//s.4cdn.org/image/favicon#{if sfw then '-ws' else ''}.ico" + $.add d.head, Favicon.el # Changing the href alone doesn't update the icon on Firefox + Favicon.switch() + + mainStyleSheet.href = newStyleSheet.href Main.setClass()