From 679630e88749323671d585502996fbebbec2b7c7 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 15 Jan 2012 14:51:46 +0100 Subject: [PATCH 1/6] Set image limit to 251 for /a/ and /v/, default to 151. --- 4chan_x.user.js | 34 ++++++++++++++++++++-------------- changelog | 2 ++ script.coffee | 27 +++++++++++++++------------ 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a6d241ab4..7b8feb363 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2716,25 +2716,31 @@ threadStats = { init: function() { - var dialog, html; - threadStats.posts = 1; - threadStats.images = $('.op img[md5]') ? 1 : 0; - html = "
" + threadStats.posts + " / " + threadStats.images + "
"; - dialog = ui.dialog('stats', 'bottom: 0; left: 0;', html); + var dialog; + dialog = ui.dialog('stats', 'bottom: 0; left: 0;', '
0 / 0
'); dialog.className = 'dialog'; - threadStats.postcountEl = $('#postcount', dialog); - threadStats.imagecountEl = $('#imagecount', dialog); $.add(d.body, dialog); + threadStats.posts = threadStats.images = 0; + threadStats.imgLimit = (function() { + switch (g.BOARD) { + case 'a': + case 'v': + return 251; + default: + return 151; + } + })(); return g.callbacks.push(threadStats.node); }, node: function(root) { - if (root.className) return; - threadStats.postcountEl.textContent = ++threadStats.posts; - if ($('img[md5]', root)) { - threadStats.imagecountEl.textContent = ++threadStats.images; - if (threadStats.images > 151) { - return threadStats.imagecountEl.className = 'error'; - } + var imgcount; + if (/\binline\b/.test(root.className)) return; + $.id('postcount').textContent = ++threadStats.posts; + if (!$('img[md5]', root)) return; + imgcount = $.id('imagecount'); + imgcount.textContent = ++threadStats.images; + if (threadStats.images > threadStats.imgLimit) { + return imgcount.className = 'error'; } } }; diff --git a/changelog b/changelog index 6a1953df1..264276ac9 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- mayhem + Set image limit in Thread Stats to 251 for /a/ and /v/, default to 151. 2.24.2 - mayhem diff --git a/script.coffee b/script.coffee index d8f96d0e5..c65a93b6e 100644 --- a/script.coffee +++ b/script.coffee @@ -2115,22 +2115,25 @@ reportButton = threadStats = init: -> - threadStats.posts = 1 - threadStats.images = if $ '.op img[md5]' then 1 else 0 - html = "
#{threadStats.posts} / #{threadStats.images}
" - dialog = ui.dialog 'stats', 'bottom: 0; left: 0;', html + dialog = ui.dialog 'stats', 'bottom: 0; left: 0;', '
0 / 0
' dialog.className = 'dialog' - threadStats.postcountEl = $ '#postcount', dialog - threadStats.imagecountEl = $ '#imagecount', dialog $.add d.body, dialog + threadStats.posts = threadStats.images = 0 + threadStats.imgLimit = + switch g.BOARD + when 'a', 'v' + 251 + else + 151 g.callbacks.push threadStats.node node: (root) -> - return if root.className - threadStats.postcountEl.textContent = ++threadStats.posts - if $ 'img[md5]', root - threadStats.imagecountEl.textContent = ++threadStats.images - if threadStats.images > 151 - threadStats.imagecountEl.className = 'error' + return if /\binline\b/.test root.className + $.id('postcount').textContent = ++threadStats.posts + return unless $ 'img[md5]', root + imgcount = $.id 'imagecount' + imgcount.textContent = ++threadStats.images + if threadStats.images > threadStats.imgLimit + imgcount.className = 'error' unread = init: -> From 43bdf70d893bf28d9d5a6f44ab1bd45897022cb4 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 15 Jan 2012 14:55:21 +0100 Subject: [PATCH 2/6] Fix 4chan X in locked threads. --- 4chan_x.user.js | 2 +- changelog | 1 + script.coffee | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7b8feb363..23e52a9da 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3154,7 +3154,7 @@ if (conf['Auto Noko'] && canPost) form.action += '?noko'; if (conf['Cooldown'] && canPost) cooldown.init(); if (conf['Image Expansion']) imgExpand.init(); - if (conf['Quick Reply']) qr.init(); + if (conf['Quick Reply'] && canPost) qr.init(); if (conf['Thread Watcher']) watcher.init(); if (conf['Keybinds']) keybinds.init(); if (g.REPLY) { diff --git a/changelog b/changelog index 264276ac9..b595d0a79 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,7 @@ master - mayhem Set image limit in Thread Stats to 251 for /a/ and /v/, default to 151. + Fix 4chan X in locked threads. 2.24.2 - mayhem diff --git a/script.coffee b/script.coffee index c65a93b6e..4498994e4 100644 --- a/script.coffee +++ b/script.coffee @@ -2498,7 +2498,7 @@ Main = if conf['Image Expansion'] imgExpand.init() - if conf['Quick Reply'] + if conf['Quick Reply'] and canPost qr.init() if conf['Thread Watcher'] From 5490a3136502cdc2be6167df9af9bd51c0b7ff70 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 15 Jan 2012 14:59:51 +0100 Subject: [PATCH 3/6] Release 2.24.3. --- 4chan_x.user.js | 6 +++--- Cakefile | 2 +- changelog | 4 +++- latest.js | 2 +- script.coffee | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 23e52a9da..5478ea374 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan x -// @version 2.24.2 +// @version 2.24.3 // @namespace aeosynth // @description Adds various features. // @copyright 2009-2011 James Campos @@ -18,7 +18,7 @@ * Copyright (c) 2009-2011 James Campos * Copyright (c) 2012 Nicolas Stepien * http://mayhemydg.github.com/4chan-x/ - * 4chan X 2.24.2 + * 4chan X 2.24.3 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -200,7 +200,7 @@ NAMESPACE = '4chan_x.'; - VERSION = '2.24.2'; + VERSION = '2.24.3'; SECOND = 1000; diff --git a/Cakefile b/Cakefile index e52abd8e2..b95e2b2c5 100644 --- a/Cakefile +++ b/Cakefile @@ -2,7 +2,7 @@ {exec} = require 'child_process' fs = require 'fs' -VERSION = '2.24.2' +VERSION = '2.24.3' HEADER = """ // ==UserScript== diff --git a/changelog b/changelog index b595d0a79..8c4014f29 100644 --- a/changelog +++ b/changelog @@ -1,5 +1,7 @@ master -- mayhem + +2.24.3 +- Mayhem Set image limit in Thread Stats to 251 for /a/ and /v/, default to 151. Fix 4chan X in locked threads. diff --git a/latest.js b/latest.js index dc2190293..219917673 100644 --- a/latest.js +++ b/latest.js @@ -1 +1 @@ -postMessage({version:'2.24.2'},'*'); +postMessage({version:'2.24.3'},'*'); diff --git a/script.coffee b/script.coffee index 4498994e4..36f8430b5 100644 --- a/script.coffee +++ b/script.coffee @@ -121,7 +121,7 @@ conf = {} ) null, config NAMESPACE = '4chan_x.' -VERSION = '2.24.2' +VERSION = '2.24.3' SECOND = 1000 MINUTE = 60*SECOND HOUR = 60*MINUTE From 43864f207d67f93335eaf194e97e50a9e81f8de0 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 15 Jan 2012 15:19:06 +0100 Subject: [PATCH 4/6] Revert "don't update closed threads" This reverts commit ee3c82707608d92425607cd58ef28d41247bc648. It can get unclosed. It doesn't matter much network-wise since we use the If-Modified-Since header. Conflicts: 4chan_x.user.js --- 4chan_x.user.js | 1 - script.coffee | 2 -- 2 files changed, 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 5478ea374..c04dc43e7 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1934,7 +1934,6 @@ updater = { init: function() { var checkbox, checked, dialog, html, input, name, title, _i, _len, _ref; - if (!$('form[name=post]')) return; if (conf['Scrolling']) { if (conf['Scroll BG']) { updater.focus = true; diff --git a/script.coffee b/script.coffee index 36f8430b5..50bce829c 100644 --- a/script.coffee +++ b/script.coffee @@ -1548,8 +1548,6 @@ threadHiding = updater = init: -> - #thread closed - return unless $ 'form[name=post]' if conf['Scrolling'] if conf['Scroll BG'] updater.focus = true From 335a972f1ab3cf5b15404904e2502d7c8cba5432 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 15 Jan 2012 22:50:46 +0100 Subject: [PATCH 5/6] Typo, kinda. --- changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog b/changelog index 8c4014f29..4af786053 100644 --- a/changelog +++ b/changelog @@ -2,7 +2,7 @@ master 2.24.3 - Mayhem - Set image limit in Thread Stats to 251 for /a/ and /v/, default to 151. + Set image limit in Thread Stats to 252 for /a/ and /v/, default to 152. Fix 4chan X in locked threads. 2.24.2 From 8313c0519582c1aea6e8e04243a92d347d307baa Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 16 Jan 2012 23:18:46 +0100 Subject: [PATCH 6/6] Shave a line. --- 4chan_x.user.js | 5 ++--- script.coffee | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c04dc43e7..6f59cf6ff 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -762,7 +762,7 @@ } }, parse: function(req, pathname, thread, a) { - var body, br, frag, href, link, next, quote, reply, _i, _j, _len, _len2, _ref, _ref2; + var body, frag, href, link, next, quote, reply, _i, _j, _len, _len2, _ref, _ref2; if (req.status !== 200) { a.textContent = "" + req.status + " " + req.statusText; $.off(a, 'click', expandThread.cb.toggle); @@ -793,8 +793,7 @@ while ((next = a.nextSibling) && !next.clear) { $.rm(next); } - br = next; - return $.before(br, frag); + return $.before(next, frag); } }; diff --git a/script.coffee b/script.coffee index 50bce829c..0b00eb3bd 100644 --- a/script.coffee +++ b/script.coffee @@ -569,8 +569,7 @@ expandThread = # eat everything, then replace with fresh full posts while (next = a.nextSibling) and not next.clear #br[clear] $.rm next - br = next - $.before br, frag + $.before next, frag replyHiding = init: ->