From 3d28298ed0641cbb5bc77478e872794fee8f0e1a Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 24 Dec 2011 02:54:06 +0100 Subject: [PATCH 01/27] Add omploader. --- 4chan_x.user.js | 2 +- changelog | 2 ++ script.coffee | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c5d14a3a3..9b285e88d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -133,7 +133,7 @@ filesize: '', md5: '' }, - flavors: ['http://iqdb.org/?url=', 'http://google.com/searchbyimage?image_url=', '#http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url=', '#http://3d.iqdb.org/?url=', '#http://regex.info/exif.cgi?imgurl=', '#http://imgur.com/upload?url='].join('\n'), + flavors: ['http://iqdb.org/?url=', 'http://google.com/searchbyimage?image_url=', '#http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url=', '#http://3d.iqdb.org/?url=', '#http://regex.info/exif.cgi?imgurl=', '#http://imgur.com/upload?url=', '#http://ompldr.org/upload?url1='].join('\n'), time: '%m/%d/%y(%a)%H:%M', backlink: '>>%id', favicon: 'ferongr', diff --git a/changelog b/changelog index 7623ebde9..daad97e12 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- mayhem + add omploader to the list of optional flavors (http://ompldr.org/upload?url1=) 2.23.7 - mayhem diff --git a/script.coffee b/script.coffee index 2a9696ef8..bb9f1ea86 100644 --- a/script.coffee +++ b/script.coffee @@ -64,6 +64,7 @@ config = '#http://3d.iqdb.org/?url=' '#http://regex.info/exif.cgi?imgurl=' '#http://imgur.com/upload?url=' + '#http://ompldr.org/upload?url1=' ].join '\n' time: '%m/%d/%y(%a)%H:%M' backlink: '>>%id' From 335d0e7f922510b40e4f8012e39651ae984fdb74 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 26 Dec 2011 17:48:07 +0100 Subject: [PATCH 02/27] Remove CSS workaround that got fixed in Fx9. --- 4chan_x.user.js | 1 - script.coffee | 1 - 2 files changed, 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 9b285e88d..0e17ce38c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3208,7 +3208,6 @@ text-decoration: none;\ }\ \ - [hidden], /* Firefox bug: hidden tables are not hidden. fixed in 9.0 */\ .thread.stub > :not(.block),\ #content > [name=tab]:not(:checked) + div,\ #updater:not(:hover) > :not(.move),\ diff --git a/script.coffee b/script.coffee index bb9f1ea86..73935d937 100644 --- a/script.coffee +++ b/script.coffee @@ -2565,7 +2565,6 @@ Main = text-decoration: none; } - [hidden], /* Firefox bug: hidden tables are not hidden. fixed in 9.0 */ .thread.stub > :not(.block), #content > [name=tab]:not(:checked) + div, #updater:not(:hover) > :not(.move), From eb22d553c3763679f836f7b53d5b8f9c024cdd6b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Dec 2011 04:37:58 +0100 Subject: [PATCH 03/27] Let the report button open multiple popups. Close #83 --- 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 0e17ce38c..d391c0cc8 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2701,7 +2701,7 @@ report: function() { var id, set, url; url = "http://sys.4chan.org/" + g.BOARD + "/imgboard.php?mode=report&no=" + ($.x('preceding-sibling::input', this).name); - id = "" + NAMESPACE + "popup"; + id = new Date().getTime(); set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=200"; return window.open(url, id, set); } diff --git a/changelog b/changelog index daad97e12..00ded2b35 100644 --- a/changelog +++ b/changelog @@ -1,5 +1,6 @@ master - mayhem + the report button can open multiple popups add omploader to the list of optional flavors (http://ompldr.org/upload?url1=) 2.23.7 diff --git a/script.coffee b/script.coffee index 73935d937..719ae450d 100644 --- a/script.coffee +++ b/script.coffee @@ -2102,7 +2102,7 @@ reportButton = $.on a, 'click', reportButton.report report: -> url = "http://sys.4chan.org/#{g.BOARD}/imgboard.php?mode=report&no=#{$.x('preceding-sibling::input', @).name}" - id = "#{NAMESPACE}popup" + id = new Date().getTime() set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=200" window.open url, id, set From 691395b627ed21b6e2b14dd3bbbe2f0dd30016dd Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Dec 2011 06:30:11 +0100 Subject: [PATCH 04/27] Update foolz archives redirection, close #71. Get #79 done, will need testing and foolz archive's support. --- 4chan_x.user.js | 120 +++++++++++++++++++++++++++--------------------- Cakefile | 1 + changelog | 4 +- script.coffee | 55 ++++++++++++++-------- 4 files changed, 107 insertions(+), 73 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d391c0cc8..a0975a19a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -6,6 +6,7 @@ // @copyright 2009-2011 James Campos // @license MIT; http://en.wikipedia.org/wiki/Mit_license // @include http://boards.4chan.org/* +// @include http://images.4chan.org/* // @include http://sys.4chan.org/* // @run-at document-start // @updateURL https://raw.github.com/MayhemYDG/4chan-x/stable/4chan_x.user.js @@ -70,7 +71,7 @@ config = { main: { Enhancing: { - '404 Redirect': [true, 'Redirect dead threads'], + '404 Redirect': [true, 'Redirect dead threads and images'], 'Keybinds': [true, 'Binds actions to keys'], 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'], 'Report Button': [true, 'Add report buttons'], @@ -2819,49 +2820,61 @@ } }; - redirect = function() { - var url; - switch (g.BOARD) { - case 'a': - case 'jp': - case 'm': - case 'tg': - case 'tv': - url = "http://oldarchive.foolz.us/" + g.BOARD + "/thread/" + g.THREAD_ID; - break; - case 'diy': - case 'g': - case 'sci': - url = "http://archive.installgentoo.net/" + g.BOARD + "/thread/" + g.THREAD_ID; - break; - case '3': - case 'adv': - case 'an': - case 'ck': - case 'co': - case 'fa': - case 'fit': - case 'int': - case 'k': - case 'mu': - case 'n': - case 'o': - case 'p': - case 'po': - case 'pol': - case 'soc': - case 'sp': - case 'toy': - case 'trv': - case 'v': - case 'vp': - case 'x': - url = "http://archive.no-ip.org/" + g.BOARD + "/thread/" + g.THREAD_ID; - break; - default: - url = "http://boards.4chan.org/" + g.BOARD; + redirect = { + init: function() { + var url; + url = location.hostname === 'images.4chan.org' ? redirect.image(g.BOARD, location.pathname.split('/')[3]) : /^\d+$/.test(g.THREAD_ID) ? redirect.thread() : void 0; + if (url) return location.href = url; + }, + image: function(board, filename) { + switch (board) { + case 'a': + case 'jp': + case 'm': + case 'tg': + case 'tv': + return "http://archivethumb.foolz.us/board/" + board + "/img/" + filename; + } + }, + thread: function() { + switch (g.BOARD) { + case 'a': + case 'jp': + case 'm': + case 'tg': + case 'tv': + return "http://archive.foolz.us/" + g.BOARD + "/thread/" + g.THREAD_ID; + case 'diy': + case 'g': + case 'sci': + return "http://archive.installgentoo.net/" + g.BOARD + "/thread/" + g.THREAD_ID; + case '3': + case 'adv': + case 'an': + case 'ck': + case 'co': + case 'fa': + case 'fit': + case 'int': + case 'k': + case 'mu': + case 'n': + case 'o': + case 'p': + case 'po': + case 'pol': + case 'soc': + case 'sp': + case 'toy': + case 'trv': + case 'v': + case 'vp': + case 'x': + return "http://archive.no-ip.org/" + g.BOARD + "/thread/" + g.THREAD_ID; + default: + return "http://boards.4chan.org/" + g.BOARD; + } } - return location.href = url; }; imgHover = { @@ -2973,26 +2986,29 @@ thumb.hidden = false; return $.rm(thumb.nextSibling); }, - expand: function(thumb) { + expand: function(thumb, url) { var a, filesize, img, max; a = thumb.parentNode; img = $.el('img', { - src: a.href + src: url ? url : a.href }); if (engine === 'gecko' && a.parentNode.className !== 'op') { filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent; max = filesize.match(/(\d+)x/); img.style.maxWidth = "" + max[1] + "px"; } - $.on(img, 'error', imgExpand.error); + if (conf['404 Redirect']) $.on(img, 'error', imgExpand.error); thumb.hidden = true; return $.add(a, img); }, error: function() { - var req, thumb; + var req, src, thumb, url; thumb = this.previousSibling; imgExpand.contract(thumb); - if (engine === 'webkit') { + src = this.src.split('/'); + if (url = redirect.image(src[3], src[5])) { + return imgExpand.expand(thumb, url); + } else if (engine === 'webkit') { return req = $.ajax(this.src, (function() { if (this.status !== 404) { return setTimeout(imgExpand.retry, 10000, thumb); @@ -3042,7 +3058,7 @@ pathname = location.pathname.slice(1).split('/'); g.BOARD = pathname[0], temp = pathname[1]; if (temp === 'res') { - g.REPLY = temp; + g.REPLY = true; g.THREAD_ID = pathname[2]; } else { g.PAGENUM = parseInt(temp) || 0; @@ -3111,11 +3127,11 @@ onLoad: function() { var callback, canPost, form, node, nodes, _i, _j, _len, _len2, _ref; $.off(d, 'DOMContentLoaded', Main.onLoad); - if (conf['404 Redirect'] && d.title === '4chan - 404' && /^\d+$/.test(g.THREAD_ID)) { - redirect(); + if (conf['404 Redirect'] && d.title === '4chan - 404') { + redirect.init(); return; } - if (!$('#navtopr')) return; + if (!$('#navtopr') || location.hostname === 'images.4chan.org') return; $.addClass(d.body, engine); $.addStyle(Main.css); threading.init(); diff --git a/Cakefile b/Cakefile index 43bb0c87f..195cbb959 100644 --- a/Cakefile +++ b/Cakefile @@ -13,6 +13,7 @@ HEADER = """ // @copyright 2009-2011 James Campos // @license MIT; http://en.wikipedia.org/wiki/Mit_license // @include http://boards.4chan.org/* +// @include http://images.4chan.org/* // @include http://sys.4chan.org/* // @run-at document-start // @updateURL https://raw.github.com/MayhemYDG/4chan-x/stable/4chan_x.user.js diff --git a/changelog b/changelog index 00ded2b35..dc57939e7 100644 --- a/changelog +++ b/changelog @@ -1,7 +1,9 @@ master - mayhem - the report button can open multiple popups + redirect 404'd pictures to archives when possible + the report button can open multiple popups again add omploader to the list of optional flavors (http://ompldr.org/upload?url1=) + update archive redirections 2.23.7 - mayhem diff --git a/script.coffee b/script.coffee index 719ae450d..ab4dfa06b 100644 --- a/script.coffee +++ b/script.coffee @@ -1,7 +1,7 @@ config = main: Enhancing: - '404 Redirect': [true, 'Redirect dead threads'] + '404 Redirect': [true, 'Redirect dead threads and images'] 'Keybinds': [true, 'Binds actions to keys'] 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'] 'Report Button': [true, 'Add report buttons'] @@ -2216,17 +2216,29 @@ Favicon = favicon.href = null $.replace favicon, clone -redirect = -> - switch g.BOARD - when 'a', 'jp', 'm', 'tg', 'tv' - url = "http://oldarchive.foolz.us/#{g.BOARD}/thread/#{g.THREAD_ID}" - when 'diy', 'g', 'sci' - url = "http://archive.installgentoo.net/#{g.BOARD}/thread/#{g.THREAD_ID}" - when '3', 'adv', 'an', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'pol', 'soc', 'sp', 'toy', 'trv', 'v', 'vp', 'x' - url = "http://archive.no-ip.org/#{g.BOARD}/thread/#{g.THREAD_ID}" - else - url = "http://boards.4chan.org/#{g.BOARD}" - location.href = url +redirect = + init: -> + url = + # waiting for https://github.com/FoOlRulez/FoOlFuuka/issues/11 + if location.hostname is 'images.4chan.org' + redirect.image g.BOARD, location.pathname.split('/')[3] + else if /^\d+$/.test g.THREAD_ID + redirect.thread() + location.href = url if url + image: (board, filename) -> #board must be given, the image can originate from a cross-quote + switch board + when 'a', 'jp', 'm', 'tg', 'tv' + "http://archivethumb.foolz.us/board/#{board}/img/#{filename}" + thread: -> + switch g.BOARD + when 'a', 'jp', 'm', 'tg', 'tv' + "http://archive.foolz.us/#{g.BOARD}/thread/#{g.THREAD_ID}" + when 'diy', 'g', 'sci' + "http://archive.installgentoo.net/#{g.BOARD}/thread/#{g.THREAD_ID}" + when '3', 'adv', 'an', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'pol', 'soc', 'sp', 'toy', 'trv', 'v', 'vp', 'x' + "http://archive.no-ip.org/#{g.BOARD}/thread/#{g.THREAD_ID}" + else + "http://boards.4chan.org/#{g.BOARD}" imgHover = init: -> @@ -2303,23 +2315,26 @@ imgExpand = thumb.hidden = false $.rm thumb.nextSibling - expand: (thumb) -> + expand: (thumb, url) -> a = thumb.parentNode img = $.el 'img', - src: a.href + src: if url then url else a.href if engine is 'gecko' and a.parentNode.className isnt 'op' filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent max = filesize.match /(\d+)x/ img.style.maxWidth = "#{max[1]}px" - $.on img, 'error', imgExpand.error + $.on img, 'error', imgExpand.error if conf['404 Redirect'] thumb.hidden = true $.add a, img error: -> thumb = @previousSibling imgExpand.contract thumb + src = @src.split '/' + if url = redirect.image src[3], src[5] + imgExpand.expand thumb, url #navigator.online is not x-browser/os yet - if engine is 'webkit' + else if engine is 'webkit' req = $.ajax @src, (-> setTimeout imgExpand.retry, 10000, thumb if @status isnt 404 ), type: 'head', event: 'onreadystatechange' @@ -2358,7 +2373,7 @@ Main = pathname = location.pathname[1..].split('/') [g.BOARD, temp] = pathname if temp is 'res' - g.REPLY = temp + g.REPLY = true g.THREAD_ID = pathname[2] else g.PAGENUM = parseInt(temp) or 0 @@ -2453,10 +2468,10 @@ Main = onLoad: -> $.off d, 'DOMContentLoaded', Main.onLoad - if conf['404 Redirect'] and d.title is '4chan - 404' and /^\d+$/.test g.THREAD_ID - redirect() + if conf['404 Redirect'] and d.title is '4chan - 404' + redirect.init() return - if not $ '#navtopr' + if not $('#navtopr') or location.hostname is 'images.4chan.org' return $.addClass d.body, engine $.addStyle Main.css From f221b09f631744bae28834c73cee6a34f5cb6962 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Dec 2011 21:16:45 +0100 Subject: [PATCH 05/27] Twice faster and shorter. --- 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 a0975a19a..539b321a0 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -972,7 +972,7 @@ } break; case conf.unreadCountTo0: - unread.replies.length = 0; + unread.replies = []; unread.updateTitle(); Favicon.update(); break; diff --git a/script.coffee b/script.coffee index ab4dfa06b..0999439f6 100644 --- a/script.coffee +++ b/script.coffee @@ -709,7 +709,7 @@ keybinds = else $('.postarea form').submit() when conf.unreadCountTo0 - unread.replies.length = 0 + unread.replies = [] unread.updateTitle() Favicon.update() else From ccc6e009de9fd0fc53f326834b7b4e35d21857cd Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Dec 2011 23:22:59 +0100 Subject: [PATCH 06/27] Decrease the unread count when inlining unread posts. Close #57 --- 4chan_x.user.js | 7 ++++++- changelog | 1 + script.coffee | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 539b321a0..85127f929 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2469,10 +2469,15 @@ return this.classList.toggle('inlined'); }, add: function(q, id) { - var el, inline, pathname, root, threadID; + var el, i, inline, pathname, root, threadID; root = q.parentNode.nodeName === 'FONT' ? q.parentNode : q.nextSibling ? q.nextSibling : q; if (el = $.id(id)) { inline = quoteInline.table(id, el.innerHTML); + if (g.REPLY && conf['Unread Count'] && (i = unread.replies.indexOf(el.parentNode.parentNode.parentNode)) !== -1) { + unread.replies.splice(i, 1); + unread.updateTitle(); + Favicon.update(); + } if (/\bbacklink\b/.test(q.className)) { $.after(q.parentNode, inline); if (conf['Forward Hiding']) { diff --git a/changelog b/changelog index dc57939e7..514b910c4 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,7 @@ master - mayhem redirect 404'd pictures to archives when possible + the unread count will decrease when inlining quotes of unread posts the report button can open multiple popups again add omploader to the list of optional flavors (http://ompldr.org/upload?url1=) update archive redirections diff --git a/script.coffee b/script.coffee index 0999439f6..cdce5bfbf 100644 --- a/script.coffee +++ b/script.coffee @@ -1959,6 +1959,10 @@ quoteInline = root = if q.parentNode.nodeName is 'FONT' then q.parentNode else if q.nextSibling then q.nextSibling else q if el = $.id id inline = quoteInline.table id, el.innerHTML + if g.REPLY and conf['Unread Count'] and (i = unread.replies.indexOf el.parentNode.parentNode.parentNode) isnt -1 + unread.replies.splice i, 1 + unread.updateTitle() + Favicon.update() if /\bbacklink\b/.test q.className $.after q.parentNode, inline $.addClass $.x('ancestor::table', el), 'forwarded' if conf['Forward Hiding'] From b2c3c6522fe24e1202e88b49a7da4db8dfeb1feb Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 29 Dec 2011 01:59:30 +0100 Subject: [PATCH 07/27] Use Date.now() --- 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 85127f929..76c13dda7 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2707,7 +2707,7 @@ report: function() { var id, set, url; url = "http://sys.4chan.org/" + g.BOARD + "/imgboard.php?mode=report&no=" + ($.x('preceding-sibling::input', this).name); - id = new Date().getTime(); + id = Date.now(); set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=200"; return window.open(url, id, set); } diff --git a/script.coffee b/script.coffee index cdce5bfbf..92e7806be 100644 --- a/script.coffee +++ b/script.coffee @@ -2106,7 +2106,7 @@ reportButton = $.on a, 'click', reportButton.report report: -> url = "http://sys.4chan.org/#{g.BOARD}/imgboard.php?mode=report&no=#{$.x('preceding-sibling::input', @).name}" - id = new Date().getTime() + id = Date.now() set = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=685,height=200" window.open url, id, set From 6df5a9311b7505a8c6ed0baed74d55c747d7ab1c Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 29 Dec 2011 02:04:39 +0100 Subject: [PATCH 08/27] Add /u/ archive redirection. --- 4chan_x.user.js | 2 ++ script.coffee | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 76c13dda7..c526dc86a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2838,6 +2838,7 @@ case 'm': case 'tg': case 'tv': + case 'u': return "http://archivethumb.foolz.us/board/" + board + "/img/" + filename; } }, @@ -2848,6 +2849,7 @@ case 'm': case 'tg': case 'tv': + case 'u': return "http://archive.foolz.us/" + g.BOARD + "/thread/" + g.THREAD_ID; case 'diy': case 'g': diff --git a/script.coffee b/script.coffee index 92e7806be..eb3434272 100644 --- a/script.coffee +++ b/script.coffee @@ -2231,11 +2231,11 @@ redirect = location.href = url if url image: (board, filename) -> #board must be given, the image can originate from a cross-quote switch board - when 'a', 'jp', 'm', 'tg', 'tv' + when 'a', 'jp', 'm', 'tg', 'tv', 'u' "http://archivethumb.foolz.us/board/#{board}/img/#{filename}" thread: -> switch g.BOARD - when 'a', 'jp', 'm', 'tg', 'tv' + when 'a', 'jp', 'm', 'tg', 'tv', 'u' "http://archive.foolz.us/#{g.BOARD}/thread/#{g.THREAD_ID}" when 'diy', 'g', 'sci' "http://archive.installgentoo.net/#{g.BOARD}/thread/#{g.THREAD_ID}" From fcc0d61f723b8e04d267777e7078e72fae98e174 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 29 Dec 2011 02:08:52 +0100 Subject: [PATCH 09/27] Add /lit/ archive redirection. --- 4chan_x.user.js | 4 +++- script.coffee | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c526dc86a..c3d47f01c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2850,7 +2850,9 @@ case 'tg': case 'tv': case 'u': - return "http://archive.foolz.us/" + g.BOARD + "/thread/" + g.THREAD_ID; + return "http://archive.foolz.us/" + g.BOARD + "/thread/" + g.THREAD_ID + "/"; + case 'lit': + return "http://fuuka.warosu.org/" + g.BOARD + "/thread/" + g.THREAD_ID; case 'diy': case 'g': case 'sci': diff --git a/script.coffee b/script.coffee index eb3434272..3243d802c 100644 --- a/script.coffee +++ b/script.coffee @@ -2236,7 +2236,9 @@ redirect = thread: -> switch g.BOARD when 'a', 'jp', 'm', 'tg', 'tv', 'u' - "http://archive.foolz.us/#{g.BOARD}/thread/#{g.THREAD_ID}" + "http://archive.foolz.us/#{g.BOARD}/thread/#{g.THREAD_ID}/" + when 'lit' + "http://fuuka.warosu.org/#{g.BOARD}/thread/#{g.THREAD_ID}" when 'diy', 'g', 'sci' "http://archive.installgentoo.net/#{g.BOARD}/thread/#{g.THREAD_ID}" when '3', 'adv', 'an', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'pol', 'soc', 'sp', 'toy', 'trv', 'v', 'vp', 'x' From 39d7e45261babda7dcd6c83ba1add88607db7845 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 29 Dec 2011 02:24:36 +0100 Subject: [PATCH 10/27] Update changelog; add /r9k/ archive redirection, even though the last archived post is dated from the 5th December. --- 4chan_x.user.js | 1 + changelog | 2 +- script.coffee | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c3d47f01c..a94e50c92 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2872,6 +2872,7 @@ case 'p': case 'po': case 'pol': + case 'r9k': case 'soc': case 'sp': case 'toy': diff --git a/changelog b/changelog index 514b910c4..d9a41b46f 100644 --- a/changelog +++ b/changelog @@ -4,7 +4,7 @@ master the unread count will decrease when inlining quotes of unread posts the report button can open multiple popups again add omploader to the list of optional flavors (http://ompldr.org/upload?url1=) - update archive redirections + update archive redirections, add /lit/ and /u/ 2.23.7 - mayhem diff --git a/script.coffee b/script.coffee index 3243d802c..85ced57bb 100644 --- a/script.coffee +++ b/script.coffee @@ -2241,7 +2241,7 @@ redirect = "http://fuuka.warosu.org/#{g.BOARD}/thread/#{g.THREAD_ID}" when 'diy', 'g', 'sci' "http://archive.installgentoo.net/#{g.BOARD}/thread/#{g.THREAD_ID}" - when '3', 'adv', 'an', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'pol', 'soc', 'sp', 'toy', 'trv', 'v', 'vp', 'x' + when '3', 'adv', 'an', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'pol', 'r9k', 'soc', 'sp', 'toy', 'trv', 'v', 'vp', 'x' "http://archive.no-ip.org/#{g.BOARD}/thread/#{g.THREAD_ID}" else "http://boards.4chan.org/#{g.BOARD}" From b1256e17541ccc9ef6dfb5a95165734081a8bc76 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 29 Dec 2011 05:03:28 +0100 Subject: [PATCH 11/27] Max-width: 75% for image hover. Close #76 --- 4chan_x.user.js | 7 ++++--- changelog | 1 + script.coffee | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a94e50c92..15edaec6a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2899,7 +2899,7 @@ }, mouseover: function() { ui.el = $.el('img', { - id: 'iHover', + id: 'ihover', src: this.parentNode.href }); return $.add(d.body, ui.el); @@ -3272,12 +3272,13 @@ width: 100%;\ }\ \ - #qp, #iHover {\ + #qp, #ihover {\ position: fixed;\ }\ \ - #iHover {\ + #ihover {\ max-height: 100%;\ + max-width: 75%;\ }\ \ #navlinks {\ diff --git a/changelog b/changelog index d9a41b46f..42e956a24 100644 --- a/changelog +++ b/changelog @@ -5,6 +5,7 @@ master the report button can open multiple popups again add omploader to the list of optional flavors (http://ompldr.org/upload?url1=) update archive redirections, add /lit/ and /u/ + fit horizontally for Image Hover 2.23.7 - mayhem diff --git a/script.coffee b/script.coffee index 85ced57bb..088f71d3d 100644 --- a/script.coffee +++ b/script.coffee @@ -2255,7 +2255,7 @@ imgHover = $.on thumb, 'mouseout', ui.hoverend mouseover: -> ui.el = $.el 'img' - id: 'iHover' + id: 'ihover' src: @parentNode.href $.add d.body, ui.el @@ -2624,12 +2624,13 @@ Main = width: 100%; } - #qp, #iHover { + #qp, #ihover { position: fixed; } - #iHover { + #ihover { max-height: 100%; + max-width: 75%; } #navlinks { From 2114c86866e1b2b6f3b230a930384477e3609fef Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 30 Dec 2011 20:10:11 +0100 Subject: [PATCH 12/27] Return asap, remove braces. --- 4chan_x.user.js | 4 ++-- script.coffee | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 15edaec6a..4f3bd78a7 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2022,7 +2022,7 @@ input.disabled = true; input.value = 404; } - d.title = d.title.match(/.+-/)[0] + ' 404'; + d.title = d.title.match(/^.+-/)[0] + ' 404'; g.dead = true; Favicon.update(); return; @@ -2035,7 +2035,6 @@ This saves bandwidth for both the user and the servers, avoid unnecessary computation, and won't load images and scripts when parsing the response. */ - updater.lastModified = this.getResponseHeader('Last-Modified'); if (this.status === 304) { if (conf['Verbose']) { updater.count.textContent = '+0'; @@ -2043,6 +2042,7 @@ } return; } + updater.lastModified = this.getResponseHeader('Last-Modified'); body = $.el('body', { innerHTML: this.responseText }); diff --git a/script.coffee b/script.coffee index 088f71d3d..e0f7f2083 100644 --- a/script.coffee +++ b/script.coffee @@ -1616,8 +1616,7 @@ updater = for input in $$ '#com_submit' input.disabled = true input.value = 404 - # XXX trailing spaces are trimmed - d.title = d.title.match(/.+-/)[0] + ' 404' + d.title = d.title.match(/^.+-/)[0] + ' 404' g.dead = true Favicon.update() return @@ -1631,12 +1630,12 @@ updater = This saves bandwidth for both the user and the servers, avoid unnecessary computation, and won't load images and scripts when parsing the response. ### - updater.lastModified = @getResponseHeader('Last-Modified') if @status is 304 if conf['Verbose'] updater.count.textContent = '+0' updater.count.className = null return + updater.lastModified = @getResponseHeader 'Last-Modified' body = $.el 'body', innerHTML: @responseText From 5bda49fb7923836e2c8d95ae135df7d08bedf3ef Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 31 Dec 2011 13:32:52 -0800 Subject: [PATCH 13/27] don't expand image or inline quote if e.metaKey MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit on osx, command(⌘)+click opens links in new tabs. e.metaKey is true when command is held. --- 4chan_x.user.js | 8 ++++++-- script.coffee | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 4f3bd78a7..c01bdd971 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2457,7 +2457,9 @@ }, toggle: function(e) { var id; - if (e.shiftKey || e.altKey || e.ctrlKey || e.button !== 0) return; + if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) { + return; + } e.preventDefault(); id = this.hash.slice(1); if (/\binlined\b/.test(this.className)) { @@ -2933,7 +2935,9 @@ }, cb: { toggle: function(e) { - if (e.shiftKey || e.altKey || e.ctrlKey || e.button !== 0) return; + if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) { + return; + } e.preventDefault(); return imgExpand.toggle(this); }, diff --git a/script.coffee b/script.coffee index e0f7f2083..637ad3bd8 100644 --- a/script.coffee +++ b/script.coffee @@ -1944,7 +1944,7 @@ quoteInline = quote.removeAttribute 'onclick' $.on quote, 'click', quoteInline.toggle toggle: (e) -> - return if e.shiftKey or e.altKey or e.ctrlKey or e.button isnt 0 + return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0 e.preventDefault() id = @hash[1..] if /\binlined\b/.test @className @@ -2279,7 +2279,7 @@ imgExpand = imgExpand.expand a.firstChild cb: toggle: (e) -> - return if e.shiftKey or e.altKey or e.ctrlKey or e.button isnt 0 + return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0 e.preventDefault() imgExpand.toggle @ all: -> From ea945cc4b7a7361dad5177572b3aee53aac2b122 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 1 Jan 2012 04:19:21 +0100 Subject: [PATCH 14/27] Whoa, what? Fix mime-type acceptance. --- 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 c01bdd971..979700ab4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1497,7 +1497,7 @@ $.on($('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode); qr.captchaTime = Date.now(); qr.spoiler = $('.postarea label') ? '' : ''; - qr.acceptFiles = $('.rules').textContent.match(/: (.+) /)[1].replace(/\w+/g, function(type) { + qr.acceptFiles = $('.rules').textContent.match(/: (.+)/)[1].replace(/\w+/g, function(type) { switch (type) { case 'JPG': return 'image/JPEG'; diff --git a/script.coffee b/script.coffee index 637ad3bd8..7632d65c1 100644 --- a/script.coffee +++ b/script.coffee @@ -1123,7 +1123,7 @@ qr = qr.captchaTime = Date.now() qr.spoiler = if $('.postarea label') then '' else '' - qr.acceptFiles = $('.rules').textContent.match(/: (.+) /)[1].replace /\w+/g, (type) -> + qr.acceptFiles = $('.rules').textContent.match(/: (.+)/)[1].replace /\w+/g, (type) -> switch type when 'JPG' 'image/JPEG' From c490bc616e1e2433389e02ad9cdcecd333d933b9 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 1 Jan 2012 15:23:46 +0100 Subject: [PATCH 15/27] Keybind to open the options: ctrl+o. Close #86 --- 4chan_x.user.js | 7 ++++++- changelog | 1 + script.coffee | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 979700ab4..d8f980701 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -139,6 +139,7 @@ backlink: '>>%id', favicon: 'ferongr', hotkeys: { + openOptions: 'ctrl+o', close: 'Esc', spoiler: 'ctrl+s', openQR: 'i', @@ -893,8 +894,11 @@ if (!(key = keybinds.keyCode(e))) return; thread = nav.getThread(); switch (key) { + case conf.openOptions: + if (!$.id('overlay')) options.dialog(); + break; case conf.close: - if (o = $('#overlay')) { + if (o = $.id('overlay')) { $.rm(o); } else if (qr.el) { qr.close(); @@ -1305,6 +1309,7 @@
Keybinds are disabled.
\ \ \ + \ \ \ \ diff --git a/changelog b/changelog index 42e956a24..f3b39266d 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,7 @@ master - mayhem redirect 404'd pictures to archives when possible + new keybind to open the options: ctrl+o the unread count will decrease when inlining quotes of unread posts the report button can open multiple popups again add omploader to the list of optional flavors (http://ompldr.org/upload?url1=) diff --git a/script.coffee b/script.coffee index 7632d65c1..2175ab9c1 100644 --- a/script.coffee +++ b/script.coffee @@ -70,6 +70,7 @@ config = backlink: '>>%id' favicon: 'ferongr' hotkeys: + openOptions: 'ctrl+o' close: 'Esc' spoiler: 'ctrl+s' openQR: 'i' @@ -649,8 +650,10 @@ keybinds = thread = nav.getThread() switch key + when conf.openOptions + options.dialog() unless $.id 'overlay' when conf.close - if o = $ '#overlay' + if o = $.id 'overlay' $.rm o else if qr.el qr.close() @@ -966,6 +969,7 @@ options =
Keybinds are disabled.
ActionsKeybinds
Open Options
Close Options or QR
Quick spoiler
Open QR with post number inserted
+ From 4041419a3d1b450510658d744aa87a8ac4caa767 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 3 Jan 2012 22:46:56 +0100 Subject: [PATCH 16/27] Revert "Whoa, what? Fix mime-type acceptance." Dunno why I got it wrong while testing. This reverts commit ea945cc4b7a7361dad5177572b3aee53aac2b122. --- 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 d8f980701..393a0200e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1502,7 +1502,7 @@ $.on($('#recaptcha_challenge_field_holder'), 'DOMNodeInserted', qr.captchaNode); qr.captchaTime = Date.now(); qr.spoiler = $('.postarea label') ? '' : ''; - qr.acceptFiles = $('.rules').textContent.match(/: (.+)/)[1].replace(/\w+/g, function(type) { + qr.acceptFiles = $('.rules').textContent.match(/: (.+) /)[1].replace(/\w+/g, function(type) { switch (type) { case 'JPG': return 'image/JPEG'; diff --git a/script.coffee b/script.coffee index 2175ab9c1..72c427c9a 100644 --- a/script.coffee +++ b/script.coffee @@ -1127,7 +1127,7 @@ qr = qr.captchaTime = Date.now() qr.spoiler = if $('.postarea label') then '' else '' - qr.acceptFiles = $('.rules').textContent.match(/: (.+)/)[1].replace /\w+/g, (type) -> + qr.acceptFiles = $('.rules').textContent.match(/: (.+) /)[1].replace /\w+/g, (type) -> switch type when 'JPG' 'image/JPEG' From 58505f693dadf7d0993b7f1677f33ef8cb8f1550 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 3 Jan 2012 22:54:22 +0100 Subject: [PATCH 17/27] Set up archived image redirection link. --- 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 393a0200e..ebb3db410 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2846,7 +2846,7 @@ case 'tg': case 'tv': case 'u': - return "http://archivethumb.foolz.us/board/" + board + "/img/" + filename; + return "http://archive.foolz.us/" + board + "/full_image/" + filename; } }, thread: function() { diff --git a/script.coffee b/script.coffee index 72c427c9a..46c5afbf9 100644 --- a/script.coffee +++ b/script.coffee @@ -2235,7 +2235,7 @@ redirect = image: (board, filename) -> #board must be given, the image can originate from a cross-quote switch board when 'a', 'jp', 'm', 'tg', 'tv', 'u' - "http://archivethumb.foolz.us/board/#{board}/img/#{filename}" + "http://archive.foolz.us/#{board}/full_image/#{filename}" thread: -> switch g.BOARD when 'a', 'jp', 'm', 'tg', 'tv', 'u' From ed1184c9a1e5656d28c56bc8f10c380d96f2d102 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 3 Jan 2012 22:57:43 +0100 Subject: [PATCH 18/27] Release 2.24.0. --- 4chan_x.user.js | 6 +++--- Cakefile | 2 +- changelog | 2 ++ latest.js | 2 +- script.coffee | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ebb3db410..0406f56bd 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan x -// @version 2.23.7 +// @version 2.24.0 // @namespace aeosynth // @description Adds various features. // @copyright 2009-2011 James Campos @@ -17,7 +17,7 @@ * * Copyright (c) 2009-2011 James Campos * http://mayhemydg.github.com/4chan-x/ - * 4chan X 2.23.7 + * 4chan X 2.24.0 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -199,7 +199,7 @@ NAMESPACE = '4chan_x.'; - VERSION = '2.23.7'; + VERSION = '2.24.0'; SECOND = 1000; diff --git a/Cakefile b/Cakefile index 195cbb959..ec093746a 100644 --- a/Cakefile +++ b/Cakefile @@ -2,7 +2,7 @@ {exec} = require 'child_process' fs = require 'fs' -VERSION = '2.23.7' +VERSION = '2.24.0' HEADER = """ // ==UserScript== diff --git a/changelog b/changelog index f3b39266d..f4c9d5f14 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master + +2.24.0 - mayhem redirect 404'd pictures to archives when possible new keybind to open the options: ctrl+o diff --git a/latest.js b/latest.js index 37736fe93..7a8079fdf 100644 --- a/latest.js +++ b/latest.js @@ -1 +1 @@ -postMessage({version:'2.23.7'},'*'); +postMessage({version:'2.24.0'},'*'); diff --git a/script.coffee b/script.coffee index 46c5afbf9..42609e1f0 100644 --- a/script.coffee +++ b/script.coffee @@ -121,7 +121,7 @@ conf = {} ) null, config NAMESPACE = '4chan_x.' -VERSION = '2.23.7' +VERSION = '2.24.0' SECOND = 1000 MINUTE = 60*SECOND HOUR = 60*MINUTE From 2196ea2c73b8f63115ab15a069c725170d41f2bf Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 4 Jan 2012 14:31:06 +0100 Subject: [PATCH 19/27] Faster selector --- 4chan_x.user.js | 10 +++++----- script.coffee | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 0406f56bd..a7e807ccf 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3067,7 +3067,7 @@ return $.prepend(form, controls); }, resize: function() { - return imgExpand.style.innerHTML = ".fitheight [md5] + img {max-height:" + d.body.clientHeight + "px;}"; + return imgExpand.style.innerHTML = ".fitheight img[md5] + img {max-height:" + d.body.clientHeight + "px;}"; } }; @@ -3270,14 +3270,14 @@ float: left;\ pointer-events: none;\ }\ - [md5], [md5] + img {\ + img[md5], img[md5] + img {\ pointer-events: all;\ }\ - .fitwidth [md5] + img {\ + .fitwidth img[md5] + img {\ max-width: 100%;\ }\ - .gecko > .fitwidth [md5] + img,\ - .presto > .fitwidth [md5] + img {\ + .gecko > .fitwidth img[md5] + img,\ + .presto > .fitwidth img[md5] + img {\ width: 100%;\ }\ \ diff --git a/script.coffee b/script.coffee index 42609e1f0..1198ee3bc 100644 --- a/script.coffee +++ b/script.coffee @@ -2375,7 +2375,7 @@ imgExpand = $.prepend form, controls resize: -> - imgExpand.style.innerHTML = ".fitheight [md5] + img {max-height:#{d.body.clientHeight}px;}" + imgExpand.style.innerHTML = ".fitheight img[md5] + img {max-height:#{d.body.clientHeight}px;}" Main = init: -> @@ -2616,14 +2616,14 @@ Main = float: left; pointer-events: none; } - [md5], [md5] + img { + img[md5], img[md5] + img { pointer-events: all; } - .fitwidth [md5] + img { + .fitwidth img[md5] + img { max-width: 100%; } - .gecko > .fitwidth [md5] + img, - .presto > .fitwidth [md5] + img { + .gecko > .fitwidth img[md5] + img, + .presto > .fitwidth img[md5] + img { width: 100%; } From b80c700c4a8d36ac9ab3652ed72a1d46b1ab759b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 4 Jan 2012 14:46:38 +0100 Subject: [PATCH 20/27] Update copyright holders. Close #92 --- 4chan_x.user.js | 1 + Cakefile | 1 + 2 files changed, 2 insertions(+) diff --git a/4chan_x.user.js b/4chan_x.user.js index a7e807ccf..d2df80453 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -16,6 +16,7 @@ /* LICENSE * * Copyright (c) 2009-2011 James Campos + * Copyright (c) 2012 Nicolas Stepien * http://mayhemydg.github.com/4chan-x/ * 4chan X 2.24.0 * diff --git a/Cakefile b/Cakefile index ec093746a..2415c87b1 100644 --- a/Cakefile +++ b/Cakefile @@ -23,6 +23,7 @@ HEADER = """ /* LICENSE * * Copyright (c) 2009-2011 James Campos + * Copyright (c) 2012 Nicolas Stepien * http://mayhemydg.github.com/4chan-x/ * 4chan X #{VERSION} * From 726335775c0fdc50b796dd499c03549829022ff0 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 4 Jan 2012 15:55:55 +0100 Subject: [PATCH 21/27] $.onLoad --- 4chan_x.user.js | 34 ++++++++++++++-------------------- script.coffee | 26 ++++++++++---------------- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d2df80453..02c1a285e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -307,6 +307,15 @@ }; $.extend($, { + onLoad: function(fc) { + var cb; + if (/interactive|complete/.test(d.readyState)) return fc(); + cb = function() { + $.off(d, 'DOMContentLoaded', cb); + return fc(); + }; + return $.on(d, 'DOMContentLoaded', cb); + }, id: function(id) { return d.getElementById(id); }, @@ -3074,7 +3083,7 @@ Main = { init: function() { - var cutoff, hiddenThreads, id, now, pathname, temp, timestamp, update, _ref; + var cutoff, hiddenThreads, id, now, pathname, temp, timestamp, _ref; pathname = location.pathname.slice(1).split('/'); g.BOARD = pathname[0], temp = pathname[1]; if (temp === 'res') { @@ -3084,27 +3093,17 @@ g.PAGENUM = parseInt(temp) || 0; } if (location.hostname === 'sys.4chan.org') { - if (/interactive|complete/.test(d.readyState)) { - qr.sys(); - } else { - $.on(d, 'DOMContentLoaded', qr.sys); - } + $.onLoad(qr.sys); return; } $.on(window, 'message', Main.message); now = Date.now(); if (conf['Check for Updates'] && $.get('lastUpdate', 0) < now - 6 * HOUR) { - update = function() { - $.off(d, 'DOMContentLoaded', update); + $.onLoad(function() { return $.add(d.head, $.el('script', { src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js' })); - }; - if (/interactive|complete/.test(d.readyState)) { - update(); - } else { - $.on(d, 'DOMContentLoaded', update); - } + }); $.set('lastUpdate', now); } g.hiddenReplies = $.get("hiddenReplies/" + g.BOARD + "/", {}); @@ -3138,15 +3137,10 @@ if (conf['Quote Backlinks']) quoteBacklink.init(); if (conf['Indicate OP quote']) quoteOP.init(); if (conf['Indicate Cross-thread Quotes']) quoteDR.init(); - if (/interactive|complete/.test(d.readyState)) { - return Main.onLoad(); - } else { - return $.on(d, 'DOMContentLoaded', Main.onLoad); - } + return $.onLoad(Main.onLoad); }, onLoad: function() { var callback, canPost, form, node, nodes, _i, _j, _len, _len2, _ref; - $.off(d, 'DOMContentLoaded', Main.onLoad); if (conf['404 Redirect'] && d.title === '4chan - 404') { redirect.init(); return; diff --git a/script.coffee b/script.coffee index 1198ee3bc..18951790e 100644 --- a/script.coffee +++ b/script.coffee @@ -221,6 +221,13 @@ $.extend = (object, properties) -> object $.extend $, + onLoad: (fc) -> + if /interactive|complete/.test d.readyState + return fc() + cb = -> + $.off d, 'DOMContentLoaded', cb + fc() + $.on d, 'DOMContentLoaded', cb id: (id) -> d.getElementById id globalEval: (code) -> @@ -2388,23 +2395,14 @@ Main = g.PAGENUM = parseInt(temp) or 0 if location.hostname is 'sys.4chan.org' - if /interactive|complete/.test d.readyState - qr.sys() - else - $.on d, 'DOMContentLoaded', qr.sys + $.onLoad qr.sys return $.on window, 'message', Main.message now = Date.now() if conf['Check for Updates'] and $.get('lastUpdate', 0) < now - 6*HOUR - update = -> - $.off d, 'DOMContentLoaded', update - $.add d.head, $.el 'script', src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js' - if /interactive|complete/.test d.readyState - update() - else - $.on d, 'DOMContentLoaded', update + $.onLoad -> $.add d.head, $.el 'script', src: 'https://raw.github.com/mayhemydg/4chan-x/master/latest.js' $.set 'lastUpdate', now g.hiddenReplies = $.get "hiddenReplies/#{g.BOARD}/", {} @@ -2470,13 +2468,9 @@ Main = quoteDR.init() - if /interactive|complete/.test d.readyState - Main.onLoad() - else - $.on d, 'DOMContentLoaded', Main.onLoad + $.onLoad Main.onLoad onLoad: -> - $.off d, 'DOMContentLoaded', Main.onLoad if conf['404 Redirect'] and d.title is '4chan - 404' redirect.init() return From 5452d7f46ba6ce8e4e8cb5711fce1167a45bc4a2 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 4 Jan 2012 16:07:13 +0100 Subject: [PATCH 22/27] Make sure to initialize the options UI, in case something goes wrong let the user change his settings. --- 4chan_x.user.js | 4 ++-- script.coffee | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 02c1a285e..4eb7c8201 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3096,6 +3096,7 @@ $.onLoad(qr.sys); return; } + $.onLoad(options.init); $.on(window, 'message', Main.message); now = Date.now(); if (conf['Check for Updates'] && $.get('lastUpdate', 0) < now - 6 * HOUR) { @@ -3195,8 +3196,7 @@ alert(err); } } - $.on($('form[name=delform]'), 'DOMNodeInserted', Main.node); - return options.init(); + return $.on($('form[name=delform]'), 'DOMNodeInserted', Main.node); }, message: function(e) { var data, origin; diff --git a/script.coffee b/script.coffee index 18951790e..c856e5624 100644 --- a/script.coffee +++ b/script.coffee @@ -2398,6 +2398,8 @@ Main = $.onLoad qr.sys return + $.onLoad options.init + $.on window, 'message', Main.message now = Date.now() @@ -2550,7 +2552,6 @@ Main = catch err alert err $.on $('form[name=delform]'), 'DOMNodeInserted', Main.node - options.init() message: (e) -> {origin, data} = e From b877f47b00ba3f615dd77b9cb00f2a71defa0b44 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 4 Jan 2012 16:24:04 +0100 Subject: [PATCH 23/27] Return ASAP in images.4chan.org --- 4chan_x.user.js | 10 +++++++++- script.coffee | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 4eb7c8201..fb3ea94ff 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3096,6 +3096,14 @@ $.onLoad(qr.sys); return; } + if (location.hostname === 'images.4chan.org') { + if (conf['404 Redirect']) { + $.onLoad(function() { + if (d.title === '4chan - 404') return redirect.init(); + }); + } + return; + } $.onLoad(options.init); $.on(window, 'message', Main.message); now = Date.now(); @@ -3146,7 +3154,7 @@ redirect.init(); return; } - if (!$('#navtopr') || location.hostname === 'images.4chan.org') return; + if (!$.id('navtopr')) return; $.addClass(d.body, engine); $.addStyle(Main.css); threading.init(); diff --git a/script.coffee b/script.coffee index c856e5624..2077d3f36 100644 --- a/script.coffee +++ b/script.coffee @@ -2397,6 +2397,10 @@ Main = if location.hostname is 'sys.4chan.org' $.onLoad qr.sys return + if location.hostname is 'images.4chan.org' + if conf['404 Redirect'] + $.onLoad -> redirect.init() if d.title is '4chan - 404' + return $.onLoad options.init @@ -2476,7 +2480,7 @@ Main = if conf['404 Redirect'] and d.title is '4chan - 404' redirect.init() return - if not $('#navtopr') or location.hostname is 'images.4chan.org' + if not $.id 'navtopr' return $.addClass d.body, engine $.addStyle Main.css From a3933212e42c72c1a7835784e9cb47b9928a23ef Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 4 Jan 2012 16:29:10 +0100 Subject: [PATCH 24/27] Some getElementById instead of querySelector. --- 4chan_x.user.js | 6 +++--- script.coffee | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index fb3ea94ff..ab88a68d5 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1442,10 +1442,10 @@ time: function() { Time.foo(); Time.date = new Date(); - return $('#timePreview').textContent = Time.funk(Time); + return $.id('timePreview').textContent = Time.funk(Time); }, backlink: function() { - return $('#backlinkPreview').textContent = conf['backlink'].replace(/%id/, '123456789'); + return $.id('backlinkPreview').textContent = conf['backlink'].replace(/%id/, '123456789'); }, favicon: function() { Favicon["switch"](); @@ -3159,7 +3159,7 @@ $.addStyle(Main.css); threading.init(); Favicon.init(); - if ((form = $('form[name=post]')) && (canPost = !!$('#recaptcha_response_field'))) { + if ((form = $('form[name=post]')) && (canPost = !!$.id('recaptcha_response_field'))) { Recaptcha.init(); if (g.REPLY && conf['Auto Watch Reply'] && conf['Thread Watcher']) { $.on(form, 'submit', function() { diff --git a/script.coffee b/script.coffee index 2077d3f36..b95954c9c 100644 --- a/script.coffee +++ b/script.coffee @@ -1084,9 +1084,9 @@ options = time: -> Time.foo() Time.date = new Date() - $('#timePreview').textContent = Time.funk Time + $.id('timePreview').textContent = Time.funk Time backlink: -> - $('#backlinkPreview').textContent = conf['backlink'].replace /%id/, '123456789' + $.id('backlinkPreview').textContent = conf['backlink'].replace /%id/, '123456789' favicon: -> Favicon.switch() Favicon.update() if g.REPLY and conf['Unread Count'] @@ -2488,7 +2488,7 @@ Main = Favicon.init() #recaptcha may be blocked, eg by noscript - if (form = $ 'form[name=post]') and (canPost = !!$ '#recaptcha_response_field') + if (form = $ 'form[name=post]') and (canPost = !!$.id 'recaptcha_response_field') Recaptcha.init() if g.REPLY and conf['Auto Watch Reply'] and conf['Thread Watcher'] $.on form, 'submit', -> if $('img.favicon').src is Favicon.empty From 7e02db3b9b4960ef70ab29381a82fd287bafd387 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 4 Jan 2012 18:24:39 +0100 Subject: [PATCH 25/27] Revert "Single nav.init()." This reverts commit eb8daa7b43eed20318b58370969bd75a0a53b380. --- 4chan_x.user.js | 3 ++- script.coffee | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ab88a68d5..9f333442a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3176,10 +3176,10 @@ if (conf['Quick Reply']) qr.init(); if (conf['Thread Watcher']) watcher.init(); if (conf['Keybinds']) keybinds.init(); - if (conf['Reply Navigation'] || conf['Index Navigation']) nav.init(); if (g.REPLY) { if (conf['Thread Updater']) updater.init(); if (conf['Thread Stats']) threadStats.init(); + if (conf['Reply Navigation']) nav.init(); if (conf['Post in Title']) titlePost.init(); if (conf['Unread Count']) unread.init(); if (conf['Quick Reply'] && conf['Persistent QR'] && canPost) { @@ -3190,6 +3190,7 @@ if (conf['Thread Hiding']) threadHiding.init(); if (conf['Thread Expansion']) expandThread.init(); if (conf['Comment Expansion']) expandComment.init(); + if (conf['Index Navigation']) nav.init(); } nodes = $$('.op, a + table'); _ref = g.callbacks; diff --git a/script.coffee b/script.coffee index b95954c9c..ae407abb2 100644 --- a/script.coffee +++ b/script.coffee @@ -2516,9 +2516,6 @@ Main = if conf['Keybinds'] keybinds.init() - if conf['Reply Navigation'] or conf['Index Navigation'] - nav.init() - if g.REPLY if conf['Thread Updater'] updater.init() @@ -2526,6 +2523,9 @@ Main = if conf['Thread Stats'] threadStats.init() + if conf['Reply Navigation'] + nav.init() + if conf['Post in Title'] titlePost.init() @@ -2547,6 +2547,9 @@ Main = if conf['Comment Expansion'] expandComment.init() + if conf['Index Navigation'] + nav.init() + nodes = $$ '.op, a + table' for callback in g.callbacks From f94a1c87368fb5c1775a550174e7bb9ee188e72f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 4 Jan 2012 21:49:11 +0100 Subject: [PATCH 26/27] Fix Open thread in new tab for Safari. Close #78 --- 4chan_x.user.js | 11 +++-------- changelog | 3 +++ script.coffee | 7 ++----- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 9f333442a..1e3f2c462 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -490,9 +490,6 @@ return defaultValue; } }, - openInTab: function(url) { - return GM_openInTab(url); - }, set: function(name, value) { name = NAMESPACE + name; localStorage[name] = JSON.stringify(value); @@ -514,9 +511,6 @@ return defaultValue; } }, - openInTab: function(url) { - return window.open(url, "_blank"); - }, set: function(name, value) { name = NAMESPACE + name; return localStorage[name] = JSON.stringify(value); @@ -1083,11 +1077,12 @@ } }, open: function(thread, tab) { - var id, url; + var id, open, url; id = thread.firstChild.id; url = "http://boards.4chan.org/" + g.BOARD + "/res/" + id; if (tab) { - return $.openInTab(url); + open = GM_openInTab || window.open; + return open(url, "_blank"); } else { return location.href = url; } diff --git a/changelog b/changelog index f4c9d5f14..ff9c68ea2 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,7 @@ master +- mayhem + fix Open thread in new tab keybind for Safari with Ninjakit + fix Index/Reply Navigation working in both cases when only one is enabled 2.24.0 - mayhem diff --git a/script.coffee b/script.coffee index ae407abb2..2b95d9565 100644 --- a/script.coffee +++ b/script.coffee @@ -369,8 +369,6 @@ if GM_deleteValue? JSON.parse value else defaultValue - openInTab: (url) -> - GM_openInTab url set: (name, value) -> name = NAMESPACE + name # for `storage` events @@ -387,8 +385,6 @@ else JSON.parse value else defaultValue - openInTab: (url) -> - window.open url, "_blank" set: (name, value) -> name = NAMESPACE + name localStorage[name] = JSON.stringify value @@ -770,7 +766,8 @@ keybinds = id = thread.firstChild.id url = "http://boards.4chan.org/#{g.BOARD}/res/#{id}" if tab - $.openInTab url + open = GM_openInTab or window.open + open url, "_blank" else location.href = url From 2390251e5991ec8f60bc69c47a57b9878e8dc9ea Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 4 Jan 2012 22:12:46 +0100 Subject: [PATCH 27/27] Shave a line, don't repeat $.extend. --- 4chan_x.user.js | 76 +++++++++++++++++++++++-------------------------- script.coffee | 7 ++--- 2 files changed, 39 insertions(+), 44 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1e3f2c462..87e1c61d0 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -475,48 +475,44 @@ $.cache.requests = {}; - if (typeof GM_deleteValue !== "undefined" && GM_deleteValue !== null) { - $.extend($, { - "delete": function(name) { - name = NAMESPACE + name; - return GM_deleteValue(name); - }, - get: function(name, defaultValue) { - var value; - name = NAMESPACE + name; - if (value = GM_getValue(name)) { - return JSON.parse(value); - } else { - return defaultValue; - } - }, - set: function(name, value) { - name = NAMESPACE + name; - localStorage[name] = JSON.stringify(value); - return GM_setValue(name, JSON.stringify(value)); + $.extend($, typeof GM_deleteValue !== "undefined" && GM_deleteValue !== null ? { + "delete": function(name) { + name = NAMESPACE + name; + return GM_deleteValue(name); + }, + get: function(name, defaultValue) { + var value; + name = NAMESPACE + name; + if (value = GM_getValue(name)) { + return JSON.parse(value); + } else { + return defaultValue; } - }); - } else { - $.extend($, { - "delete": function(name) { - name = NAMESPACE + name; - return delete localStorage[name]; - }, - get: function(name, defaultValue) { - var value; - name = NAMESPACE + name; - if (value = localStorage[name]) { - return JSON.parse(value); - } else { - return defaultValue; - } - }, - set: function(name, value) { - name = NAMESPACE + name; - return localStorage[name] = JSON.stringify(value); + }, + set: function(name, value) { + name = NAMESPACE + name; + localStorage[name] = JSON.stringify(value); + return GM_setValue(name, JSON.stringify(value)); + } + } : { + "delete": function(name) { + name = NAMESPACE + name; + return delete localStorage[name]; + }, + get: function(name, defaultValue) { + var value; + name = NAMESPACE + name; + if (value = localStorage[name]) { + return JSON.parse(value); + } else { + return defaultValue; } - }); - } + }, + set: function(name, value) { + name = NAMESPACE + name; + return localStorage[name] = JSON.stringify(value); + } + }); for (key in conf) { val = conf[key]; diff --git a/script.coffee b/script.coffee index 2b95d9565..00c31dfa7 100644 --- a/script.coffee +++ b/script.coffee @@ -358,8 +358,8 @@ $.extend $, $.cache.requests = {} -if GM_deleteValue? - $.extend $, +$.extend $, + if GM_deleteValue? delete: (name) -> name = NAMESPACE + name GM_deleteValue name @@ -374,8 +374,7 @@ if GM_deleteValue? # for `storage` events localStorage[name] = JSON.stringify value GM_setValue name, JSON.stringify value -else - $.extend $, + else delete: (name) -> name = NAMESPACE + name delete localStorage[name]
ActionsKeybinds
Open Options
Close Options or QR
Quick spoiler
Open QR with post number inserted