From 35dbf1fa53148baf8d44482a8496cdd32e469b53 Mon Sep 17 00:00:00 2001 From: thebladeee Date: Sat, 11 Jan 2014 17:03:24 -0500 Subject: [PATCH 01/44] Readded Love is Over --- json/archives.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/json/archives.json b/json/archives.json index ff93bb842..9c4db2258 100644 --- a/json/archives.json +++ b/json/archives.json @@ -43,6 +43,15 @@ "software": "foolfuuka", "boards": ["c", "w", "wg"], "files": ["c", "w", "wg"] +}, { + "uid": 5, + "name": "Love is Over", + "domain": "loveisover.me", + "http": true, + "https": true, + "software": "foolfuuka", + "boards": ["d", "i"], + "files": ["d", "i"] }, { "uid": 7, "name": "Install Gentoo", From a0dad17253d272640a294889e7bdbe5c661e4a7a Mon Sep 17 00:00:00 2001 From: V o H Date: Sat, 11 Jan 2014 14:41:15 -0800 Subject: [PATCH 02/44] Update archives.json p-perverts --- json/archives.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json/archives.json b/json/archives.json index 9c4db2258..1355ece87 100644 --- a/json/archives.json +++ b/json/archives.json @@ -41,8 +41,8 @@ "http": true, "https": true, "software": "foolfuuka", - "boards": ["c", "w", "wg"], - "files": ["c", "w", "wg"] + "boards": ["c", "e", "w", "wg"], + "files": ["c", "e", "w", "wg"] }, { "uid": 5, "name": "Love is Over", From d991e6e0cbc52744b646986953725bdfdc788f60 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 15 Jan 2014 01:06:21 +0100 Subject: [PATCH 03/44] Typo --- src/General/Thread.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/General/Thread.coffee b/src/General/Thread.coffee index 5b14e135d..410a4288a 100644 --- a/src/General/Thread.coffee +++ b/src/General/Thread.coffee @@ -44,7 +44,7 @@ class Thread @timeOfDeath = Date.now() collect: -> - for postID, post in @posts + for postID, post of @posts post.collect() delete g.threads[@fullID] delete @board.threads[@] From 8c3e46d23b0de5aeb85e4dc6b1a5346abd298639 Mon Sep 17 00:00:00 2001 From: AchtBit Date: Fri, 17 Jan 2014 00:33:43 -0600 Subject: [PATCH 04/44] Fix wait error regex There are 2 spaces separating the number of seconds. --- 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 24209cf08..2eed475ff 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -547,7 +547,7 @@ QR = # Too many frequent mistyped captchas will auto-ban you! # On connection error, the post most likely didn't go through. QR.cooldown.set delay: 2 - else if err.textContent and m = err.textContent.match /wait\s(\d+)\ssecond/i + else if err.textContent and m = err.textContent.match /wait\s+(\d+)\s+second/i QR.cooldown.auto = if QR.captcha.isEnabled !!QR.captcha.captchas.length else From a7642d73b33b7b0837bf8db8bb75d9a48c415b08 Mon Sep 17 00:00:00 2001 From: Noble pleb Date: Fri, 17 Jan 2014 14:48:53 +0200 Subject: [PATCH 05/44] Update archives.json /adv/ --- json/archives.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json/archives.json b/json/archives.json index 1355ece87..856c0740a 100644 --- a/json/archives.json +++ b/json/archives.json @@ -32,8 +32,8 @@ "http": true, "https": true, "software": "foolfuuka", - "boards": ["hr", "o", "pol", "s4s", "tg", "tv", "x"], - "files": ["hr", "o", "pol", "s4s", "tg", "tv", "x"] + "boards": ["adv", "hr", "o", "pol", "s4s", "tg", "tv", "x"], + "files": ["adv", "hr", "o", "pol", "s4s", "tg", "tv", "x"] }, { "uid": 4, "name": "Nyafuu", From 8402c406275c0b6e144b62112151c6324d5fe324 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 17 Jan 2014 17:43:30 +0100 Subject: [PATCH 06/44] Update deps. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4737e80fe..1f7f11bd3 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "grunt-concurrent": "~0.4.0", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-coffee": "~0.8.0", - "grunt-contrib-compress": "~0.5.2", + "grunt-contrib-compress": "~0.6.0", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-copy": "~0.5.0", "grunt-contrib-watch": "~0.5.3", From 436e6b3deaef1af960a3bd9b8cf59076ac25c230 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 17 Jan 2014 17:47:30 +0100 Subject: [PATCH 07/44] Add fgts archive. --- json/archives.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/json/archives.json b/json/archives.json index 856c0740a..b1aaa9f5b 100644 --- a/json/archives.json +++ b/json/archives.json @@ -88,6 +88,15 @@ "software": "fuuka", "boards": ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"], "files": ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"] +}, { + "uid": 15, + "name": "fgts", + "domain": "fgts.eu", + "http": true, + "https": true, + "software": "foolfuuka", + "boards": ["soc"], + "files": ["soc"] }, { "uid": 13, "name": "Foolz Beta", From 606a07828a833155f25989f3daa372f20c202073 Mon Sep 17 00:00:00 2001 From: anounyym1 Date: Fri, 17 Jan 2014 20:31:04 +0200 Subject: [PATCH 08/44] Update rbt.asia to archive.rebeccablacktech.com --- json/archives.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json/archives.json b/json/archives.json index b1aaa9f5b..954b95d77 100644 --- a/json/archives.json +++ b/json/archives.json @@ -64,7 +64,7 @@ }, { "uid": 8, "name": "Rebecca Black Tech", - "domain": "rbt.asia", + "domain": "archive.rebeccablacktech.com", "http": true, "https": true, "software": "fuuka", From 55192274a037048f44127a713b45328beb110ffc Mon Sep 17 00:00:00 2001 From: ManamiTamura Date: Sun, 19 Jan 2014 00:00:25 +0100 Subject: [PATCH 09/44] changed mawa.re to be before foolz beta --- json/archives.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/json/archives.json b/json/archives.json index 954b95d77..a34436c4b 100644 --- a/json/archives.json +++ b/json/archives.json @@ -97,6 +97,15 @@ "software": "foolfuuka", "boards": ["soc"], "files": ["soc"] +}, { + "uid": 16, + "name": "maware", + "domain": "archive.mawa.re", + "http": true, + "https": false, + "software": "foolfuuka", + "boards": ["t"], + "files": ["t"] }, { "uid": 13, "name": "Foolz Beta", From da203ae76a921b0476fd425fec40dca693e47479 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 19 Jan 2014 00:25:01 +0100 Subject: [PATCH 10/44] Update the archives settings tab when manually updating the archives list. --- src/Archive/Redirect.coffee | 12 ++++++------ src/General/Settings.coffee | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index bb63f09ae..27593edd1 100644 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -33,12 +33,12 @@ Redirect = # The list is also updated when 4chan X gets updated. return if lastarchivecheck > now - 2 * $.DAY $.ajax '<%= meta.page %>json/archives.json', onload: -> - return unless @status is 200 - Conf['archives'] = JSON.parse @response - $.set - lastarchivecheck: now - archives: Conf['archives'] - cb? now + if @status is 200 + Conf['archives'] = JSON.parse @response + $.set + lastarchivecheck: now + archives: Conf['archives'] + cb?() to: (dest, data) -> archive = (if dest is 'search' then Redirect.data.thread else Redirect.data[dest])[data.boardID] diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 8f7cc2d5c..ed05ebf42 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -383,20 +383,17 @@ Settings = archives: (section) -> section.innerHTML = <%= importHTML('General/Settings-section-Archives') %> - 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) -> + Redirect.update -> button.textContent = 'Updated' - showLastUpdateTime time - - $.get 'lastarchivecheck', 0, ({lastarchivecheck}) -> showLastUpdateTime lastarchivecheck + Settings.addArchivesTable section + Settings.addArchivesTable section + addArchivesTable: (section) -> boards = {} for archive in Conf['archives'] for boardID in archive.boards @@ -423,13 +420,18 @@ Settings = Settings.addArchiveCell row, boardID, data, 'thread' Settings.addArchiveCell row, boardID, data, 'post' Settings.addArchiveCell row, boardID, data, 'file' - $.add $('tbody', section), rows - $.get 'selectedArchives', Conf['selectedArchives'], ({selectedArchives}) -> + tbody = $ 'tbody', section + $.rmAll tbody + $.add tbody, rows + $.get { + lastarchivecheck: 0 + selectedArchives: Conf['selectedArchives'] + }, ({lastarchivecheck, selectedArchives}) -> for boardID, data of selectedArchives for type, uid of data if option = $ "select[data-board-i-d='#{boardID}'][data-type='#{type}'] > option[value='#{uid}']", section option.selected = true - return + $('time', section).textContent = new Date(lastarchivecheck).toLocaleString() addArchiveCell: (row, boardID, data, type) -> options = [] for archive in data[type] From c47c3ddafef2e1b96a8cb25cb91afb4abeb350f5 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 19 Jan 2014 01:05:48 +0100 Subject: [PATCH 11/44] Move previous version check out of Setting and into Main. Also halve the notice timeout. --- src/General/Main.coffee | 11 +++++++++++ src/General/Settings.coffee | 18 ------------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index e408fdb22..4dc5b421f 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -205,6 +205,17 @@ Main = $.event '4chanXInitFinished' + $.get 'previousversion', null, ({previousversion}) -> + return if previousversion is g.VERSION + if previousversion + changelog = '<%= meta.repo %>blob/<%= meta.mainBranch %>/CHANGELOG.md' + el = $.el 'span', + innerHTML: "<%= meta.name %> has been updated to version #{g.VERSION}." + new Notice 'info', el, 15 + else + Settings.open() + $.set previousversion, g.VERSION + callbackNodes: (klass, nodes) -> # get the nodes' length only once len = nodes.length diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index ed05ebf42..45aa8124b 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -23,23 +23,6 @@ Settings = order: 110 open: -> Conf['Enable 4chan\'s Extension'] - $.get 'previousversion', null, (item) -> - if previous = item['previousversion'] - return if previous is g.VERSION - changelog = '<%= meta.repo %>blob/<%= meta.mainBranch %>/CHANGELOG.md' - el = $.el 'span', - innerHTML: "<%= meta.name %> has been updated to version #{g.VERSION}." - new Notice 'info', el, 30 - else - $.on d, '4chanXInitFinished', Settings.open - # The archive list will always be updated with 4chan X updates. - Conf['archives'] = Redirect.archives - now = Date.now() - $.set - archives: Conf['archives'] - lastarchivecheck: now - previousversion: g.VERSION - Settings.addSection 'Main', Settings.main Settings.addSection 'Filter', Settings.filter Settings.addSection 'QR', Settings.qr @@ -57,7 +40,6 @@ Settings = localStorage.setItem '4chan-settings', JSON.stringify settings open: (openSection) -> - $.off d, '4chanXInitFinished', Settings.open return if Settings.dialog $.event 'CloseMenu' From bf51864823dee7d8b746c7ca792f14d92f9933ee Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 19 Jan 2014 13:00:56 +0100 Subject: [PATCH 12/44] Typo. --- 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 4dc5b421f..35d1b9f0e 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -214,7 +214,7 @@ Main = new Notice 'info', el, 15 else Settings.open() - $.set previousversion, g.VERSION + $.set 'previousversion', g.VERSION callbackNodes: (klass, nodes) -> # get the nodes' length only once From b875b7f829d1d8beed24988f9d1f156168becc52 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 19 Jan 2014 16:06:51 +0100 Subject: [PATCH 13/44] Add installgentoo.com archive. It does not have search or stats, so it's kinda useless, but it does have post fething via XHR. So /g/ will get their post resurrection. --- json/archives.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/json/archives.json b/json/archives.json index a34436c4b..3519fe95a 100644 --- a/json/archives.json +++ b/json/archives.json @@ -106,6 +106,15 @@ "software": "foolfuuka", "boards": ["t"], "files": ["t"] +}, { + "uid": 17, + "name": "installgentoo.com", + "domain": "chan.installgentoo.com", + "http": true, + "https": false, + "software": "foolfuuka", + "boards": ["g", "t"], + "files": ["g", "t"] }, { "uid": 13, "name": "Foolz Beta", From f66bbee9f150b3f647528e946c4067ed76053aa0 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 19 Jan 2014 19:06:56 +0100 Subject: [PATCH 14/44] warosu is https only. --- json/archives.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json/archives.json b/json/archives.json index 3519fe95a..a19808354 100644 --- a/json/archives.json +++ b/json/archives.json @@ -83,7 +83,7 @@ "uid": 10, "name": "warosu", "domain": "fuuka.warosu.org", - "http": true, + "http": false, "https": true, "software": "fuuka", "boards": ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"], From 5a10d5f75c29f91469fd683794b98fc2698b328e Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 20 Jan 2014 09:04:32 +0100 Subject: [PATCH 15/44] Re-select archives when the archives list gets updated or when we select an archive in the settings. --- src/Archive/Redirect.coffee | 36 ++++++++++++++++++++---------------- src/General/Settings.coffee | 2 ++ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index 27593edd1..400ae7ee4 100644 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -1,31 +1,34 @@ Redirect = archives: `<%= JSON.stringify(grunt.file.readJSON('json/archives.json')) %>` - data: - thread: {} - post: {} - file: {} - init: -> + @selectArchives() + @update() + + selectArchives: -> + data = + thread: {} + post: {} + file: {} for boardID, data of Conf['selectedArchives'] for type, uid of data for archive in Conf['archives'] - continue if archive.uid isnt uid or type is 'post' and archive.software isnt 'foolfuuka' + continue if archive.uid isnt uid + break if type is 'post' and archive.software isnt 'foolfuuka' arr = if type is 'file' archive.files else archive.boards - Redirect.data[type][boardID] = archive if boardID in arr + data[type][boardID] = archive if boardID in arr + break for archive in Conf['archives'] for boardID in archive.boards - unless boardID of Redirect.data.thread - Redirect.data.thread[boardID] = archive - unless boardID of Redirect.data.post or archive.software isnt 'foolfuuka' - Redirect.data.post[boardID] = archive - unless boardID of Redirect.data.file or boardID not in archive.files - Redirect.data.file[boardID] = archive - - Redirect.update() - + unless boardID of data.thread + data.thread[boardID] = archive + unless boardID of data.post or archive.software isnt 'foolfuuka' + data.post[boardID] = archive + unless boardID of data.file or boardID not in archive.files + data.file[boardID] = archive + Redirect.data = data update: (cb) -> $.get 'lastarchivecheck', 0, ({lastarchivecheck}) -> now = Date.now() @@ -35,6 +38,7 @@ Redirect = $.ajax '<%= meta.page %>json/archives.json', onload: -> if @status is 200 Conf['archives'] = JSON.parse @response + Redirect.selectArchives() $.set lastarchivecheck: now archives: Conf['archives'] diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 45aa8124b..370130eb2 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -435,6 +435,8 @@ Settings = saveSelectedArchive: -> $.get 'selectedArchives', Conf['selectedArchives'], ({selectedArchives}) => (selectedArchives[@dataset.boardID] or= {})[@dataset.type] = +@value + Conf['selectedArchives'] = selectedArchives + Redirect.selectArchives() $.set 'selectedArchives', selectedArchives keybinds: (section) -> From bb00d4c2035d30a607eca13610d4bc203662a688 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 20 Jan 2014 09:36:18 +0100 Subject: [PATCH 16/44] Update deps. --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 1f7f11bd3..45a96cbad 100644 --- a/package.json +++ b/package.json @@ -21,18 +21,18 @@ } }, "devDependencies": { - "font-awesome": "https://github.com/FortAwesome/Font-Awesome/archive/v4.0.3.tar.gz", - "grunt": "~0.4.1", - "grunt-bump": "~0.0.11", - "grunt-concurrent": "~0.4.0", + "font-awesome": "~4.0.3", + "grunt": "~0.4.2", + "grunt-bump": "~0.0.13", + "grunt-concurrent": "~0.4.3", "grunt-contrib-clean": "~0.5.0", - "grunt-contrib-coffee": "~0.8.0", + "grunt-contrib-coffee": "~0.8.2", "grunt-contrib-compress": "~0.6.0", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-copy": "~0.5.0", "grunt-contrib-watch": "~0.5.3", - "grunt-shell": "~0.6.0", - "load-grunt-tasks": "~0.2.0" + "grunt-shell": "~0.6.3", + "load-grunt-tasks": "~0.2.1" }, "repository": { "type": "git", From fdd6a20c87eb6b56fda12aca0b7bc2f35a39ece4 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 20 Jan 2014 09:51:52 +0100 Subject: [PATCH 17/44] rm useless code --- 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 35d1b9f0e..371cc4166 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -174,7 +174,7 @@ Main = posts = [] for postRoot in $$ '.thread > .postContainer', threadRoot try - posts.push post = new Post postRoot, thread, g.BOARD, {isOriginalMarkup: true} + posts.push new Post postRoot, thread, g.BOARD, {isOriginalMarkup: true} catch err # Skip posts that we failed to parse. errors = [] unless errors From a44164c58dc9d02ce97dc84939cbce2980aebfc0 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 20 Jan 2014 10:02:19 +0100 Subject: [PATCH 18/44] Fix crash --- src/Archive/Redirect.coffee | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index 400ae7ee4..99c1bf8c7 100644 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -5,7 +5,7 @@ Redirect = @update() selectArchives: -> - data = + Redirect.data = thread: {} post: {} file: {} @@ -18,17 +18,17 @@ Redirect = archive.files else archive.boards - data[type][boardID] = archive if boardID in arr + Redirect.data[type][boardID] = archive if boardID in arr break for archive in Conf['archives'] for boardID in archive.boards - unless boardID of data.thread - data.thread[boardID] = archive - unless boardID of data.post or archive.software isnt 'foolfuuka' - data.post[boardID] = archive - unless boardID of data.file or boardID not in archive.files - data.file[boardID] = archive - Redirect.data = data + unless boardID of Redirect.data.thread + Redirect.data.thread[boardID] = archive + unless boardID of Redirect.data.post or archive.software isnt 'foolfuuka' + Redirect.data.post[boardID] = archive + unless boardID of Redirect.data.file or boardID not in archive.files + Redirect.data.file[boardID] = archive + return update: (cb) -> $.get 'lastarchivecheck', 0, ({lastarchivecheck}) -> now = Date.now() From 2f23534863c104fc6d09b51a8d396a0fcc6642b7 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 20 Jan 2014 10:05:29 +0100 Subject: [PATCH 19/44] Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b4671e90..f110125b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- Stability update. + ## 3.15.0 - *2013-12-13* - More index navigation improvements: From ba0830e8284d52d4e58ff8d14dc4af75557fb76b Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 20 Jan 2014 10:06:29 +0100 Subject: [PATCH 20/44] Release 4chan X v3.15.1. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f110125b5..0bdc43674 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +### 3.15.1 - *2014-01-20* + - Stability update. ## 3.15.0 - *2013-12-13* diff --git a/package.json b/package.json index 45a96cbad..d83f8cb91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.15.0", + "version": "3.15.1", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X", From 0e10e3fd810e322fe0518769bcbebc6e89854457 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 20 Jan 2014 22:45:34 +0100 Subject: [PATCH 21/44] Fix index search going badly when inputing only spaces. --- src/General/Index.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 24fc49315..b1544177e 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -393,6 +393,7 @@ Index = else pageNum = Index.getCurrentPage() else + return unless Index.searchInput.dataset.searching pageNum = Index.pageBeforeSearch delete Index.pageBeforeSearch <% if (type === 'userscript') { %> From b5a1c3a2874d825e3f8d3251e61e59e00ce56ba1 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 09:11:43 +0100 Subject: [PATCH 22/44] Don't call chrome.storage[area].set with empty data. --- lib/$.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/$.coffee b/lib/$.coffee index b971cfa7a..7abfed7c3 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -269,7 +269,7 @@ $.set = do -> timeout = {} setArea = (area) -> - return if timeout[area] + return if !Object.keys(items[area]).length or timeout[area] chrome.storage[area].set items[area], -> if chrome.runtime.lastError c.error chrome.runtime.lastError.message From a8068c083ffc01369401062597210dfca80ca8e9 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 10:20:08 +0100 Subject: [PATCH 23/44] Fix #1384. --- src/General/Header.coffee | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 7399ca4c1..41438fa25 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -279,9 +279,21 @@ Header = scrollTo: (root, down, needed) -> if down x = Header.getBottomOf root + if Conf['Header auto-hide on scroll'] and Conf['Bottom header'] + {height} = Header.bar.getBoundingClientRect() + if x <= 0 + x += height if !Header.isHidden() + else + x -= height if Header.isHidden() window.scrollBy 0, -x unless needed and x >= 0 else x = Header.getTopOf root + if Conf['Header auto-hide on scroll'] and !Conf['Bottom header'] + {height} = Header.bar.getBoundingClientRect() + if x >= 0 + x += height if !Header.isHidden() + else + x -= height if Header.isHidden() window.scrollBy 0, x unless needed and x >= 0 scrollToIfNeeded: (root, down) -> Header.scrollTo root, down, true @@ -298,6 +310,12 @@ Header = headRect = Header.toggle.getBoundingClientRect() bottom -= clientHeight - headRect.bottom + headRect.height bottom + isHidden: -> + {top} = Header.bar.getBoundingClientRect() + if Conf['Bottom header'] + top is doc.clientHeight + else + top < 0 addShortcut: (el, index) -> shortcut = $.el 'span', From ee1e5d03e66b2601b4bbc4f5924675fa5ac1c1f9 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 13:48:23 +0100 Subject: [PATCH 24/44] Update min Firefox/GM versions. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d83f8cb91..648014293 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ ], "min": { "chrome": "29", - "firefox": "22", - "greasemonkey": "1.12" + "firefox": "26", + "greasemonkey": "1.14" } }, "devDependencies": { From 59fa428db5c1c077285ba025bb1548b3d0699191 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 13:58:50 +0100 Subject: [PATCH 25/44] Warn about Firefox versions <26. --- src/General/Main.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 371cc4166..90700b014 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -190,6 +190,11 @@ Main = alert '4chan X v2 detected: Disable it or v3 will break.' <% if (type === 'userscript') { %> + test = $.el 'span' + test.classList.add 'a', 'b' + if test.className isnt 'a b' + new Notice 'warning', "Your version of Firefox is outdated (v<%= meta.min.firefox %> minimum) and <%= meta.name %> may not operate correctly.", 30 + GMver = GM_info.version.split '.' for v, i in "<%= meta.min.greasemonkey %>".split '.' break if v < GMver[i] From ef3ac421ca641fd0fc1f41aac3ce238ac88b81d2 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 14:13:46 +0100 Subject: [PATCH 26/44] Use text-decoration instead of border for forwardlinks. --- css/style.css | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/css/style.css b/css/style.css index 21fb6dc8c..f697b45e2 100644 --- a/css/style.css +++ b/css/style.css @@ -506,6 +506,15 @@ a.hide-announcement { text-decoration: none; border-bottom: 1px dashed; } +@supports (text-decoration-style: dashed) or (-moz-text-decoration-style: dashed) { + .quotelink.forwardlink, + .backlink.forwardlink { + text-decoration: underline; + -moz-text-decoration-style: dashed; + text-decoration-style: dashed; + border-bottom: none; + } +} .filtered { text-decoration: underline line-through; } From 878b6afe5a08c5deb667e2af6387ff3ca6f413a0 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 14:22:58 +0100 Subject: [PATCH 27/44] Use `mouseenter` instead of `mouseover` for menu entries. --- src/General/UI.coffee | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/General/UI.coffee b/src/General/UI.coffee index dff2be93f..b0309b62a 100644 --- a/src/General/UI.coffee +++ b/src/General/UI.coffee @@ -139,6 +139,8 @@ UI = do -> e.preventDefault() e.stopPropagation() + onFocus: (e) => + @focus e.target focus: (entry) -> while focused = $.x 'parent::*/child::*[contains(@class,"focused")]', entry $.rmClass focused, 'focused' @@ -174,10 +176,7 @@ UI = do -> parseEntry: (entry) -> {el, subEntries} = entry $.addClass el, 'entry' - $.on el, 'focus mouseover', ((e) -> - e.stopPropagation() - @focus el - ).bind @ + $.on el, 'focus mouseenter', @onFocus el.style.order = entry.order or 100 return unless subEntries $.addClass el, 'has-submenu' From 6c6f94bf583895e449688db5934338891f9c5ac8 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 14:23:45 +0100 Subject: [PATCH 28/44] Up min Chrome requirement. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 648014293..7f276b8aa 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "*://i.4cdn.org/*" ], "min": { - "chrome": "29", + "chrome": "30", "firefox": "26", "greasemonkey": "1.14" } From 2ed498813d0cc7fdb4af35a7911228908e262731 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 14:26:06 +0100 Subject: [PATCH 29/44] Remove outdated Chrome workaround. --- src/Linkification/Linkify.coffee | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 8c0cfa351..fd90879e6 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -105,10 +105,6 @@ Linkify = range.surroundContents anchor true catch - <% if (type === 'crx') { %> - # Chrome bug: crbug.com/275848 - return true if anchor.parentNode - <% } %> # Attempt to handle cases such as: # [spoiler]www.[/spoiler]example.com # # www.example[spoiler].com[/spoiler] # From 710655f13e9a54271e422b58b620286b82389ce5 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 14:46:26 +0100 Subject: [PATCH 30/44] Use xhr.responseType = 'json'. --- lib/$.coffee | 2 ++ src/Archive/Redirect.coffee | 2 +- src/Filtering/ThreadHiding.coffee | 2 +- src/General/DataBoard.coffee | 2 +- src/General/Get.coffee | 4 ++-- src/General/Index.coffee | 2 +- src/Images/ImageExpand.coffee | 2 +- src/Images/ImageHover.coffee | 2 +- src/Miscellaneous/ExpandThread.coffee | 5 ++--- src/Monitoring/ThreadStats.coffee | 5 ++--- src/Monitoring/ThreadUpdater.coffee | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/$.coffee b/lib/$.coffee index 7abfed7c3..2bbb69c76 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -47,6 +47,8 @@ $.ajax = do -> if whenModified r.setRequestHeader 'If-Modified-Since', lastModified[url] if url of lastModified $.on r, 'load', -> lastModified[url] = r.getResponseHeader 'Last-Modified' + if /\.json$/.test url + r.responseType = 'json' $.extend r, options $.extend r.upload, upCallbacks r.send form diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index 99c1bf8c7..67cf6d575 100644 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -37,7 +37,7 @@ Redirect = return if lastarchivecheck > now - 2 * $.DAY $.ajax '<%= meta.page %>json/archives.json', onload: -> if @status is 200 - Conf['archives'] = JSON.parse @response + Conf['archives'] = @response Redirect.selectArchives() $.set lastarchivecheck: now diff --git a/src/Filtering/ThreadHiding.coffee b/src/Filtering/ThreadHiding.coffee index bc0068067..6d5635201 100644 --- a/src/Filtering/ThreadHiding.coffee +++ b/src/Filtering/ThreadHiding.coffee @@ -61,7 +61,7 @@ ThreadHiding = $.cache "//a.4cdn.org/#{g.BOARD}/threads.json", -> return unless @status is 200 threads = {} - for page in JSON.parse @response + for page in @response for thread in page.threads if thread.no of hiddenThreadsOnCatalog threads[thread.no] = hiddenThreadsOnCatalog[thread.no] diff --git a/src/General/DataBoard.coffee b/src/General/DataBoard.coffee index c3e9a6ebc..aba14d68d 100644 --- a/src/General/DataBoard.coffee +++ b/src/General/DataBoard.coffee @@ -75,7 +75,7 @@ class DataBoard return board = @data.boards[boardID] threads = {} - for page in JSON.parse e.target.response + for page in e.target.response for thread in page.threads if thread.no of board threads[thread.no] = board[thread.no] diff --git a/src/General/Get.coffee b/src/General/Get.coffee index 8095d5669..2de421e27 100644 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -114,7 +114,7 @@ Get = "Error #{req.statusText} (#{req.status})." return - posts = JSON.parse(req.response).posts + {posts} = req.response Build.spoilerRange[boardID] = posts[0].custom_spoiler for post in posts break if post.no is postID # we found it! @@ -145,7 +145,7 @@ Get = Get.insert post, root, context return - data = JSON.parse req.response + data = req.response if data.error $.addClass root, 'warning' root.textContent = data.error diff --git a/src/General/Index.coffee b/src/General/Index.coffee index b1544177e..79a935099 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -239,7 +239,7 @@ Index = try if req.status is 200 - Index.parse JSON.parse(req.response), pageNum + Index.parse req.response, pageNum else if req.status is 304 and pageNum? Index.pageNav pageNum catch err diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 47779828b..4ef91fa28 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -135,7 +135,7 @@ ImageExpand = # XXX CORS for i.4cdn.org WHEN? $.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: -> return if @status isnt 200 - for postObj in JSON.parse(@response).posts + for postObj in @response.posts break if postObj.no is post.ID if postObj.no isnt post.ID clearTimeout timeoutID diff --git a/src/Images/ImageHover.coffee b/src/Images/ImageHover.coffee index 5e1dcd501..9e11951a3 100644 --- a/src/Images/ImageHover.coffee +++ b/src/Images/ImageHover.coffee @@ -41,7 +41,7 @@ ImageHover = # XXX CORS for i.4cdn.org WHEN? $.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: -> return if @status isnt 200 - for postObj in JSON.parse(@response).posts + for postObj in @response.posts break if postObj.no is post.ID if postObj.no isnt post.ID clearTimeout timeoutID diff --git a/src/Miscellaneous/ExpandThread.coffee b/src/Miscellaneous/ExpandThread.coffee index 3acd11bba..6401a400c 100644 --- a/src/Miscellaneous/ExpandThread.coffee +++ b/src/Miscellaneous/ExpandThread.coffee @@ -74,13 +74,12 @@ ExpandThread = a.textContent = "Error #{req.statusText} (#{req.status})" return - data = JSON.parse(req.response).posts - Build.spoilerRange[thread.board] = data.shift().custom_spoiler + Build.spoilerRange[thread.board] = req.response.posts.shift().custom_spoiler posts = [] postsRoot = [] filesCount = 0 - for postData in data + for postData in req.response.posts if post = thread.posts[postData.no] filesCount++ if 'file' of post postsRoot.push post.nodes.root diff --git a/src/Monitoring/ThreadStats.coffee b/src/Monitoring/ThreadStats.coffee index dc189a572..a477b377b 100644 --- a/src/Monitoring/ThreadStats.coffee +++ b/src/Monitoring/ThreadStats.coffee @@ -41,10 +41,9 @@ ThreadStats = whenModified: true onThreadsLoad: -> return if @status isnt 200 - pages = JSON.parse @response - for page in pages + for page in @response for thread in page.threads if thread.no is ThreadStats.thread.ID ThreadStats.pageCountEl.textContent = page.page - (if page.page is pages.length - 1 then $.addClass else $.rmClass) ThreadStats.pageCountEl, 'warning' + (if page.page is @response.length - 1 then $.addClass else $.rmClass) ThreadStats.pageCountEl, 'warning' return diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee index f42dc1283..028a4ccd9 100644 --- a/src/Monitoring/ThreadUpdater.coffee +++ b/src/Monitoring/ThreadUpdater.coffee @@ -98,7 +98,7 @@ ThreadUpdater = switch req.status when 200 g.DEAD = false - ThreadUpdater.parse JSON.parse(req.response).posts + ThreadUpdater.parse req.response.posts ThreadUpdater.setInterval() when 404 g.DEAD = true From 64a90bf8d3b1a4ad90b28333c0666ce3f3b15d7e Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 14:55:14 +0100 Subject: [PATCH 31/44] Up min Chrome requirement. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7f276b8aa..3736fb918 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "*://i.4cdn.org/*" ], "min": { - "chrome": "30", + "chrome": "31", "firefox": "26", "greasemonkey": "1.14" } From e25fd080bc5d1ecf976b439c1b7a70f8ac78e2b7 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 15:09:16 +0100 Subject: [PATCH 32/44] Foolfuuka's API URL does not end with `.json` so we must define the responseType manually. --- src/General/Get.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/General/Get.coffee b/src/General/Get.coffee index 2de421e27..9fe328a13 100644 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -76,6 +76,7 @@ Get = $.cache url, -> Get.archivedPost @, boardID, postID, root, context , + responseType: 'json' withCredentials: url.archive.withCredentials insert: (post, root, context) -> # Stop here if the container has been removed while loading. From 7495a905dde9386341630ba2214fe3efd5296e5d Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 15:16:36 +0100 Subject: [PATCH 33/44] Fix thread expanding. Apparently an xhr's reponse is read-only. --- src/Miscellaneous/ExpandThread.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Miscellaneous/ExpandThread.coffee b/src/Miscellaneous/ExpandThread.coffee index 6401a400c..d7c6a6d59 100644 --- a/src/Miscellaneous/ExpandThread.coffee +++ b/src/Miscellaneous/ExpandThread.coffee @@ -74,12 +74,13 @@ ExpandThread = a.textContent = "Error #{req.statusText} (#{req.status})" return - Build.spoilerRange[thread.board] = req.response.posts.shift().custom_spoiler + Build.spoilerRange[thread.board] = req.response.posts[0].custom_spoiler posts = [] postsRoot = [] filesCount = 0 for postData in req.response.posts + continue if postData.no is thread.ID if post = thread.posts[postData.no] filesCount++ if 'file' of post postsRoot.push post.nodes.root From 508ab4f884ec895a238879ecd49db13ec3faf64b Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 15:30:47 +0100 Subject: [PATCH 34/44] Make $.addClass/rmClass use multiple classes at once. --- lib/$.coffee | 8 ++++---- src/General/Header.coffee | 6 ++---- src/General/Main.coffee | 7 +------ src/Miscellaneous/PSAHiding.coffee | 6 ++---- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/lib/$.coffee b/lib/$.coffee index 2bbb69c76..85e418aca 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -93,10 +93,10 @@ $.addStyle = (css) -> $.x = (path, root=d.body) -> # XPathResult.ANY_UNORDERED_NODE_TYPE === 8 d.evaluate(path, root, null, 8, null).singleNodeValue -$.addClass = (el, className) -> - el.classList.add className -$.rmClass = (el, className) -> - el.classList.remove className +$.addClass = (el, className...) -> + el.classList.add className... +$.rmClass = (el, className...) -> + el.classList.remove className... $.hasClass = (el, className) -> el.classList.contains className $.rm = do -> diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 41438fa25..d65c80a41 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -200,11 +200,9 @@ Header = hideBarOnScroll: -> offsetY = window.pageYOffset if offsetY > (Header.previousOffset or 0) - $.addClass Header.bar, 'autohide' - $.addClass Header.bar, 'scroll' + $.addClass Header.bar, 'autohide', 'scroll' else - $.rmClass Header.bar, 'autohide' - $.rmClass Header.bar, 'scroll' + $.rmClass Header.bar, 'autohide', 'scroll' Header.previousOffset = offsetY setBarPosition: (bottom) -> diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 90700b014..254d2cba4 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -128,12 +128,7 @@ Main = return if !Main.isThisPageLegit() or $.hasClass doc, 'fourchan-x' # disable the mobile layout $('link[href*=mobile]', d.head)?.disabled = true - <% if (type === 'crx') { %> - $.addClass doc, 'blink' - <% } else { %> - $.addClass doc, 'gecko' - <% } %> - $.addClass doc, 'fourchan-x' + $.addClass doc, 'fourchan-x', '<% if (type === 'crx') { %>blink<% } else { %>gecko<% } %>' $.addStyle Main.css if g.VIEW is 'catalog' diff --git a/src/Miscellaneous/PSAHiding.coffee b/src/Miscellaneous/PSAHiding.coffee index f215f2c1b..0b1ad0a6b 100644 --- a/src/Miscellaneous/PSAHiding.coffee +++ b/src/Miscellaneous/PSAHiding.coffee @@ -2,16 +2,14 @@ PSAHiding = init: -> return if !Conf['Announcement Hiding'] - $.addClass doc, 'hide-announcement' - $.addClass doc, 'hide-announcement-enabled' + $.addClass doc, 'hide-announcement', 'hide-announcement-enabled' $.on d, '4chanXInitFinished', @setup setup: -> $.off d, '4chanXInitFinished', PSAHiding.setup unless psa = $.id 'globalMessage' - $.rmClass doc, 'hide-announcement' - $.rmClass doc, 'hide-announcement-enabled' + $.rmClass doc, 'hide-announcement', 'hide-announcement-enabled' return entry = From 0fdf5c89bba0bee29e5740b33a907413f424bfec Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 15:37:28 +0100 Subject: [PATCH 35/44] `mouseenter` did not work as I expected, reverting to `mouseover`. --- src/General/UI.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/General/UI.coffee b/src/General/UI.coffee index b0309b62a..e52774aea 100644 --- a/src/General/UI.coffee +++ b/src/General/UI.coffee @@ -140,6 +140,7 @@ UI = do -> e.stopPropagation() onFocus: (e) => + e.stopPropagation() @focus e.target focus: (entry) -> while focused = $.x 'parent::*/child::*[contains(@class,"focused")]', entry @@ -176,7 +177,7 @@ UI = do -> parseEntry: (entry) -> {el, subEntries} = entry $.addClass el, 'entry' - $.on el, 'focus mouseenter', @onFocus + $.on el, 'focus mouseover', @onFocus el.style.order = entry.order or 100 return unless subEntries $.addClass el, 'has-submenu' From 5ef395cc8df91cb77482e0c8fd43c3fae851c408 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 16:19:57 +0100 Subject: [PATCH 36/44] Simplify code related to clear hidden posts/threads button in settings. --- src/General/Settings.coffee | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 370130eb2..afd6c8f7d 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -122,22 +122,18 @@ Settings = div = $.el 'div', innerHTML: ": Clear manually-hidden threads and posts on all boards. Reload the page to apply." button = $ 'button', div - hiddenNum = 0 - $.get 'hiddenThreads', boards: {}, (item) -> - for ID, board of item.hiddenThreads.boards + $.get {hiddenThreads: {}, hiddenPosts: {}}, ({hiddenThreads, hiddenPosts}) -> + hiddenNum = 0 + for ID, board of hiddenThreads.boards + hiddenNum += Object.keys(board).length + for ID, board of hiddenPosts.boards for ID, thread of board - hiddenNum++ - button.textContent = "Hidden: #{hiddenNum}" - $.get 'hiddenPosts', boards: {}, (item) -> - for ID, board of item.hiddenPosts.boards - for ID, thread of board - for ID, post of thread - hiddenNum++ + hiddenNum += Object.keys(thread).length button.textContent = "Hidden: #{hiddenNum}" $.on button, 'click', -> @textContent = 'Hidden: 0' - $.get 'hiddenThreads', boards: {}, (item) -> - for boardID of item.hiddenThreads.boards + $.get 'hiddenThreads', {}, ({hiddenThreads}) -> + for boardID of hiddenThreads.boards localStorage.removeItem "4chan-hide-t-#{boardID}" $.delete ['hiddenThreads', 'hiddenPosts'] $.after $('input[name="Stubs"]', section).parentNode.parentNode, div From 6e450030f1561efa62c8d20ee91ed9f458de88fc Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 16:54:42 +0100 Subject: [PATCH 37/44] Only Chrome/Firefox/Opera are supported. --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2e13468c1..3478e5082 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,9 @@ Reporting bugs: -1. Make sure both your **browser** and **4chan X** are up to date. +1. Make sure both your **browser** and **4chan X** are up to date.
+ Only **Chrome**, **Firefox** and **Opera** are supported.
+ **SRWare Iron**, **Firefox ESR**, **Pale Moon**, **Waterfox**, and other derivatives are not supported, use them at your own risk. 2. Look at the list of [known problems and solutions](https://github.com/MayhemYDG/4chan-x/wiki/FAQ#known-problems). 3. Disable your other extensions & scripts to identify conflicts. 4. If your issue persists, open a [new issue](https://github.com/MayhemYDG/4chan-x/issues) with the following information: From c49579efcd666579f5522301a593758b717c29f0 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 21 Jan 2014 20:00:08 +0100 Subject: [PATCH 38/44] Attemps to fix possible race condition in setArea(). #1342 --- lib/$.coffee | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/$.coffee b/lib/$.coffee index 85e418aca..35d62a4c1 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -271,13 +271,16 @@ $.set = do -> timeout = {} setArea = (area) -> - return if !Object.keys(items[area]).length or timeout[area] - chrome.storage[area].set items[area], -> + data = items[area] + return if !Object.keys(data).length or timeout[area] + items[area] = {} + chrome.storage[area].set data, -> if chrome.runtime.lastError c.error chrome.runtime.lastError.message + for key, val of data when key not of items[area] + items[area][key] = val timeout[area] = setTimeout setArea, $.MINUTE, area return - items[area] = {} delete timeout[area] setAll = $.debounce $.SECOND, -> From 119f059ea92b3587a4cadf51c902a2df409e0ffb Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 22 Jan 2014 09:30:58 +0100 Subject: [PATCH 39/44] Changelog. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bdc43674..7f96b9a63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- More stability update. + ### 3.15.1 - *2014-01-20* - Stability update. From b0689af89ae4d49b94c90428283b2a6918eb69d9 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 22 Jan 2014 09:31:06 +0100 Subject: [PATCH 40/44] Release 4chan X v3.15.2. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f96b9a63..b565a188d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +### 3.15.2 - *2014-01-22* + - More stability update. ### 3.15.1 - *2014-01-20* diff --git a/package.json b/package.json index 3736fb918..29a771a70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.15.1", + "version": "3.15.2", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X", From 8a3af6f69ffdc78b1ba34502f662771faa94d1dd Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 22 Jan 2014 09:52:44 +0100 Subject: [PATCH 41/44] Toggling `Header auto-hide on scroll` should update the Conf too now. --- src/General/Header.coffee | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/General/Header.coffee b/src/General/Header.coffee index d65c80a41..e351fa4d7 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -194,9 +194,8 @@ Header = $.rmClass Header.bar, 'scroll' $.rmClass Header.bar, 'autohide' unless Conf['Header auto-hide'] toggleHideBarOnScroll: (e) -> - hide = @checked - $.set 'Header auto-hide on scroll', hide - Header.setHideBarOnScroll hide + $.cb.checked.call @ + Header.setHideBarOnScroll @checked hideBarOnScroll: -> offsetY = window.pageYOffset if offsetY > (Header.previousOffset or 0) From 0b39d6d3f5f3259226fb7887e5a376a6c523077a Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 22 Jan 2014 15:50:00 +0100 Subject: [PATCH 42/44] Simplify export settings code. Firefox does let us download links now. --- src/General/Header.coffee | 2 +- src/General/Settings.coffee | 34 ++++++++++------------------------ 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/General/Header.coffee b/src/General/Header.coffee index e351fa4d7..e97fcdf0f 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -193,7 +193,7 @@ Header = $.off window, 'scroll', Header.hideBarOnScroll $.rmClass Header.bar, 'scroll' $.rmClass Header.bar, 'autohide' unless Conf['Header auto-hide'] - toggleHideBarOnScroll: (e) -> + toggleHideBarOnScroll: -> $.cb.checked.call @ Header.setHideBarOnScroll @checked hideBarOnScroll: -> diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index afd6c8f7d..f05f1641f 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -137,35 +137,22 @@ Settings = localStorage.removeItem "4chan-hide-t-#{boardID}" $.delete ['hiddenThreads', 'hiddenPosts'] $.after $('input[name="Stubs"]', section).parentNode.parentNode, div - export: (now, data) -> - unless typeof now is 'number' - now = Date.now() - data = - version: g.VERSION - date: now - for db in DataBoard.keys - 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 + export: -> + # Make sure to export the most recent data. + $.get Conf, (Conf) -> + # XXX don't export archives. + delete Conf['archives'] + Settings.downloadExport {version: g.VERSION, date: Date.now(), Conf} + downloadExport: (data) -> a = $.el 'a', - className: 'warning' - textContent: 'Save me!' - download: "<%= meta.name %> v#{g.VERSION}-#{now}.json" + download: "<%= meta.name %> v#{g.VERSION}-#{data.date}.json" href: "data:application/json;base64,#{btoa unescape encodeURIComponent JSON.stringify data, null, 2}" - target: '_blank' <% if (type === 'userscript') { %> - # XXX Firefox won't let us download automatically. p = $ '.imp-exp-result', Settings.dialog $.rmAll p $.add p, a - <% } else { %> - a.click() <% } %> + a.click() import: -> @nextElementSibling.click() onImport: -> @@ -177,8 +164,7 @@ Settings = reader = new FileReader() reader.onload = (e) -> try - data = JSON.parse e.target.result - Settings.loadSettings data + Settings.loadSettings JSON.parse e.target.result if confirm 'Import successful. Reload now?' window.location.reload() catch err From c7c8ea9ec5c3a6f802bfb3d3e5bfd3a21d3a4053 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 22 Jan 2014 16:33:08 +0100 Subject: [PATCH 43/44] Add a `Reset Settings` button. --- CHANGELOG.md | 2 ++ html/General/Settings-section-Main.html | 3 ++- lib/$.coffee | 12 ++++++++++++ src/General/Settings.coffee | 16 ++++++++++------ src/Meta/metadata.js | 1 + 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b565a188d..f727a71bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- Added a `Reset Settings` button in the settings. + ### 3.15.2 - *2014-01-22* - More stability update. diff --git a/html/General/Settings-section-Main.html b/html/General/Settings-section-Main.html index 580ddae46..3af2be8c4 100644 --- a/html/General/Settings-section-Main.html +++ b/html/General/Settings-section-Main.html @@ -1,6 +1,7 @@
- + +

diff --git a/lib/$.coffee b/lib/$.coffee index 35d62a4c1..c50412cbf 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -300,6 +300,15 @@ $.set = do -> else $.extend items.sync, key setAll() +$.clear = (cb) -> + count = 2 + done = -> + if chrome.runtime.lastError + c.error chrome.runtime.lastError.message + return + cb?() unless --count + chrome.storage.local.clear done + chrome.storage.sync.clear done <% } else { %> # http://wiki.greasespot.net/Main_Page $.sync = do -> @@ -341,4 +350,7 @@ $.set = do -> for key, val of keys set key, val return +$.clear = (cb) -> + $.delete GM_listValues().map (key) -> key.replace g.NAMESPACE, '' + cb?() <% } %> diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index f05f1641f..0d85a8d44 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -96,6 +96,7 @@ Settings = section.innerHTML = <%= importHTML('General/Settings-section-Main') %> $.on $('.export', section), 'click', Settings.export $.on $('.import', section), 'click', Settings.import + $.on $('.reset', section), 'click', Settings.reset $.on $('input', section), 'change', Settings.onImport items = {} @@ -154,7 +155,7 @@ Settings = <% } %> a.click() import: -> - @nextElementSibling.click() + $('input', @parentNode).click() onImport: -> return unless file = @files[0] output = @parentNode.nextElementSibling @@ -174,6 +175,11 @@ Settings = loadSettings: (data) -> version = data.version.split '.' if version[0] is '2' + convertSettings = (data, map) -> + for prevKey, newKey of map + data.Conf[newKey] = data.Conf[prevKey] if newKey + delete data.Conf[prevKey] + data data = Settings.convertSettings data, # General confs 'Disable 4chan\'s extension': '' @@ -243,11 +249,9 @@ Settings = data.Conf['watchedThreads'] = boards: ThreadWatcher.convert data.Conf['WatchedThreads'] delete data.Conf['WatchedThreads'] $.set data.Conf - convertSettings: (data, map) -> - for prevKey, newKey of map - data.Conf[newKey] = data.Conf[prevKey] if newKey - delete data.Conf[prevKey] - data + reset: -> + if confirm 'Your current settings will be entirely wiped, are you sure?' + $.clear -> window.location.reload() if confirm 'Reset successful. Reload now?' filter: (section) -> section.innerHTML = <%= importHTML('General/Settings-section-Filter') %> diff --git a/src/Meta/metadata.js b/src/Meta/metadata.js index 6a1ff3a66..5a6383b4d 100644 --- a/src/Meta/metadata.js +++ b/src/Meta/metadata.js @@ -14,6 +14,7 @@ // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue +// @grant GM_listValues // @grant GM_openInTab // @run-at document-start // @updateURL <%= meta.page %><%= meta.buildsPath %><%= name %>.meta.js From 1eaf43e39ae104c2c3272805a10bd628922313b3 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 22 Jan 2014 16:52:46 +0100 Subject: [PATCH 44/44] Fetch the image's HEAD status to see if it's still available or not. Chrome bypasses the lack of CORS because we've allowed `i.4cdn.org` in the manifest. --- src/Images/ImageExpand.coffee | 10 ++++++++++ src/Images/ImageHover.coffee | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 4ef91fa28..13816680c 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -132,6 +132,15 @@ ImageExpand = return timeoutID = setTimeout ImageExpand.expand, 10000, post + <% if (type === 'crx') { %> + $.ajax @src, + onloadend: -> + return if @status isnt 404 + clearTimeout timeoutID + post.kill true + , + type: 'head' + <% } else { %> # XXX CORS for i.4cdn.org WHEN? $.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: -> return if @status isnt 200 @@ -143,6 +152,7 @@ ImageExpand = else if postObj.filedeleted clearTimeout timeoutID post.kill true + <% } %> menu: init: -> diff --git a/src/Images/ImageHover.coffee b/src/Images/ImageHover.coffee index 9e11951a3..9494b0c71 100644 --- a/src/Images/ImageHover.coffee +++ b/src/Images/ImageHover.coffee @@ -38,6 +38,15 @@ ImageHover = return timeoutID = setTimeout (=> @src = post.file.URL + '?' + Date.now()), 3000 + <% if (type === 'crx') { %> + $.ajax @src, + onloadend: -> + return if @status isnt 404 + clearTimeout timeoutID + post.kill true + , + type: 'head' + <% } else { %> # XXX CORS for i.4cdn.org WHEN? $.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: -> return if @status isnt 200 @@ -49,3 +58,4 @@ ImageHover = else if postObj.filedeleted clearTimeout timeoutID post.kill true + <% } %>