From a70a237f8bd8420ae8c17d30f9a9ab546f074cf9 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 15 Mar 2012 17:11:58 +0100 Subject: [PATCH 01/13] Looks like there are exceptions to the max-width/height of thumbnails. --- 4chan_x.user.js | 8 ++++---- script.coffee | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3fcf74e4d..eff86fd42 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -4299,12 +4299,12 @@ img[md5], img[md5] + img {\ /* revealed spoilers do not have height/width,\ this fixes "expanded" auto-gifs */\ img[md5] {\ - max-height: 251px;\ - max-width: 251px;\ + max-height: 252px;\ + max-width: 252px;\ }\ input ~ a > img[md5] {\ - max-height: 126px;\ - max-width: 126px;\ + max-height: 127px;\ + max-width: 127px;\ }\ \ #qr, #qp, #updater, #stats, #ihover, #overlay, #navlinks {\ diff --git a/script.coffee b/script.coffee index a325c32d3..321c89177 100644 --- a/script.coffee +++ b/script.coffee @@ -3636,12 +3636,12 @@ img[md5], img[md5] + img { /* revealed spoilers do not have height/width, this fixes "expanded" auto-gifs */ img[md5] { - max-height: 251px; - max-width: 251px; + max-height: 252px; + max-width: 252px; } input ~ a > img[md5] { - max-height: 126px; - max-width: 126px; + max-height: 127px; + max-width: 127px; } #qr, #qp, #updater, #stats, #ihover, #overlay, #navlinks { From a9a57a3082e4de0a56efe0b5d4fb72fe262efc59 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 15 Mar 2012 18:00:22 -0700 Subject: [PATCH 02/13] fix #332: separate versioning; add contributing --- readme.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 0a9b4d33a..1ccc502bc 100644 --- a/readme.md +++ b/readme.md @@ -7,4 +7,16 @@ - Clone 4chan X. - `cd` into it and build with `cake build`. - For development (continuous builds), run `cake dev &`. Kill the process with `killall node`. -- Upgrade version with `cake -v VERSION upgrade`. + +# Releasing + +- Upgrade version with `cake -v VERSION upgrade`. Note that this is only used to +release new 4chan x versions, and is not needed or wanted in pull requests. + +# Contributing + +- Edit the changelog +- Edit the CoffeeScript source +- Build the JavaScript +- Fork the repo +- Send a pull request From 00a1fba7126ce51a27662f5c55fb72d67c154432 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 15 Mar 2012 18:49:24 -0700 Subject: [PATCH 03/13] follow my own instructions and edit changelog --- changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog b/changelog index 06142db30..fa6ce1e92 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,8 @@ master - Mayhem Now works when using https. +- aeosynth + add `Releasing` and `Contributing` sections to readme 2.29.1 - Mayhem From 9fa1266e4b995d177dfb60479a0b5471f34c05bb Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 16 Mar 2012 01:47:16 -0700 Subject: [PATCH 04/13] Revert "follow my own instructions and edit changelog" This reverts commit 00a1fba7126ce51a27662f5c55fb72d67c154432. desn't matter for the end user --- changelog | 2 -- 1 file changed, 2 deletions(-) diff --git a/changelog b/changelog index fa6ce1e92..06142db30 100644 --- a/changelog +++ b/changelog @@ -1,8 +1,6 @@ master - Mayhem Now works when using https. -- aeosynth - add `Releasing` and `Contributing` sections to readme 2.29.1 - Mayhem From 52b95e3b184a9ecc5c5d819a906ba9b4d8c46cef Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 16 Mar 2012 01:49:09 -0700 Subject: [PATCH 05/13] only edit changelog if edits affect regular users --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 1ccc502bc..c6012445a 100644 --- a/readme.md +++ b/readme.md @@ -15,8 +15,8 @@ release new 4chan x versions, and is not needed or wanted in pull requests. # Contributing -- Edit the changelog - Edit the CoffeeScript source - Build the JavaScript +- If the edits affect regular users, edit the changelog - Fork the repo - Send a pull request From 9a8fee2e3c687bd980049bdabff702b5c64dcab1 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 17 Mar 2012 12:43:14 +0100 Subject: [PATCH 06/13] Native localStorage functions are usually faster. --- 4chan_x.user.js | 11 ++++------- script.coffee | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index eff86fd42..2f6499a53 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -512,26 +512,23 @@ }, set: function(name, value) { name = NAMESPACE + name; - localStorage[name] = JSON.stringify(value); + localStorage.setItem(name, JSON.stringify(value)); return GM_setValue(name, JSON.stringify(value)); } } : { "delete": function(name) { - name = NAMESPACE + name; - return delete localStorage[name]; + return localStorage.removeItem(NAMESPACE + name); }, get: function(name, defaultValue) { var value; - name = NAMESPACE + name; - if (value = localStorage[name]) { + if (value = localStorage.getItem(NAMESPACE + name)) { return JSON.parse(value); } else { return defaultValue; } }, set: function(name, value) { - name = NAMESPACE + name; - return localStorage[name] = JSON.stringify(value); + return localStorage.setItem(NAMESPACE + name, JSON.stringify(value)); } }); diff --git a/script.coffee b/script.coffee index 321c89177..3f0631cf0 100644 --- a/script.coffee +++ b/script.coffee @@ -434,21 +434,18 @@ $.extend $, set: (name, value) -> name = NAMESPACE + name # for `storage` events - localStorage[name] = JSON.stringify value + localStorage.setItem name, JSON.stringify value GM_setValue name, JSON.stringify value else delete: (name) -> - name = NAMESPACE + name - delete localStorage[name] + localStorage.removeItem NAMESPACE + name get: (name, defaultValue) -> - name = NAMESPACE + name - if value = localStorage[name] + if value = localStorage.getItem NAMESPACE + name JSON.parse value else defaultValue set: (name, value) -> - name = NAMESPACE + name - localStorage[name] = JSON.stringify value + localStorage.setItem NAMESPACE + name, JSON.stringify value $$ = (selector, root=d.body) -> Array::slice.call root.querySelectorAll selector From ed3cc48d3fe4906e010bd8e1ad521e2902d4af56 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 17 Mar 2012 13:08:41 +0100 Subject: [PATCH 07/13] Don't preParse isOP, as it's only used in the filter and is incorrect or ambiguous for inlined posts. --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 2f6499a53..c3d0ab3fd 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -592,6 +592,7 @@ node: function(post) { var el, filter, firstThread, isOP, key, result, thisThread, value, _i, _len, _ref; if (post.isInlined) return; + post.isOP = post["class"] === 'op'; isOP = post.isOP, el = post.el; for (key in Filter.filters) { value = Filter[key](post); @@ -4008,7 +4009,6 @@ "class": klass, id: node.getElementsByTagName('input')[0].name, threadId: g.THREAD_ID || $.x('ancestor::div[@class="thread"]', node).firstChild.id, - isOP: klass === 'op', isInlined: /\binline\b/.test(klass), filesize: node.getElementsByClassName('filesize')[0] || false, quotes: node.getElementsByClassName('quotelink'), diff --git a/script.coffee b/script.coffee index 3f0631cf0..30146cef2 100644 --- a/script.coffee +++ b/script.coffee @@ -524,6 +524,7 @@ Filter = node: (post) -> return if post.isInlined + post.isOP = post.class is 'op' {isOP, el} = post for key of Filter.filters value = Filter[key] post @@ -3365,7 +3366,6 @@ Main = class: klass id: node.getElementsByTagName('input')[0].name threadId: g.THREAD_ID or $.x('ancestor::div[@class="thread"]', node).firstChild.id - isOP: klass is 'op' isInlined: /\binline\b/.test klass filesize: node.getElementsByClassName('filesize')[0] or false quotes: node.getElementsByClassName 'quotelink' From 8bc82be67796b5e27b28b4c4225648fa29c91e92 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 17 Mar 2012 13:18:32 +0100 Subject: [PATCH 08/13] Fix >>>/board/id still displayed as filtered after unhiding its linked post. --- 4chan_x.user.js | 2 +- script.coffee | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c3d0ab3fd..1c9089fba 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -905,7 +905,7 @@ table.hidden = false; $.rm(parent); id = table.firstChild.firstChild.lastChild.id; - _ref2 = $$(".quotelink[href='#" + id + "'], .backlink[href='#" + id + "']"); + _ref2 = $$(".quotelink[href$='#" + id + "'], .backlink[href='#" + id + "']"); for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { quote = _ref2[_j]; $.removeClass(quote, 'filtered'); diff --git a/script.coffee b/script.coffee index 30146cef2..f295c56d8 100644 --- a/script.coffee +++ b/script.coffee @@ -524,7 +524,7 @@ Filter = node: (post) -> return if post.isInlined - post.isOP = post.class is 'op' + post.isOP = post.class is 'op' {isOP, el} = post for key of Filter.filters value = Filter[key] post @@ -769,7 +769,7 @@ ReplyHiding = table.hidden = false $.rm parent id = table.firstChild.firstChild.lastChild.id - for quote in $$ ".quotelink[href='##{id}'], .backlink[href='##{id}']" + for quote in $$ ".quotelink[href$='##{id}'], .backlink[href='##{id}']" $.removeClass quote, 'filtered' delete g.hiddenReplies[id] $.set "hiddenReplies/#{g.BOARD}/", g.hiddenReplies From b2792a05f97f1db878991c795dbe52aae4df4138 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 18 Mar 2012 01:21:45 +0100 Subject: [PATCH 09/13] Fix cross-thread quotes after expanding the comment. --- 4chan_x.user.js | 8 +++++--- script.coffee | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1c9089fba..a8d8ac40b 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -735,7 +735,7 @@ })); }, parse: function(req, a, threadID, replyID) { - var doc, node, post, quote, quotes, _i, _len; + var doc, href, node, post, quote, quotes, _i, _len; if (req.status !== 200) { a.textContent = "" + req.status + " " + req.statusText; return; @@ -747,8 +747,10 @@ quotes = node.getElementsByClassName('quotelink'); for (_i = 0, _len = quotes.length; _i < _len; _i++) { quote = quotes[_i]; - if (quote.hash === quote.getAttribute('href')) { + if (quote.hash === (href = quote.getAttribute('href'))) { quote.pathname = "/" + g.BOARD + "/res/" + threadID; + } else if (href !== quote.href) { + quote.href = "res/" + href; } } post = { @@ -853,7 +855,7 @@ _ref2 = $$('.quotelink', table); for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { quote = _ref2[_j]; - if ((href = quote.getAttribute('href')) === quote.hash) { + if (quote.hash === (href = quote.getAttribute('href'))) { quote.pathname = pathname; } else if (href !== quote.href) { quote.href = "res/" + href; diff --git a/script.coffee b/script.coffee index f295c56d8..244ba74a8 100644 --- a/script.coffee +++ b/script.coffee @@ -646,8 +646,10 @@ ExpandComment = quotes = node.getElementsByClassName 'quotelink' for quote in quotes - if quote.hash is quote.getAttribute 'href' + if quote.hash is href = quote.getAttribute 'href' # Add pathname to in-thread quotes quote.pathname = "/#{g.BOARD}/res/#{threadID}" + else if href isnt quote.href # Fix cross-thread links, not cross-board ones + quote.href = "res/#{href}" post = el: node threadId: threadID @@ -726,9 +728,9 @@ ExpandThread = for reply in $$ '.reply', doc table = d.importNode reply.parentNode.parentNode.parentNode for quote in $$ '.quotelink', table - if (href = quote.getAttribute 'href') is quote.hash #add pathname to normal quotes + if quote.hash is href = quote.getAttribute 'href' # Add pathname to in-thread quotes quote.pathname = pathname - else if href isnt quote.href #fix x-thread links, not x-board ones + else if href isnt quote.href # Fix cross-thread links, not cross-board ones quote.href = "res/#{href}" link = $ '.quotejs', table link.href = "res/#{thread.firstChild.id}##{reply.id}" From 8e09b7b483c6c94e8a08a7ecfef323c349c109df Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 18 Mar 2012 20:13:52 +0100 Subject: [PATCH 10/13] Fix #346. I dislike this CSS. --- 4chan_x.user.js | 7 ++----- script.coffee | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a8d8ac40b..a121df15f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2426,7 +2426,7 @@ _ref = $$('.thread'); for (_i = 0, _len = _ref.length; _i < _len; _i++) { thread = _ref[_i]; - op = thread.firstChild; + op = $('.op', thread); a = $.el('a', { textContent: '[ - ]', href: 'javascript:;' @@ -4069,10 +4069,7 @@ a[href="javascript:;"] {\ text-decoration: none;\ }\ \ -.block ~ .op,\ -.block ~ .omittedposts,\ -.block ~ table,\ -.block ~ br,\ +.block ~ *,\ #content > [name=tab]:not(:checked) + div,\ #updater:not(:hover) > :not(.move),\ #qp > input, #qp .inline, .forwarded {\ diff --git a/script.coffee b/script.coffee index 244ba74a8..d82d7d43c 100644 --- a/script.coffee +++ b/script.coffee @@ -2043,7 +2043,7 @@ ThreadHiding = init: -> hiddenThreads = $.get "hiddenThreads/#{g.BOARD}/", {} for thread in $$ '.thread' - op = thread.firstChild + op = $ '.op', thread a = $.el 'a', textContent: '[ - ]' href: 'javascript:;' @@ -3406,10 +3406,7 @@ a[href="javascript:;"] { text-decoration: none; } -.block ~ .op, -.block ~ .omittedposts, -.block ~ table, -.block ~ br, +.block ~ *, #content > [name=tab]:not(:checked) + div, #updater:not(:hover) > :not(.move), #qp > input, #qp .inline, .forwarded { From 991c88fc7511cb031e5b768a0a5331cd0948405a Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 18 Mar 2012 20:25:00 +0100 Subject: [PATCH 11/13] Close #343. --- 4chan_x.user.js | 3 ++- script.coffee | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a121df15f..de50674ef 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2847,7 +2847,7 @@ var day, hour, min, month, year, _, _ref; _ref = node.textContent.match(/(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\d+)/), _ = _ref[0], month = _ref[1], day = _ref[2], year = _ref[3], hour = _ref[4], min = _ref[5]; year = "20" + year; - month -= 1; + month--; hour = chanOffset + Number(hour); return new Date(year, month, day, hour, min); }; @@ -2861,6 +2861,7 @@ time = $.el('time', { textContent: ' ' + Time.funk(Time) + ' ' }); + time.setAttribute('datetime', Time.date.toISOString()); return $.replace(node, time); }, foo: function() { diff --git a/script.coffee b/script.coffee index d82d7d43c..5b97558aa 100644 --- a/script.coffee +++ b/script.coffee @@ -2408,7 +2408,7 @@ Time = [_, month, day, year, hour, min] = node.textContent.match /(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\d+)/ year = "20#{year}" - month -= 1 #months start at 0 + month-- # Months start at 0 hour = chanOffset + Number hour new Date year, month, day, hour, min @@ -2420,6 +2420,8 @@ Time = Time.date = Time.parse node time = $.el 'time', textContent: ' ' + Time.funk(Time) + ' ' + # Set the datetime attribute, ISO'd. + time.setAttribute 'datetime', Time.date.toISOString() $.replace node, time foo: -> code = conf['time'].replace /%([A-Za-z])/g, (s, c) -> From 4ea4dc863bb529bdc63836f7730898a195347490 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 19 Mar 2012 23:19:46 +0100 Subject: [PATCH 12/13] Fix #325. --- 4chan_x.user.js | 19 ++++++++----------- script.coffee | 10 ++++------ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index de50674ef..81bddb99f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2079,6 +2079,13 @@ req: 'response', html: this.response }); + }, + onerror: function() { + return qr.message.send({ + req: 'status', + ready: true, + banned: true + }); } }; opts = { @@ -2104,17 +2111,7 @@ 'Content-Type': 'multipart/form-data;boundary=' + boundary }; } - try { - return qr.ajax = $.ajax(url, callbacks, opts); - } catch (e) { - if (e.name === 'NETWORK_ERR') { - return qr.message.send({ - req: 'status', - ready: true, - banned: true - }); - } - } + return qr.ajax = $.ajax(url, callbacks, opts); } } }; diff --git a/script.coffee b/script.coffee index 5b97558aa..7eaaff73d 100644 --- a/script.coffee +++ b/script.coffee @@ -1747,6 +1747,9 @@ qr = qr.message.send req: 'response' html: @response + onerror: -> + # CORS disabled error: redirecting to banned page ;_; + qr.message.send req: 'status', ready: true, banned: true opts = form: form type: 'post' @@ -1763,12 +1766,7 @@ qr = opts.headers = 'Content-Type': 'multipart/form-data;boundary=' + boundary - try - qr.ajax = $.ajax url, callbacks, opts - catch e - # CORS disabled error: redirecting to banned page ;_; - if e.name is 'NETWORK_ERR' - qr.message.send req: 'status', ready: true, banned: true + qr.ajax = $.ajax url, callbacks, opts Options = init: -> From 8712d29e46d39c64ed70696b69a816c419a53b48 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 19 Mar 2012 23:34:15 +0100 Subject: [PATCH 13/13] More compatible File Info Formatting. --- 4chan_x.user.js | 22 ++++++++++++---------- script.coffee | 21 +++++++++------------ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 81bddb99f..3934927d7 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2945,21 +2945,23 @@ return g.callbacks.push(this.node); }, node: function(post) { - var fullname, link, node, regexp, resolution, shortname, size, type, unit, _, _ref; + var data, link, node, regexp, resolution, size, span, unit, _, _ref; if (post["class"] === 'inline' || !(node = post.filesize)) return; - type = node.childElementCount === 2 ? 0 : 1; - regexp = type ? /^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF)/ : /^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF), ([^<]+)/; - _ref = node.innerHTML.match(regexp), _ = _ref[0], link = _ref[1], size = _ref[2], unit = _ref[3], resolution = _ref[4], fullname = _ref[5], shortname = _ref[6]; - FileInfo.data = { + regexp = /^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF)/; + _ref = node.innerHTML.match(regexp), _ = _ref[0], link = _ref[1], size = _ref[2], unit = _ref[3], resolution = _ref[4]; + data = { link: link, size: size, unit: unit, - resolution: resolution, - fullname: fullname, - shortname: shortname, - type: type + resolution: resolution }; - return node.innerHTML = FileInfo.funks[type](FileInfo); + if (span = $('span', node)) { + data.fullname = span.title; + data.shortname = span.textContent; + } + data.type = +(!span); + FileInfo.data = data; + return node.innerHTML = FileInfo.funks[data.type](FileInfo); }, setFormats: function() { var code, format, funks, i, param; diff --git a/script.coffee b/script.coffee index 7eaaff73d..84688eec2 100644 --- a/script.coffee +++ b/script.coffee @@ -2476,23 +2476,20 @@ FileInfo = g.callbacks.push @node node: (post) -> return if post.class is 'inline' or not node = post.filesize - type = if node.childElementCount is 2 then 0 else 1 - regexp = - if type - /^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF)/ - else - /^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF), ([^<]+)/ - [_, link, size, unit, resolution, fullname, shortname] = + regexp = /^File: (<.+>)-\((?:Spoiler Image, )?([\d\.]+) (\w+), (\d+x\d+|PDF)/ + [_, link, size, unit, resolution] = node.innerHTML.match regexp - FileInfo.data = + data = link: link size: size unit: unit resolution: resolution - fullname: fullname - shortname: shortname - type: type - node.innerHTML = FileInfo.funks[type] FileInfo + if span = $ 'span', node + data.fullname = span.title + data.shortname = span.textContent + data.type = +!span + FileInfo.data = data + node.innerHTML = FileInfo.funks[data.type] FileInfo setFormats: -> funks = [] for i in [0..1]