From 97da6173f9a089d3ed430aa1d930d005ab386a67 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 12 May 2013 22:41:23 +0200 Subject: [PATCH 01/16] Some people add random text instead of real sauce links. --- src/Miscellaneous/Sauce.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Miscellaneous/Sauce.coffee b/src/Miscellaneous/Sauce.coffee index 82d39d86a..7c4892862 100644 --- a/src/Miscellaneous/Sauce.coffee +++ b/src/Miscellaneous/Sauce.coffee @@ -5,7 +5,11 @@ Sauce = links = [] for link in Conf['sauces'].split '\n' continue if link[0] is '#' - links.push @createSauceLink link.trim() + try + links.push @createSauceLink link.trim() + catch err + # Don't add random text plz. + continue return unless links.length @links = links @link = $.el 'a', target: '_blank' From df21f89d0266b83731077c2d36dec20cc576a51e Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 12 May 2013 23:10:32 +0200 Subject: [PATCH 02/16] Let's try to identify a bug. --- src/General/DataBoard.coffee | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/General/DataBoard.coffee b/src/General/DataBoard.coffee index 893de9edb..499ffccca 100644 --- a/src/General/DataBoard.coffee +++ b/src/General/DataBoard.coffee @@ -57,7 +57,16 @@ class DataBoard clean: -> for boardID of @data.boards - @deleteIfEmpty {boardID} + try + @deleteIfEmpty {boardID} + catch err + # XXX I get obscure reports of: + # "Unread" initialization crashed. TypeError: Object.keys called on non-object + # comming from here, gotta figure out why that happens. + Main.logError + message: "Couldn't deleteIfEmpty on:\n#{JSON.stringify @data}\n" + error: err + delete @data.boards[boardID] now = Date.now() if (@data.lastChecked or 0) < now - 2 * $.HOUR From 5267b93317f2370095c4e630091ab7f8bc464160 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 12 May 2013 23:16:03 +0200 Subject: [PATCH 03/16] Don't export archives. --- src/General/Settings.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 93f9f14e7..bf4610001 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -175,6 +175,8 @@ Settings = Conf[db] = boards: {} # Make sure to export the most recent data. $.get Conf, (Conf) -> + # XXX don't export archives. + delete Conf['archives'] data.Conf = Conf Settings.export now, data return From 6e1109d9a9ad949d7ac0d76d1f77b97b462246b4 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 12 May 2013 23:30:16 +0200 Subject: [PATCH 04/16] Attempt to fix some obscure Redirect initialization bugs. --- src/Archive/Redirect.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index b02253e5c..f39721cd3 100644 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -5,6 +5,14 @@ Redirect = file: {} init: -> + try + Conf['archives'].length + catch err + # XXX I get obscure reports of: + # "Redirect" initialization crashed. TypeError: Cannot read property 'length' of undefined + # comming from here. + Conf['archives'] = Redirect.archives + $.delete ['archives', 'lastarchivecheck'] Redirect.update() for boardID, data of Conf['selectedArchives'] From efa99a29b0a7542d4884bf0e2978a3a033e3f44c Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 12 May 2013 23:36:17 +0200 Subject: [PATCH 05/16] Warn users that have cookies disabled. --- src/General/Main.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index d54a6aff2..9cb8663b2 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -198,6 +198,12 @@ Main = if $.hasClass d.body, 'fourchan_x' alert '4chan X v2 detected: Disable it or v3 will break.' + + try + localStorage.getItem '4chan-settings' + catch err + new Notification 'warning', 'Cookies need to be enabled on 4chan for <%= meta.name %> to properly function.', 30 + <% if (type === 'userscript') { %> el = $.el 'span' el.style.flex = 'test' From f072e68f6eabcfbbf83c5835a241d8b690657406 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 12 May 2013 23:53:15 +0200 Subject: [PATCH 06/16] Close #1087. --- CHANGELOG.md | 2 ++ src/General/Config.coffee | 1 + src/Posting/QR.coffee | 3 +++ 3 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fa94b692..0e36ec55b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- Added the option `Tab to Choose Files First`, disabled by default. + ## 3.4.0 - *2013-05-06* - **New feature**: `Archive selection` diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 19df555be..a219525ae 100644 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -61,6 +61,7 @@ Config = 'Hide Original Post Form': [true, 'Hide the normal post form.'] 'Cooldown': [true, 'Indicate the remaining time before posting again.'] 'Cooldown Prediction': [true, 'Decrease the cooldown time by taking into account upload speed. Disable it if it\'s inaccurate for you.'] + 'Tab to Choose Files First': [false, 'Tab to the file input before the submit button.'] 'Quote Links': 'Quote Backlinks': [true, 'Add quote backlinks.'] 'OP Backlinks': [true, 'Add backlinks to the OP.'] diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index b0e25f14a..d6bb1d39b 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -819,6 +819,9 @@ QR = status: $ '[type=submit]', dialog fileInput: $ '[type=file]', dialog + if Conf['Tab to Choose Files First'] + $.add nodes.fileSubmit, nodes.status + # Allow only this board's supported files. mimeTypes = $('ul.rules > li').textContent.trim().match(/: (.+)/)[1].toLowerCase().replace /\w+/g, (type) -> switch type From ebfa224fe377b5a2795402d8840cc81a106ee47a Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 12 May 2013 23:56:50 +0200 Subject: [PATCH 07/16] Actually, let's keep listening to 4chanMainInit, it guarantees that we don't get FOUC'd on the index/in threads. --- src/General/Main.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 9cb8663b2..10bf5ebd5 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -18,6 +18,7 @@ Main = Conf['archives'] = Redirect.archives $.get Conf, Main.initFeatures + $.on d, '4chanMainInit', Main.initStyle $.asap (-> d.head and $('link[rel="shortcut icon"]', d.head) or d.readyState in ['interactive', 'complete']), Main.initStyle @@ -119,7 +120,8 @@ Main = $.ready Main.initReady initStyle: -> - return unless Main.isThisPageLegit() + $.off d, '4chanMainInit', Main.initStyle + return if !Main.isThisPageLegit() or $.hasClass doc, 'fourchan-x' # disable the mobile layout $('link[href*=mobile]', d.head)?.disabled = true <% if (type === 'crx') { %> From e9b8db87d8d5eecb0eeb1107f809c3c0c705049a Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 13 May 2013 00:21:12 +0200 Subject: [PATCH 08/16] Add a button to update the archive list. Also display the last update time. --- html/General/Settings-section-Archives.html | 1 + src/Archive/Redirect.coffee | 3 ++- src/General/Settings.coffee | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/html/General/Settings-section-Archives.html b/html/General/Settings-section-Archives.html index 086b33d92..4ee9bd1e5 100644 --- a/html/General/Settings-section-Archives.html +++ b/html/General/Settings-section-Archives.html @@ -1,5 +1,6 @@
404 Redirect is disabled.

Disabled selections indicate that only one archive is available for that board and redirection type.

+

Last updated:

diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index f39721cd3..1061f087c 100644 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -34,7 +34,7 @@ Redirect = Redirect.file[boardID] = archive return - update: -> + update: (cb) -> $.get 'lastarchivecheck', 0, ({lastarchivecheck}) -> now = Date.now() # Update the list of archives every 4 days. @@ -46,6 +46,7 @@ Redirect = $.set lastarchivecheck: now archives: Conf['archives'] + cb now if cb to: (dest, data) -> archive = (if dest is 'search' then Redirect.thread else Redirect[dest])[data.boardID] diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index bf4610001..4a42e183d 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -399,6 +399,20 @@ Settings = <%= grunt.file.read('html/General/Settings-section-Archives.html').replace(/>\s+<').trim() %> """ + showLastUpdateTime = (time) -> + $('time', section).textContent = new Date(time).toLocaleString() + + button = $ 'button', section + $.on button, 'click', -> + $.delete 'lastarchivecheck' + button.textContent = '...' + button.disabled = true + Redirect.update (time) -> + button.textContent = 'Updated' + showLastUpdateTime time + + $.get 'lastarchivecheck', 0, ({lastarchivecheck}) -> showLastUpdateTime lastarchivecheck + boards = {} for archive in Conf['archives'] for boardID in archive.boards From fccbad5d3613899a9bba5f30bd59db0aecdd916c Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 13 May 2013 00:24:08 +0200 Subject: [PATCH 09/16] Changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e36ec55b..f8849c8b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +- Added a button in the Archives settings to update the list now. - Added the option `Tab to Choose Files First`, disabled by default. ## 3.4.0 - *2013-05-06* From a43bc821cabbc5a124cab6d9687f592cf066f546 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 13 May 2013 00:24:20 +0200 Subject: [PATCH 10/16] Release 4chan X v3.4.1. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8849c8b4..23c1cc93a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +### 3.4.1 - *2013-05-13* + - Added a button in the Archives settings to update the list now. - Added the option `Tab to Choose Files First`, disabled by default. diff --git a/package.json b/package.json index d9ade39d0..f719b466e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.4.0", + "version": "3.4.1", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X", From fd3d898f757c5acbc900a63e47cecf91744f03a8 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 13 May 2013 00:34:33 +0200 Subject: [PATCH 11/16] cb? now --- src/Archive/Redirect.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index 1061f087c..3a381510a 100644 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -46,7 +46,7 @@ Redirect = $.set lastarchivecheck: now archives: Conf['archives'] - cb now if cb + cb? now to: (dest, data) -> archive = (if dest is 'search' then Redirect.thread else Redirect[dest])[data.boardID] From 215761557dd42ac7e2d237faea2a67ae6dd4ae09 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 13 May 2013 18:44:22 +0200 Subject: [PATCH 12/16] Looks like some users had a `null` value on a board with the Unread features. No idea how that could have happened. --- src/General/DataBoard.coffee | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/General/DataBoard.coffee b/src/General/DataBoard.coffee index 499ffccca..1d6d30a3f 100644 --- a/src/General/DataBoard.coffee +++ b/src/General/DataBoard.coffee @@ -56,17 +56,13 @@ class DataBoard val or defaultValue clean: -> - for boardID of @data.boards - try - @deleteIfEmpty {boardID} - catch err - # XXX I get obscure reports of: - # "Unread" initialization crashed. TypeError: Object.keys called on non-object - # comming from here, gotta figure out why that happens. - Main.logError - message: "Couldn't deleteIfEmpty on:\n#{JSON.stringify @data}\n" - error: err + for boardID, val of @data.boards + # XXX tmp fix for users that had the `null` + # value for a board with the Unread features: + unless val delete @data.boards[boardID] + else + @deleteIfEmpty {boardID} now = Date.now() if (@data.lastChecked or 0) < now - 2 * $.HOUR From 8b7ab800698446fb8247e25054c7a9fc0b3473e1 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 14 May 2013 00:02:27 +0200 Subject: [PATCH 13/16] That's silly. #1093 --- src/General/Main.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 10bf5ebd5..08739ac01 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -19,7 +19,7 @@ Main = $.get Conf, Main.initFeatures $.on d, '4chanMainInit', Main.initStyle - $.asap (-> d.head and $('link[rel="shortcut icon"]', d.head) or d.readyState in ['interactive', 'complete']), + $.asap (-> d.head and $('title', d.head) or d.readyState in ['interactive', 'complete']), Main.initStyle initFeatures: (items) -> From 74f9df889a05c4cb53714aae98678b90312c4796 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 14 May 2013 00:10:31 +0200 Subject: [PATCH 14/16] We need these g.'s ASAP. --- src/General/Main.coffee | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 08739ac01..e502816d4 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -18,13 +18,6 @@ Main = Conf['archives'] = Redirect.archives $.get Conf, Main.initFeatures - $.on d, '4chanMainInit', Main.initStyle - $.asap (-> d.head and $('title', d.head) or d.readyState in ['interactive', 'complete']), - Main.initStyle - - initFeatures: (items) -> - Conf = items - pathname = location.pathname.split '/' g.BOARD = new Board pathname[1] g.VIEW = @@ -38,6 +31,13 @@ Main = if g.VIEW is 'thread' g.THREADID = +pathname[3] + $.on d, '4chanMainInit', Main.initStyle + $.asap (-> d.head and $('title', d.head) or d.readyState in ['interactive', 'complete']), + Main.initStyle + + initFeatures: (items) -> + Conf = items + switch location.hostname when 'api.4chan.org' return @@ -48,9 +48,10 @@ Main = $.ready -> if Conf['404 Redirect'] and d.title is '4chan - 404 Not Found' Redirect.init() + pathname = location.pathname.split '/' URL = Redirect.to 'file', - boardID: pathname[1] - filename: pathname[3] + boardID: g.BOARD.ID + filename: pathname[pathname.length - 1] location.href = URL if URL return From 60bfc25f7e0f25666065d90ab9dacd7c0c901e22 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 14 May 2013 21:42:04 +0200 Subject: [PATCH 15/16] Try to fix an obscure bug. --- src/Filtering/Filter.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Filtering/Filter.coffee b/src/Filtering/Filter.coffee index 8ac6e18c9..98cdbf11c 100644 --- a/src/Filtering/Filter.coffee +++ b/src/Filtering/Filter.coffee @@ -5,6 +5,11 @@ Filter = for key of Config.filter @filters[key] = [] + if Conf[key] is undefined + # XXX hopefully tmp fix for the rare people getting this mysterious error: + # "Filter" initialization crashed. TypeError: Cannot call method 'split' of undefined + $.delete key + continue for filter in Conf[key].split '\n' continue if filter[0] is '#' From 57758fdc8a1431e02e3e4816f0c64ef1a78ff2ff Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 14 May 2013 21:55:27 +0200 Subject: [PATCH 16/16] Don't execute 4chan X on /z/, this represents 5% of error reports god damn. --- src/General/Main.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index e502816d4..2fea223c6 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -20,6 +20,7 @@ Main = pathname = location.pathname.split '/' g.BOARD = new Board pathname[1] + return if g.BOARD.ID is 'z' g.VIEW = switch pathname[2] when 'res'
Archived boards