From 8fe05bee37028d172265a0d3451ca7739d733d9b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 2 Apr 2012 12:21:46 +0200 Subject: [PATCH] Fix #367 --- 4chan_x.user.js | 2 ++ script.coffee | 3 +++ 2 files changed, 5 insertions(+) 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