From 44499fe784f327750e7c234e612e919befc9e448 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 14 Apr 2013 22:29:37 +0200 Subject: [PATCH 01/22] Fix #1025. --- CHANGELOG.md | 1 + src/manifest.json | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d173b098e..a7acabc21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +- Fix support for www.4chan.org/frames on Chrome. - Fix resurrecting dead quotelinks on HTTP. ### 3.0.6 - *2013-04-14* diff --git a/src/manifest.json b/src/manifest.json index c89510295..b9793bda3 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -11,6 +11,7 @@ "content_scripts": [{ "js": ["script.js"], "matches": <%= JSON.stringify(meta.matches) %>, + "all_frames": true, "run_at": "document_start" }], "homepage_url": "<%= meta.page %>", From abaf10e1016ddd6bc0475232f8f716326ca5787b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 15 Apr 2013 00:49:48 +0200 Subject: [PATCH 02/22] Close #1035. --- src/features.coffee | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/features.coffee b/src/features.coffee index d409ece64..16aaa8b60 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -1687,12 +1687,10 @@ DeleteLink = return if DeleteLink.cooldown.counting isnt post unless 0 <= seconds <= length if DeleteLink.cooldown.counting is post + node.textContent = 'Delete' delete DeleteLink.cooldown.counting return setTimeout DeleteLink.cooldown.count, 1000, post, seconds - 1, length, node - if seconds is 0 - node.textContent = 'Delete' - return node.textContent = "Delete (#{seconds})" DownloadLink = From 6a8ebfed0dcd29664455172f6cfc8d25c3087ff4 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 15 Apr 2013 18:34:17 +0200 Subject: [PATCH 03/22] Fix dead quotelinks inside clones. --- CHANGELOG.md | 1 + lib/ui.coffee | 3 +- src/features.coffee | 105 +++++++++++++++++++++++--------------------- 3 files changed, 56 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7acabc21..4b9aeb50c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ - Fix support for www.4chan.org/frames on Chrome. +- Fix quote features not working on dead quotelinks in inlined posts. - Fix resurrecting dead quotelinks on HTTP. ### 3.0.6 - *2013-04-14* diff --git a/lib/ui.coffee b/lib/ui.coffee index eb06129aa..a743993de 100644 --- a/lib/ui.coffee +++ b/lib/ui.coffee @@ -6,8 +6,7 @@ UI = do -> id: id $.get "#{id}.position", position, (item) -> el.style.cssText = item["#{id}.position"] - move = $ '.move', el - $.on move, 'touchstart mousedown', dragstart + $.on $('.move', el), 'touchstart mousedown', dragstart el diff --git a/src/features.coffee b/src/features.coffee index 16aaa8b60..412eef272 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -2606,67 +2606,70 @@ Quotify = name: 'Resurrect Quotes' cb: @node node: -> - return if @isClone for deadlink in $$ '.deadlink', @nodes.comment - if deadlink.parentNode.className is 'prettyprint' - # Don't quotify deadlinks inside code tags, - # un-`span` them. - $.replace deadlink, [deadlink.childNodes...] - continue + if @isClone + if $.hasClass deadlink, 'quotelink' + @nodes.quotelinks.push deadlink + else + Quotify.parseDeadlink.call @, deadlink + return - quote = deadlink.textContent - continue unless postID = quote.match(/\d+$/)?[0] - boardID = - if m = quote.match /^>>>\/([a-z\d]+)/ - m[1] - else - @board.ID - quoteID = "#{boardID}.#{postID}" + parseDeadlink: (deadlink) -> + if deadlink.parentNode.className is 'prettyprint' + # Don't quotify deadlinks inside code tags, + # un-`span` them. + $.replace deadlink, [deadlink.childNodes...] + return - # \u00A0 is nbsp - if post = g.posts[quoteID] - unless post.isDead - # Don't (Dead) when quotifying in an archived post, - # and we know the post still exists. - a = $.el 'a', - href: "/#{boardID}/#{post.thread}/res/#p#{postID}" - className: 'quotelink' - textContent: quote - else - # Replace the .deadlink span if we can redirect. - a = $.el 'a', - href: "/#{boardID}/#{post.thread}/res/#p#{postID}" - className: 'quotelink deadlink' - target: '_blank' - textContent: "#{quote}\u00A0(Dead)" - a.setAttribute 'data-boardid', boardID - a.setAttribute 'data-threadid', post.thread.ID - a.setAttribute 'data-postid', postID - else if redirect = Redirect.to {boardID, threadID: 0, postID} + quote = deadlink.textContent + return unless postID = quote.match(/\d+$/)?[0] + boardID = if m = quote.match /^>>>\/([a-z\d]+)/ + m[1] + else + @board.ID + quoteID = "#{boardID}.#{postID}" + + if post = g.posts[quoteID] + unless post.isDead + # Don't (Dead) when quotifying in an archived post, + # and we know the post still exists. + a = $.el 'a', + href: "/#{boardID}/#{post.thread}/res/#p#{postID}" + className: 'quotelink' + textContent: quote + else # Replace the .deadlink span if we can redirect. a = $.el 'a', - href: redirect - className: 'deadlink' + href: "/#{boardID}/#{post.thread}/res/#p#{postID}" + className: 'quotelink deadlink' target: '_blank' textContent: "#{quote}\u00A0(Dead)" - if Redirect.post boardID, postID - # Make it function as a normal quote if we can fetch the post. - $.addClass a, 'quotelink' - a.setAttribute 'data-boardid', boardID - a.setAttribute 'data-postid', postID + a.setAttribute 'data-boardid', boardID + a.setAttribute 'data-threadid', post.thread.ID + a.setAttribute 'data-postid', postID + else if redirect = Redirect.to {boardID, threadID: 0, postID} + # Replace the .deadlink span if we can redirect. + a = $.el 'a', + href: redirect + className: 'deadlink' + target: '_blank' + textContent: "#{quote}\u00A0(Dead)" + if Redirect.post boardID, postID + # Make it function as a normal quote if we can fetch the post. + $.addClass a, 'quotelink' + a.setAttribute 'data-boardid', boardID + a.setAttribute 'data-postid', postID - unless quoteID in @quotes - @quotes.push quoteID + unless quoteID in @quotes + @quotes.push quoteID - unless a - deadlink.textContent += "\u00A0(Dead)" - continue + unless a + deadlink.textContent = "#{quote}\u00A0(Dead)" + return - $.replace deadlink, a - if $.hasClass a, 'quotelink' - @nodes.quotelinks.push a - a = null - return + $.replace deadlink, a + if $.hasClass a, 'quotelink' + @nodes.quotelinks.push a QuoteInline = init: -> From c55b071c71548bc1b4bfcec25026436b405426f4 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 15 Apr 2013 18:39:25 +0200 Subject: [PATCH 04/22] Update deps. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4626f8ff3..d9ebe7038 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "grunt-bump": "~0.0.0", "grunt-contrib-clean": "~0.4.0", "grunt-contrib-coffee": "~0.6.6", - "grunt-contrib-compress": "~0.4.9", + "grunt-contrib-compress": "~0.4.10", "grunt-contrib-concat": "~0.2.0", "grunt-contrib-copy": "~0.4.1", "grunt-contrib-watch": "~0.3.1", From 59df1a3e07fd3e92568af3efee8cae490bdf820b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 15 Apr 2013 18:59:58 +0200 Subject: [PATCH 05/22] Fix opening QR scrolling us to the end of the page. --- lib/ui.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ui.coffee b/lib/ui.coffee index a743993de..42cc139f6 100644 --- a/lib/ui.coffee +++ b/lib/ui.coffee @@ -4,6 +4,7 @@ UI = do -> className: 'dialog' innerHTML: html id: id + el.style.cssText = position $.get "#{id}.position", position, (item) -> el.style.cssText = item["#{id}.position"] $.on $('.move', el), 'touchstart mousedown', dragstart From be68f4c78a44c9e232dec9e23eac7a99c77b393d Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 15 Apr 2013 19:44:01 +0200 Subject: [PATCH 06/22] Get rid of $.engine. --- lib/$.coffee | 1 - src/features.coffee | 23 ++++++++++++++--------- src/main.coffee | 2 +- src/qr.coffee | 10 +++++++--- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/lib/$.coffee b/lib/$.coffee index 454e2c62b..46befcb64 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -16,7 +16,6 @@ $.extend $, MINUTE: 1000 * 60 HOUR : 1000 * 60 * 60 DAY : 1000 * 60 * 60 * 24 - engine: '<% if (type === 'crx') { %>webkit<% } else if (type === 'userjs') { %>presto<% } else { %>gecko<% } %>' id: (id) -> d.getElementById id ready: (fc) -> diff --git a/src/features.coffee b/src/features.coffee index 412eef272..8288228b2 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -167,7 +167,7 @@ Header = unless Conf['Bottom header'] headRect = Header.toggle.getBoundingClientRect() top += - headRect.top - headRect.height - (if $.engine is 'webkit' then d.body else doc).scrollTop += top + <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop += top toggleBarVisibility: (e) -> return if e.type is 'mousedown' and e.button isnt 0 # not LMB hide = if @nodeName is 'INPUT' @@ -439,13 +439,14 @@ Settings = download: "<%= meta.name %> v#{g.VERSION}-#{now}.json" href: "data:application/json;base64,#{btoa unescape encodeURIComponent JSON.stringify data, null, 2}" target: '_blank' - if $.engine isnt 'gecko' - a.click() - return + <% 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() + <% } %> import: -> @nextElementSibling.click() onImport: -> @@ -1695,11 +1696,15 @@ DeleteLink = DownloadLink = init: -> + <% if (type === 'userscript') { %> + # Firefox won't let us download cross-domain content. + return + <% } %> return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Download Link'] - # Firefox won't let us download cross-domain content. # Test for download feature support. - return if $.engine is 'gecko' or $.el('a').download is undefined + return unless 'download' of $.el 'a' + a = $.el 'a', className: 'download-link' textContent: 'Download file' @@ -3305,7 +3310,7 @@ ImageExpand = unless Conf['Bottom header'] headRect = Header.toggle.getBoundingClientRect() top += - headRect.top - headRect.height - root = if $.engine is 'webkit' then d.body else doc + root = <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %> root.scrollTop += top if rect.top < 0 root.scrollLeft = 0 if rect.left < 0 @@ -3347,7 +3352,7 @@ ImageExpand = $.addClass post.nodes.root, 'expanded-image' $.rmClass post.file.thumb, 'expanding' return unless prev.top + prev.height <= 0 - root = if $.engine is 'webkit' then d.body else doc + root = <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %> curr = post.nodes.root.getBoundingClientRect() root.scrollTop += curr.height - prev.height + curr.top - prev.top @@ -4206,7 +4211,7 @@ ThreadUpdater = $.add ThreadUpdater.root, nodes if scroll if Conf['Bottom Scroll'] - (if $.engine is 'webkit' then d.body else doc).scrollTop = d.body.clientHeight + <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop = d.body.clientHeight else Header.scrollToPost nodes[0] diff --git a/src/main.coffee b/src/main.coffee index 68c95f7b2..79a724537 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -397,7 +397,7 @@ Main = return unless Main.isThisPageLegit() # disable the mobile layout $('link[href*=mobile]', d.head)?.disabled = true - $.addClass doc, $.engine + $.addClass doc, '<% if (type === 'crx') { %>webkit<% } else if (type === 'userjs') { %>presto<% } else { %>gecko<% } %>' $.addClass doc, 'fourchan-x' $.addStyle Main.css diff --git a/src/qr.coffee b/src/qr.coffee index e1ca69e06..c1aa9bbfa 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -28,8 +28,9 @@ QR = QR.nodes.com.focus() Header.addShortcut sc - if $.engine is 'webkit' - $.on d, 'paste', QR.paste + <% if (type === 'crx') { %> + $.on d, 'paste', QR.paste + <% } %> $.on d, 'dragover', QR.dragOver $.on d, 'drop', QR.dropFile $.on d, 'dragstart dragend', QR.drag @@ -781,7 +782,10 @@ QR = # Add empty mimeType to avoid errors with URLs selected in Window's file dialog. QR.mimeTypes.push '' nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value - nodes.fileInput.accept = "text/*, #{mimeTypes}" if $.engine isnt 'presto' # Opera's accept attribute is fucked up + <% if (type !== 'userjs') { %> + # Opera's accept attribute is fucked up + nodes.fileInput.accept = "text/*, #{mimeTypes}" + <% } %> QR.spoiler = !!$ 'input[name=spoiler]' nodes.spoiler.hidden = !QR.spoiler From 38b51d8c10390b8064578885fe23397b3e834572 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 15 Apr 2013 19:45:52 +0200 Subject: [PATCH 07/22] Don't execute on api.4chan.org. --- src/main.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.coffee b/src/main.coffee index 79a724537..e2bc37171 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -319,6 +319,8 @@ Main = g.THREADID = +pathname[3] switch location.hostname + when 'api.4chan.org' + return when 'sys.4chan.org' Report.init() return From d7482159329547af44b06bc3e396a33932983e23 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 15 Apr 2013 19:51:27 +0200 Subject: [PATCH 08/22] Remove the firefox version alert, some people change their user agent apparently. --- src/main.coffee | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.coffee b/src/main.coffee index e2bc37171..b59e18916 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -468,8 +468,6 @@ Main = if $.hasClass d.body, 'fourchan_x' alert '4chan X v2 detected: Disable it or v3 will break.' - if /Firefox\/1/.test navigator.userAgent - alert 'Your version of Firefox is incompatible with 4chan X v3. Firefox 20+ is required.' $.event '4chanXInitFinished' Main.checkUpdate() From a5deb2019675a3c3861298a5f8a4548bdc746283 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 15 Apr 2013 20:22:26 +0200 Subject: [PATCH 09/22] Quoting while uploading should open a new post or the next one and start auto-dumping. --- src/qr.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qr.coffee b/src/qr.coffee index c1aa9bbfa..feb3edc9d 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -265,6 +265,11 @@ QR = text += ">#{s}\n" QR.open() + if QR.selected.isLocked + index = QR.posts.indexOf QR.selected + (QR.posts[index+1] or new QR.post()).select() + $.addClass QR.nodes.el, 'dump' + QR.cooldown.auto = true {com, thread} = QR.nodes thread.value = OP.ID unless com.value From cf1d94876ad994344c47ac54764362b431a47588 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 15 Apr 2013 21:45:36 +0200 Subject: [PATCH 10/22] $.off these 4chanXInitFinished. --- src/databoard.coffee | 5 ++++- src/features.coffee | 11 +++++++++-- src/qr.coffee | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/databoard.coffee b/src/databoard.coffee index 0e41af492..cceb63c10 100644 --- a/src/databoard.coffee +++ b/src/databoard.coffee @@ -8,7 +8,10 @@ class DataBoard return unless sync # Chrome also fires the onChanged callback on the current tab, # so we only start syncing when we're ready. - $.on d, '4chanXInitFinished', => @sync = sync + init = => + $.off d, '4chanXInitFinished', init + @sync = sync + $.on d, '4chanXInitFinished', init delete: ({boardID, threadID, postID}) -> if postID diff --git a/src/features.coffee b/src/features.coffee index 8288228b2..8333a410e 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -297,6 +297,7 @@ Settings = localStorage.setItem '4chan-settings', JSON.stringify settings open: (openSection) -> + $.off d, '4chanXInitFinished', Settings.open return if Settings.dialog $.event 'CloseMenu' @@ -1778,11 +1779,13 @@ Keybinds = init: -> return if g.VIEW is 'catalog' or !Conf['Keybinds'] - $.on d, '4chanXInitFinished', -> + init = -> + $.off d, '4chanXInitFinished', init $.on d, 'keydown', Keybinds.keydown for node in $$ '[accesskey]' node.removeAttribute 'accesskey' return + $.on d, '4chanXInitFinished', init keydown: (e) -> return unless key = Keybinds.keyCode e @@ -1999,7 +2002,10 @@ Nav = $.on next, 'click', @next $.add span, [prev, $.tn(' '), next] - $.on d, '4chanXInitFinished', -> $.add d.body, span + append = -> + $.off d, '4chanXInitFinished', append + $.add d.body, span + $.on d, '4chanXInitFinished', append prev: -> if g.VIEW is 'thread' @@ -4259,6 +4265,7 @@ ThreadWatcher = $.delete 'AutoWatch' ready: -> + $.off d, '4chanXInitFinished', ThreadWatcher.ready return unless Main.isThisPageLegit() ThreadWatcher.refresh() $.add d.body, ThreadWatcher.dialog diff --git a/src/qr.coffee b/src/qr.coffee index feb3edc9d..010d2d1ed 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -14,6 +14,7 @@ QR = cb: @node initReady: -> + $.off d, '4chanXInitFinished', QR.initReady QR.postingIsEnabled = !!$.id 'postForm' return unless QR.postingIsEnabled From b3ea2cc08f91a72f21bbd53a1c311de161c9d31f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 15 Apr 2013 23:05:32 +0200 Subject: [PATCH 11/22] Close #1022. --- src/qr.coffee | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/qr.coffee b/src/qr.coffee index 010d2d1ed..9e21d1714 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -29,6 +29,11 @@ QR = QR.nodes.com.focus() Header.addShortcut sc + $.on d, 'QRGetSelectedPost', ({detail: cb}) -> + cb QR.selected + $.on d, 'QRAddPreSubmitHook', ({detail: cb}) -> + QR.preSubmitHooks.push cb + <% if (type === 'crx') { %> $.on d, 'paste', QR.paste <% } %> @@ -449,6 +454,7 @@ QR = rectList = @nodes.el.parentNode.getBoundingClientRect() @nodes.el.parentNode.scrollLeft += rectEl.left + rectEl.width/2 - rectList.left - rectList.width/2 @load() + $.event 'QRPostSelection', @ load: -> # Load this post's values. for name in ['thread', 'name', 'email', 'sub', 'com'] @@ -860,6 +866,7 @@ QR = # Use it to extend the QR's functionalities, or for XTRM RICE. $.event 'QRDialogCreation', null, dialog + preSubmitHooks: [] submit: (e) -> e?.preventDefault() @@ -892,6 +899,9 @@ QR = err = 'No file selected.' else if post.file and thread.fileLimit and !thread.isSticky err = 'Max limit of image replies has been reached.' + else for hook in QR.preSubmitHooks + if err = hook post, thread + break if QR.captcha.isEnabled and !err {challenge, response} = QR.captcha.getOne() @@ -1046,11 +1056,10 @@ QR = val: true # Post/upload confirmed as successful. - $.event 'QRPostSuccessful', { + $.event 'QRPostSuccessful', board: g.BOARD threadID postID - }, QR.nodes.el # Enable auto-posting if we have stuff to post, disable it otherwise. QR.cooldown.auto = QR.posts.length > 1 and isReply From f185557dc16c335551397bfdbafde04746f7ed3d Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 16 Apr 2013 00:03:05 +0200 Subject: [PATCH 12/22] The file limit isn't hit anymore in stickies. --- src/qr.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qr.coffee b/src/qr.coffee index 9e21d1714..4359f27bf 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -897,7 +897,7 @@ QR = err = 'You can\'t reply to this thread anymore.' else unless post.com or post.file err = 'No file selected.' - else if post.file and thread.fileLimit and !thread.isSticky + else if post.file and thread.fileLimit err = 'Max limit of image replies has been reached.' else for hook in QR.preSubmitHooks if err = hook post, thread From 35cd7a7e346df2e4df91a9670de7740a1cf31408 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 16 Apr 2013 01:17:47 +0200 Subject: [PATCH 13/22] Close #933. --- CHANGELOG.md | 1 + css/style.css | 5 +++++ src/config.coffee | 1 + src/features.coffee | 49 +++++++++++++++++++++++++++++++++++++++++++++ src/main.coffee | 1 + 5 files changed, 57 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b9aeb50c..4729f608d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +- **New feature**: `Announcement Hiding`, enabled by default. - Fix support for www.4chan.org/frames on Chrome. - Fix quote features not working on dead quotelinks in inlined posts. - Fix resurrecting dead quotelinks on HTTP. diff --git a/css/style.css b/css/style.css index 30d916302..0dcd18830 100644 --- a/css/style.css +++ b/css/style.css @@ -370,6 +370,11 @@ a[href="javascript:;"] { overflow: hidden; } +/* Announcement Hiding */ +:root.hide-announcement #globalMessage { + display: none; +} + /* Unread */ #unread-line { margin: 0; diff --git a/src/config.coffee b/src/config.coffee index bd1452991..acc178684 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -3,6 +3,7 @@ Config = 'Miscellaneous': 'Enable 4chan\'s Extension': [false, 'Compatibility between <%= meta.name %> and 4chan\'s inline extension is NOT guaranteed.'] 'Custom Board Navigation': [true, 'Show custom links instead of the full board list'] + 'Announcement Hiding': [true, 'Add button to hide 4chan announcements.'] '404 Redirect': [true, 'Redirect dead threads and images.'] 'Keybinds': [true, 'Bind actions to keyboard shortcuts.'] 'Time Formatting': [true, 'Localize and format timestamps.'] diff --git a/src/features.coffee b/src/features.coffee index 8333a410e..a55f4168b 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -783,6 +783,55 @@ Settings = @value = key $.cb.value.call @ +PSAHiding = + init: -> + return if !Conf['Announcement Hiding'] + + $.addClass doc, 'hide-announcement' + + $.on d, '4chanXInitFinished', @setup + setup: -> + $.off d, '4chanXInitFinished', PSAHiding.setup + + unless psa = $.id 'globalMessage' + $.rmClass doc, 'hide-announcement' + return + + PSAHiding.btn = btn = $.el 'a', + title: 'Toggle announcement.' + href: 'javascript:;' + $.on btn, 'click', PSAHiding.toggle + + text = PSAHiding.trim psa + $.get 'hiddenPSAs', [], (item) -> + PSAHiding.sync item['hiddenPSAs'] + $.before psa, btn + $.rmClass doc, 'hide-announcement' + + $.sync 'hiddenPSAs', PSAHiding.sync + toggle: (e) -> + hide = $.hasClass @, 'hide-announcement' + text = PSAHiding.trim $.id 'globalMessage' + $.get 'hiddenPSAs', [], (item) -> + {hiddenPSAs} = item + if hide + hiddenPSAs.push text + else + i = hiddenPSAs.indexOf text + hiddenPSAs.splice i, 1 + hiddenPSAs = hiddenPSAs[-5..] + PSAHiding.sync hiddenPSAs + $.set 'hiddenPSAs', hiddenPSAs + sync: (hiddenPSAs) -> + {btn} = PSAHiding + psa = $.id 'globalMessage' + [psa.hidden, btn.innerHTML, btn.className] = if PSAHiding.trim(psa) in hiddenPSAs + [true, '[ + ]', 'show-announcement'] + else + [false, '[ - ]', 'hide-announcement'] + trim: (psa) -> + psa.textContent.replace(/\W+/g, '').toLowerCase() + Fourchan = init: -> return if g.VIEW is 'catalog' diff --git a/src/main.coffee b/src/main.coffee index b59e18916..c99e13483 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -346,6 +346,7 @@ Main = initFeature 'Polyfill', Polyfill initFeature 'Header', Header initFeature 'Settings', Settings + initFeature 'Announcement Hiding', PSAHiding initFeature 'Fourchan thingies', Fourchan initFeature 'Custom CSS', CustomCSS initFeature 'Resurrect Quotes', Quotify From 4811a209fa17d3990f4fff24d66fc79eaf2426f6 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 16 Apr 2013 01:22:49 +0200 Subject: [PATCH 14/22] Release 4chan X v3.1.0. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4729f608d..c43fd3bbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 3.1.0 - *2013-04-16* + - **New feature**: `Announcement Hiding`, enabled by default. - Fix support for www.4chan.org/frames on Chrome. - Fix quote features not working on dead quotelinks in inlined posts. diff --git a/package.json b/package.json index d9ebe7038..c22e0a13e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.0.6", + "version": "3.1.0", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X", From 98f2caf4bcf31f5390638e4726b29961a12cc3e7 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 16 Apr 2013 01:24:30 +0200 Subject: [PATCH 15/22] There should be a span here. --- src/features.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/features.coffee b/src/features.coffee index a55f4168b..6070fdbbc 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -826,9 +826,9 @@ PSAHiding = {btn} = PSAHiding psa = $.id 'globalMessage' [psa.hidden, btn.innerHTML, btn.className] = if PSAHiding.trim(psa) in hiddenPSAs - [true, '[ + ]', 'show-announcement'] + [true, '[ + ]', 'show-announcement'] else - [false, '[ - ]', 'hide-announcement'] + [false, '[ - ]', 'hide-announcement'] trim: (psa) -> psa.textContent.replace(/\W+/g, '').toLowerCase() From 0aa131bdaf1933ca19eeba5b54304cba56402a0e Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 16 Apr 2013 01:30:09 +0200 Subject: [PATCH 16/22] Make the button float. --- css/style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/css/style.css b/css/style.css index 0dcd18830..7426d3c8d 100644 --- a/css/style.css +++ b/css/style.css @@ -374,6 +374,10 @@ a[href="javascript:;"] { :root.hide-announcement #globalMessage { display: none; } +a.hide-announcement, +a.show-announcement { + float: left; +} /* Unread */ #unread-line { From 97a404d4bd112f92424ff3be8e2fb6e693987c78 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 16 Apr 2013 01:30:22 +0200 Subject: [PATCH 17/22] Release 4chan X v3.1.1. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c43fd3bbc..e0ec4dd21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +### 3.1.1 - *2013-04-16* + ## 3.1.0 - *2013-04-16* - **New feature**: `Announcement Hiding`, enabled by default. diff --git a/package.json b/package.json index c22e0a13e..713cf0f9c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.1.0", + "version": "3.1.1", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X", From f7bd8fb722b30fd10ca8cd85d43322e8a8e59c43 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 16 Apr 2013 01:31:56 +0200 Subject: [PATCH 18/22] Changelog. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0ec4dd21..8268b4f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ### 3.1.1 - *2013-04-16* +- Styling adjustments for the announcement toggler. + ## 3.1.0 - *2013-04-16* - **New feature**: `Announcement Hiding`, enabled by default. From 18784b30a10a9280410fda9fdc467eaedd894452 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 16 Apr 2013 03:46:29 +0200 Subject: [PATCH 19/22] God damn CS. --- CHANGELOG.md | 2 ++ src/qr.coffee | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8268b4f4d..5393fe25e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- Fix error with successful posting. + ### 3.1.1 - *2013-04-16* - Styling adjustments for the announcement toggler. diff --git a/src/qr.coffee b/src/qr.coffee index 4359f27bf..30c6b0a84 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -1056,10 +1056,11 @@ QR = val: true # Post/upload confirmed as successful. - $.event 'QRPostSuccessful', + $.event 'QRPostSuccessful', { board: g.BOARD threadID postID + } # Enable auto-posting if we have stuff to post, disable it otherwise. QR.cooldown.auto = QR.posts.length > 1 and isReply From da6e7b6406d4f783246835a8ae952ded71002645 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 16 Apr 2013 03:46:38 +0200 Subject: [PATCH 20/22] Release 4chan X v3.1.2. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5393fe25e..b63f3a3c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +### 3.1.2 - *2013-04-16* + - Fix error with successful posting. ### 3.1.1 - *2013-04-16* diff --git a/package.json b/package.json index 713cf0f9c..163ebf562 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.1.1", + "version": "3.1.2", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X", From 8216e1f7147017293a6efa834d97bdc45963eece Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 16 Apr 2013 06:18:52 +0200 Subject: [PATCH 21/22] Fix infinite loop when switching from the filter tab in the settings. MAXIMUM OVER RUSTLE --- CHANGELOG.md | 2 ++ lib/$.coffee | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b63f3a3c6..a47985f78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- Fix Chrome freezing when switching from the `Filter` tab to another tab in the settings. + ### 3.1.2 - *2013-04-16* - Fix error with successful posting. diff --git a/lib/$.coffee b/lib/$.coffee index 46befcb64..67b57c0ff 100644 --- a/lib/$.coffee +++ b/lib/$.coffee @@ -104,7 +104,8 @@ $.extend $, rmAll: (root) -> # jsperf.com/emptify-element while node = root.firstChild - $.rm node + # HTMLSelectElement.remove !== Element.remove + root.removeChild node return tn: (s) -> d.createTextNode s From a1f38160db40a2a0364aea150285c18c78881fc7 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 16 Apr 2013 06:19:29 +0200 Subject: [PATCH 22/22] Release 4chan X v3.1.3. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a47985f78..1d3b7d08f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +### 3.1.3 - *2013-04-16* + - Fix Chrome freezing when switching from the `Filter` tab to another tab in the settings. ### 3.1.2 - *2013-04-16* diff --git a/package.json b/package.json index 163ebf562..a426e6c75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.1.2", + "version": "3.1.3", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X",