diff --git a/src/Filtering/ThreadHiding.coffee b/src/Filtering/ThreadHiding.coffee index 24cbab960..843148de9 100755 --- a/src/Filtering/ThreadHiding.coffee +++ b/src/Filtering/ThreadHiding.coffee @@ -9,6 +9,7 @@ ThreadHiding = cb: @node catalogSet: (board) -> + return unless $.hasStorage hiddenThreads = ThreadHiding.db.get boardID: board.ID defaultValue: {} @@ -16,6 +17,7 @@ ThreadHiding = localStorage.setItem "4chan-hide-t-#{board}", JSON.stringify hiddenThreads catalogWatch: -> + return unless $.hasStorage @hiddenThreads = JSON.parse(localStorage.getItem "4chan-hide-t-#{g.BOARD}") or {} Main.ready -> # 4chan's catalog sets the style to "display: none;" when hiding or unhiding a thread. diff --git a/src/General/Main.coffee b/src/General/Main.coffee index d86533d8b..d019e2afe 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -43,8 +43,12 @@ Main = $.get items, (items) -> $.asap (-> doc = d.documentElement), -> + # Don't hide the local storage warning behind a settings panel. + if $.cantSet + # pass + # Fresh install - if !items.previousversion? + else if !items.previousversion? Main.ready -> $.set 'previousversion', g.VERSION Settings.open() @@ -205,10 +209,16 @@ Main = $.event '4chanXInitFinished' if Conf['Show Support Message'] - try - localStorage.getItem '4chan-settings' - catch err - new Notice 'warning', 'Cookies need to be enabled on 4chan for <%= meta.name %> to operate properly.', 30 + if $.cantSync + why = if $.cantSet + 'save your settings' + else + 'synchronize data between tabs' + new Notice 'warning', """ + <%= meta.name %> needs local storage to #{why}. + Enable it on boards.4chan.org in your browser's privacy settings + (may be listed as part of "local data" or "cookies"). + """ initThread: -> if board = $ '.board' diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 2029a3e73..1e7396361 100755 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -21,7 +21,7 @@ Settings = $.on d, 'AddSettingsSection', Settings.addSection $.on d, 'OpenSettings', (e) -> Settings.open e.detail - if Conf['Disable Native Extension'] + if Conf['Disable Native Extension'] and $.hasStorage settings = JSON.parse(localStorage.getItem '4chan-settings') or {} return if settings.disableAll settings.disableAll = true @@ -140,8 +140,9 @@ Settings = $.on button, 'click', -> @textContent = 'Hidden: 0' $.get 'hiddenThreads', {}, ({hiddenThreads}) -> - for boardID of hiddenThreads.boards - localStorage.removeItem "4chan-hide-t-#{boardID}" + if $.hasStorage + for boardID of hiddenThreads.boards + localStorage.removeItem "4chan-hide-t-#{boardID}" $.delete ['hiddenThreads', 'hiddenPosts'] $.after $('input[name="Stubs"]', section).parentNode.parentNode, div diff --git a/src/General/css/style.css b/src/General/css/style.css index e009d4c61..faa237ae6 100755 --- a/src/General/css/style.css +++ b/src/General/css/style.css @@ -430,6 +430,7 @@ audio.controls-added { max-height: 200px; width: 100%; overflow: auto; + white-space: pre-line; } /* Settings */ diff --git a/src/General/lib/$.coffee b/src/General/lib/$.coffee index 5cb9205a0..071b6e07a 100755 --- a/src/General/lib/$.coffee +++ b/src/General/lib/$.coffee @@ -338,6 +338,12 @@ $.engine = do -> return 'webkit' if /WebKit\//.test navigator.userAgent return 'gecko' if /Gecko\/|Goanna/.test navigator.userAgent # Goanna = Pale Moon 26+ +try + localStorage.getItem 'x' + $.hasStorage = true +catch err + $.hasStorage = false + $.item = (key, val) -> item = {} item[key] = val @@ -456,10 +462,13 @@ do -> if GM_deleteValue? $.getValue = GM_getValue $.listValues = -> GM_listValues() # error when called if missing -else +else if $.hasStorage $.getValue = (key) -> localStorage[key] $.listValues = -> key for key of localStorage when key[...g.NAMESPACE.length] is g.NAMESPACE +else + $.getValue = -> + $.listValues = -> [] if GM_addValueChangeListener? $.setValue = GM_setValue @@ -470,13 +479,14 @@ else if GM_deleteValue? GM_setValue key, val if key of $.syncing $.oldValue[key] = val - localStorage[key] = val # for `storage` events + localStorage[key] = val if $.hasStorage # for `storage` events $.deleteValue = (key) -> GM_deleteValue key if key of $.syncing delete $.oldValue[key] - delete localStorage[key] # for `storage` events -else + delete localStorage[key] if $.hasStorage # for `storage` events + $.cantSync = true if !$.hasStorage +else if $.hasStorage $.oldValue = {} $.setValue = (key, val) -> $.oldValue[key] = val if key of $.syncing @@ -484,6 +494,10 @@ else $.deleteValue = (key) -> delete $.oldValue[key] if key of $.syncing delete localStorage[key] +else + $.setValue = -> + $.deleteValue = -> + $.cantSync = $.cantSet = true if GM_addValueChangeListener? $.sync = (key, cb) -> @@ -492,7 +506,7 @@ if GM_addValueChangeListener? newValue = JSON.parse newValue unless newValue is undefined cb newValue, key $.forceSync = -> -else +else if $.hasStorage $.sync = (key, cb) -> key = g.NAMESPACE + key $.syncing[key] = cb @@ -516,6 +530,9 @@ else # e.g. http://boards.4chan.org and https://boards.4chan.org # so force a check for changes to avoid lost data. onChange g.NAMESPACE + key +else + $.sync = -> + $.forceSync = -> $.delete = (keys) -> unless keys instanceof Array diff --git a/src/Miscellaneous/Flash.coffee b/src/Miscellaneous/Flash.coffee index dc52ce8f1..7f9084832 100644 --- a/src/Miscellaneous/Flash.coffee +++ b/src/Miscellaneous/Flash.coffee @@ -4,4 +4,7 @@ Flash = $.ready Flash.initReady initReady: -> - $.globalEval 'if (JSON.parse(localStorage["4chan-settings"] || "{}").disableAll) SWFEmbed.init();' + if $.hasStorage + $.global -> window.SWFEmbed.init() if JSON.parse(localStorage['4chan-settings'] or '{}').disableAll + else + $.global -> window.SWFEmbed.init()