diff --git a/4chan_x.user.js b/4chan_x.user.js index 2e474b937..d8068d999 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -73,7 +73,7 @@ */ (function() { - var $, $$, Anonymize, AutoGif, DAY, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, GetTitle, HOUR, ImageExpand, ImageHover, Keybinds, MINUTE, Main, NAMESPACE, Nav, Options, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Redirect, ReplyHiding, ReportButton, RevealSpoilers, SECOND, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Threading, Time, TitlePost, Unread, Updater, VERSION, Watcher, conf, config, d, engine, flatten, g, key, log, qr, ui, val, _base; + var $, $$, Anonymize, AutoGif, DAY, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, GetTitle, HOUR, ImageExpand, ImageHover, Keybinds, MINUTE, Main, NAMESPACE, Nav, Options, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Redirect, ReplyHiding, ReportButton, RevealSpoilers, SECOND, Sauce, StrikethroughQuotes, ThreadHiding, ThreadStats, Threading, Time, TitlePost, Unread, Updater, VERSION, Watcher, conf, config, d, engine, flatten, g, log, qr, ui, _base; config = { main: { @@ -534,11 +534,6 @@ } }); - for (key in conf) { - val = conf[key]; - conf[key] = $.get(key, val); - } - $$ = function(selector, root) { if (root == null) root = d.body; return Array.prototype.slice.call(root.querySelectorAll(selector)); @@ -972,7 +967,7 @@ return $.on(d, 'keydown', Keybinds.keydown); }, keydown: function(e) { - var o, range, selEnd, selStart, ta, thread, value, _ref, _ref2; + var key, o, range, selEnd, selStart, ta, thread, value, _ref, _ref2; if (!(key = Keybinds.keyCode(e)) || /TEXTAREA|INPUT/.test(e.target.nodeName) && !(e.altKey || e.ctrlKey || e.keyCode === 27)) { return; } @@ -1064,7 +1059,7 @@ return e.preventDefault(); }, keyCode: function(e) { - var c, kc; + var c, kc, key; key = (function() { switch (kc = e.keyCode) { case 8: @@ -2372,6 +2367,7 @@ return g.hiddenReplies = {}; }, keybind: function(e) { + var key; if (e.keyCode === 9) return; e.preventDefault(); e.stopPropagation(); @@ -3837,7 +3833,7 @@ Main = { init: function() { - var cutoff, hiddenThreads, id, now, path, pathname, temp, timestamp, _ref; + var cutoff, hiddenThreads, id, key, now, path, pathname, temp, timestamp, val, _ref; path = location.pathname; pathname = path.slice(1).split('/'); g.BOARD = pathname[0], temp = pathname[1]; @@ -3847,6 +3843,10 @@ } else { g.PAGENUM = parseInt(temp) || 0; } + for (key in conf) { + val = conf[key]; + conf[key] = $.get(key, val); + } $.on(window, 'message', Main.message); switch (location.hostname) { case 'sys.4chan.org': diff --git a/script.coffee b/script.coffee index b6331d37b..b5e9667dc 100644 --- a/script.coffee +++ b/script.coffee @@ -449,10 +449,6 @@ $.extend $, name = NAMESPACE + name localStorage[name] = JSON.stringify value -#load values from localStorage -for key, val of conf - conf[key] = $.get key, val - $$ = (selector, root=d.body) -> Array::slice.call root.querySelectorAll selector @@ -3143,6 +3139,10 @@ Main = else g.PAGENUM = parseInt(temp) or 0 + #load values from localStorage + for key, val of conf + conf[key] = $.get key, val + $.on window, 'message', Main.message switch location.hostname