diff --git a/lib/$.coffee b/lib/$.coffee index bfea3c47f..8b2202304 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -211,7 +211,7 @@ $.sync = do -> chrome.storage.onChanged.addListener (changes) -> for key of changes if cb = $.syncing[key] - cb changes[key].newValue + cb changes[key].newValue, key return (key, cb) -> $.syncing[key] = cb $.localKeys = [ @@ -289,9 +289,9 @@ $.set = do -> <% } else { %> # http://wiki.greasespot.net/Main_Page $.sync = do -> - $.on window, 'storage', (e) -> - if cb = $.syncing[e.key] - cb JSON.parse e.newValue + $.on window, 'storage', ({key, newValue}) -> + if cb = $.syncing[key] + cb JSON.parse(newValue), key (key, cb) -> $.syncing[g.NAMESPACE + key] = cb $.delete = (keys) -> unless keys instanceof Array diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index 36c193e97..a06a6043b 100644 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -2,6 +2,9 @@ Keybinds = init: -> return if g.VIEW is 'catalog' or !Conf['Keybinds'] + for hotkey of Conf.hotkeys + $.sync hotkey, Keybinds.sync + init = -> $.off d, '4chanXInitFinished', init $.on d, 'keydown', Keybinds.keydown @@ -10,6 +13,9 @@ Keybinds = return $.on d, '4chanXInitFinished', init + sync: (key, hotkey) -> + Conf[hotkey] = key + keydown: (e) -> return unless key = Keybinds.keyCode e {target} = e