From 371cf05b68247fcd52439950fcc00e555bc52123 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 17 May 2013 22:02:16 +0200 Subject: [PATCH 01/19] Set the g's even sooner. --- src/General/Main.coffee | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 2fea223c6..3191dc148 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -1,5 +1,19 @@ Main = init: (items) -> + pathname = location.pathname.split '/' + g.BOARD = new Board pathname[1] + return if g.BOARD.ID is 'z' + g.VIEW = + switch pathname[2] + when 'res' + 'thread' + when 'catalog' + 'catalog' + else + 'index' + if g.VIEW is 'thread' + g.THREADID = +pathname[3] + # flatten Config into Conf # and get saved or default values flatten = (parent, obj) -> @@ -18,20 +32,6 @@ Main = Conf['archives'] = Redirect.archives $.get Conf, Main.initFeatures - pathname = location.pathname.split '/' - g.BOARD = new Board pathname[1] - return if g.BOARD.ID is 'z' - g.VIEW = - switch pathname[2] - when 'res' - 'thread' - when 'catalog' - 'catalog' - else - 'index' - 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 From 45de71ad41ae59837ee419fda77b83b6d0af309f Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 17 May 2013 22:03:01 +0200 Subject: [PATCH 02/19] Also block /fk/. --- 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 3191dc148..9cc8704a5 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -2,7 +2,7 @@ Main = init: (items) -> pathname = location.pathname.split '/' g.BOARD = new Board pathname[1] - return if g.BOARD.ID is 'z' + return if g.BOARD.ID in ['z', 'fk'] g.VIEW = switch pathname[2] when 'res' From 627ab32b59a46c509d88b188fefd625b410ec999 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 17 May 2013 22:05:01 +0200 Subject: [PATCH 03/19] Don't log errors coming from v2 users. --- src/General/Main.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 9cc8704a5..51d33f5bb 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -201,6 +201,7 @@ Main = Main.callbackNodes Post, posts if $.hasClass d.body, 'fourchan_x' + Main.v2Detected = true alert '4chan X v2 detected: Disable it or v3 will break.' try @@ -315,6 +316,7 @@ Main = errors: [] logError: (data) -> + return if Main.v2Detected unless Main.errors.length $.on window, 'unload', Main.postErrors c.error data.message, data.error.stack From f00b060f7014b34674f362ca4072dcdad1bd3817 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 17 May 2013 22:14:05 +0200 Subject: [PATCH 04/19] Fix #1109. Just how fucking difficult is it to integrate the catalog correctly? /slap @desuwa --- 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 51d33f5bb..00cc41300 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -33,7 +33,9 @@ Main = $.get Conf, Main.initFeatures $.on d, '4chanMainInit', Main.initStyle - $.asap (-> d.head and $('title', d.head) or d.readyState in ['interactive', 'complete']), + # comes after the stylesheets on the index/thread pages, but before on the catalog. + # <link favicon> comes after the stylesheets on the catalog, but before on the index/thread pages. + $.asap (-> d.head and $('title', d.head) and $('link[rel="shortcut icon"]', d.head) or d.readyState in ['interactive', 'complete']), Main.initStyle initFeatures: (items) -> From ff65a27034193ba56547eade2048c517be8a3b50 Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Fri, 17 May 2013 22:19:47 +0200 Subject: [PATCH 05/19] Stop logging this. It didn't reveal anything other than that #boardNavMobile is missing too. --- src/General/Header.coffee | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/General/Header.coffee b/src/General/Header.coffee index f374cbb67..d873adf0f 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -92,16 +92,7 @@ Header = # XXX Getting weird reports here of # "Header" initialization crashed. TypeError: Cannot read property 'innerHTML' of null # Let's try to find the cause. - if nav is null - Main.logError - message: "Header crash: nav is null" - error: new Error """ - #{!!$.id 'boardNavMobile'} - d.readyState = #{d.readyState} - doc.className = #{doc.className} - d.body.className = #{d.body.className} - """ - else + if nav fullBoardList.innerHTML = nav.innerHTML $.rm $ '#navtopright', fullBoardList btn = $.el 'span', From fb699eac64063f10e270b867700d4d35b62af2a4 Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Fri, 17 May 2013 22:26:19 +0200 Subject: [PATCH 06/19] I'm still getting `Object.keys called on non-object` from here. wtf --- src/General/DataBoard.coffee | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/General/DataBoard.coffee b/src/General/DataBoard.coffee index 1d6d30a3f..fcf943a1c 100644 --- a/src/General/DataBoard.coffee +++ b/src/General/DataBoard.coffee @@ -59,10 +59,8 @@ class DataBoard 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} + @data.boards[boardID] or= {} + @deleteIfEmpty {boardID} now = Date.now() if (@data.lastChecked or 0) < now - 2 * $.HOUR From fbef2401b3b711895be6312d248342639173c824 Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Fri, 17 May 2013 22:32:46 +0200 Subject: [PATCH 07/19] Actually let's try this fix instead. --- src/General/DataBoard.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/General/DataBoard.coffee b/src/General/DataBoard.coffee index fcf943a1c..4cd054375 100644 --- a/src/General/DataBoard.coffee +++ b/src/General/DataBoard.coffee @@ -59,8 +59,10 @@ class DataBoard for boardID, val of @data.boards # XXX tmp fix for users that had the `null` # value for a board with the Unread features: - @data.boards[boardID] or= {} - @deleteIfEmpty {boardID} + if typeof @data.boards[boardID] isnt 'object' + delete @data.boards[boardID] + else + @deleteIfEmpty {boardID} now = Date.now() if (@data.lastChecked or 0) < now - 2 * $.HOUR From aa0cd42ba55aa7db49372a1ce2a858a39390ee60 Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Fri, 17 May 2013 22:50:08 +0200 Subject: [PATCH 08/19] Changelog. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e10a9a5b..bd3f89c4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- More minor fixes. + ### 3.4.2 - *2013-05-14* - Minor fixes. From abf481e84459ef4533bea6eececffebb725c93c4 Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Fri, 17 May 2013 22:50:15 +0200 Subject: [PATCH 09/19] Release 4chan X v3.4.3. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd3f89c4c..b8928f24f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +### 3.4.3 - *2013-05-17* + - More minor fixes. ### 3.4.2 - *2013-05-14* diff --git a/package.json b/package.json index 2013a2ae4..c1d219635 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.4.2", + "version": "3.4.3", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X", From be934756d461624d7ed64c6bff2f0c6c1e2b8329 Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Fri, 17 May 2013 23:13:46 +0200 Subject: [PATCH 10/19] Close #856. --- src/Posting/QR.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 5bca535b6..a3d179f09 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -212,7 +212,7 @@ QR = else 300 sage: if board is 'q' then 600 else 60 file: if board is 'q' then 300 else 30 - post: if board is 'q' then 60 else 30 + post: if board is 'q' then 150 else 30 QR.cooldown.upSpd = 0 QR.cooldown.upSpdAccuracy = .5 $.get "cooldown.#{board}", {}, (item) -> From afe98d2425c5886d1e7572dd8b6b100c482378cb Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Sat, 18 May 2013 16:49:31 +0200 Subject: [PATCH 11/19] Errors will occur before we detect v2, make sure those don't get sent. --- 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 00cc41300..50dabbe63 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -318,13 +318,13 @@ Main = errors: [] logError: (data) -> - return if Main.v2Detected unless Main.errors.length $.on window, 'unload', Main.postErrors c.error data.message, data.error.stack Main.errors.push data postErrors: -> + return if Main.v2Detected errors = Main.errors.map (d) -> d.message + ' ' + d.error.stack $.ajax '<%= meta.page %>errors', {}, sync: true From f87ba3f3e80775f6679ae4deddd921cd9446a098 Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Sat, 18 May 2013 17:01:55 +0200 Subject: [PATCH 12/19] Differentiate between an original post and a clone in error reports. --- src/General/Get.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/General/Get.coffee b/src/General/Get.coffee index 235d2781e..d246493b0 100644 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -78,7 +78,7 @@ Get = # Stop here if the container has been removed while loading. return unless root.parentNode clone = post.addClone context - Main.callbackNodes Post, [clone] + Main.callbackNodes Clone, [clone] # Get rid of the side arrows. {nodes} = clone From 2b1ef422ca0ca6819d07181ae32a9d76a2e75193 Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Sat, 18 May 2013 18:52:11 +0200 Subject: [PATCH 13/19] Tiny $.cache fix. --- lib/$.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/$.coffee b/lib/$.coffee index 53a6a7dce..ef83364c3 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -54,7 +54,7 @@ $.cache = do -> (url, cb) -> if req = reqs[url] if req.readyState is 4 - cb.call req + cb.call req, req.evt else req.callbacks.push cb return @@ -62,6 +62,7 @@ $.cache = do -> req = $.ajax url, onload: (e) -> cb.call @, e for cb in @callbacks + req.evt = e delete @callbacks onabort: rm onerror: rm From b6bbaa54da699f8b5cb7c25c57a330cfdb034c64 Mon Sep 17 00:00:00 2001 From: Wohlfe <minusthewohlfe@gmail.com> Date: Sat, 18 May 2013 19:34:33 -0300 Subject: [PATCH 14/19] Added /pol/ --- json/archives.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json/archives.json b/json/archives.json index d5f527798..d0cddd855 100644 --- a/json/archives.json +++ b/json/archives.json @@ -68,7 +68,7 @@ "http": true, "https": true, "software": "foolfuuka", - "boards": ["adv", "asp", "cm", "e", "i", "lgbt", "n", "o", "p", "s", "s4s", "t", "trv", "y"], + "boards": ["adv", "asp", "cm", "e", "i", "lgbt", "n", "o", "p", "pol", "s", "s4s", "t", "trv", "y"], "files": ["adv", "asp", "cm", "e", "i", "lgbt", "n", "o", "p", "s", "s4s", "t", "trv", "y"] }, { "uid": 7, From dbe82a46f9107591ae6cd14a6f3b5f8b5972cf82 Mon Sep 17 00:00:00 2001 From: harava <the_rage_619@hotmail.com> Date: Sun, 19 May 2013 17:28:48 +0300 Subject: [PATCH 15/19] Update archives.json --- json/archives.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json/archives.json b/json/archives.json index d0cddd855..055da85b2 100644 --- a/json/archives.json +++ b/json/archives.json @@ -95,8 +95,8 @@ "http": true, "https": false, "software": "fuuka", - "boards": ["an", "fit", "k", "mlp", "r9k", "toy", "x"], - "files": ["an", "k", "toy", "x"] + "boards": ["an", "fit", "k", "mlp", "r9k", "toy"], + "files": ["an", "fit", "k", "r9k", "toy"] }, { "uid": 10, "name": "warosu", From 11f3ba2647d0c61e5e7708013b71489955284f39 Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Sun, 19 May 2013 19:03:20 +0200 Subject: [PATCH 16/19] `@` --- lib/$.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/$.coffee b/lib/$.coffee index ef83364c3..c255c13f8 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -62,7 +62,7 @@ $.cache = do -> req = $.ajax url, onload: (e) -> cb.call @, e for cb in @callbacks - req.evt = e + @evt = e delete @callbacks onabort: rm onerror: rm From 388c8b9d1a152777f7dd1c27925f9d79018977e2 Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Mon, 20 May 2013 02:46:05 +0200 Subject: [PATCH 17/19] Fix withCredentials on synchronous XHRs. --- lib/$.coffee | 9 ++++++++- src/Monitoring/Unread.coffee | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/$.coffee b/lib/$.coffee index c255c13f8..a37a9c494 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -46,7 +46,14 @@ $.ajax = (url, callbacks, opts={}) -> r.setRequestHeader key, val $.extend r, callbacks $.extend r.upload, upCallbacks - r.withCredentials = cred + try + # Firefox throws an error if you try + # to set this on a synchronous XHR. + # Only cookies from the remote domain + # are used in a request withCredentials. + r.withCredentials = cred + catch err + # do nothing r.send form r $.cache = do -> diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 79a4f072b..a951be09a 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -131,7 +131,7 @@ Unread = Unread.db.set boardID: Unread.thread.board.ID threadID: Unread.thread.ID - val: Unread.lastReadPost + val: Unread.lastReadPost setLine: (force) -> return unless d.hidden or force is true From 5abb67edcb3996dcc300efcef28733a24e7dfe06 Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Mon, 20 May 2013 02:57:44 +0200 Subject: [PATCH 18/19] Update deps. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c1d219635..9501600c3 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "grunt-contrib-compress": "~0.5.0", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-copy": "~0.4.1", - "grunt-contrib-watch": "~0.4.2", + "grunt-contrib-watch": "~0.4.3", "grunt-shell": "~0.2.2" }, "repository": { From 05baad8b2ee6f52a21e267aa0879f8da8787110e Mon Sep 17 00:00:00 2001 From: Mayhem <stepien.nicolas@gmail.com> Date: Mon, 20 May 2013 22:34:34 +0200 Subject: [PATCH 19/19] Close #1117. --- src/Menu/DeleteLink.coffee | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Menu/DeleteLink.coffee b/src/Menu/DeleteLink.coffee index fa1b5c5fb..9427d4076 100644 --- a/src/Menu/DeleteLink.coffee +++ b/src/Menu/DeleteLink.coffee @@ -31,7 +31,7 @@ DeleteLink = el: div order: 40 open: (post) -> - return false if post.isDead + return false if post.isDead or post.board.ID is 'q' DeleteLink.post = post node = div.firstChild node.textContent = 'Delete' @@ -86,10 +86,7 @@ DeleteLink = delete DeleteLink.cooldown.counting return DeleteLink.cooldown.counting = post - length = if post.board.ID is 'q' - 600 - else - 30 + length = 30 seconds = Math.ceil (length * $.SECOND - (Date.now() - post.info.date)) / $.SECOND DeleteLink.cooldown.count post, seconds, length, node count: (post, seconds, length, node) ->