From eb0b2399b6fc9874969c2cf40ed4cb50d7b34e24 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 11 Feb 2012 18:22:59 +0100 Subject: [PATCH] Refactor options.init. --- 4chan_x.user.js | 26 +++++++++++--------------- script.coffee | 18 ++++++------------ 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 5c278cdb0..97164bf0a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1994,21 +1994,17 @@ options = { init: function() { - var a, home; - home = $('#navtopr a'); - a = $.el('a', { - textContent: '4chan X', - href: 'javascript:;' - }); - $.on(a, 'click', options.dialog); - $.replace(home, a); - home = $('#navbotr a'); - a = $.el('a', { - textContent: '4chan X', - href: 'javascript:;' - }); - $.on(a, 'click', options.dialog); - $.replace(home, a); + var a, home, _i, _len, _ref; + _ref = [$.id('navtopr'), $.id('navbotr')]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + home = _ref[_i]; + a = $.el('a', { + textContent: '4chan X', + href: 'javascript:;' + }); + $.on(a, 'click', options.dialog); + $.replace(home.firstElementChild, a); + } if (!$.get('firstrun')) { $.set('firstrun', true); return options.dialog(); diff --git a/script.coffee b/script.coffee index 20bb1f9fb..e6ff14ed2 100644 --- a/script.coffee +++ b/script.coffee @@ -1539,18 +1539,12 @@ qr = options = init: -> - home = $ '#navtopr a' - a = $.el 'a', - textContent: '4chan X' - href: 'javascript:;' - $.on a, 'click', options.dialog - $.replace home, a - home = $ '#navbotr a' - a = $.el 'a', - textContent: '4chan X' - href: 'javascript:;' - $.on a, 'click', options.dialog - $.replace home, a + for home in [$.id('navtopr'), $.id('navbotr')] + a = $.el 'a', + textContent: '4chan X' + href: 'javascript:;' + $.on a, 'click', options.dialog + $.replace home.firstElementChild, a unless $.get 'firstrun' $.set 'firstrun', true options.dialog()