diff --git a/4chan_x.user.js b/4chan_x.user.js index dbe75ca8b..c22cdf76b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1959,6 +1959,7 @@ $.replace(home.firstElementChild, a); } if (!$.get('firstrun')) { + if (!Favicon.el) Favicon.init(); $.set('firstrun', true); return Options.dialog(); } @@ -3320,6 +3321,7 @@ Favicon = { init: function() { var href; + if (this.el) return; this.el = $('link[rel="shortcut icon"]', d.head); this.el.type = 'image/x-icon'; href = this.el.href; diff --git a/script.coffee b/script.coffee index e10dc9695..c38bbbbdf 100644 --- a/script.coffee +++ b/script.coffee @@ -1644,6 +1644,8 @@ Options = $.on a, 'click', Options.dialog $.replace home.firstElementChild, a unless $.get 'firstrun' + # Prevent race conditions + Favicon.init() unless Favicon.el $.set 'firstrun', true Options.dialog() @@ -2809,6 +2811,7 @@ Unread = Favicon = init: -> + return if @el # Prevent race condition with options first run @el = $ 'link[rel="shortcut icon"]', d.head @el.type = 'image/x-icon' {href} = @el