diff --git a/4chan_x.user.js b/4chan_x.user.js index 3623f8d83..1bda89a86 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan x -// @version 2.29.3 +// @version 2.29.4 // @namespace aeosynth // @description Adds various features. // @copyright 2009-2011 James Campos @@ -19,7 +19,7 @@ * Copyright (c) 2009-2011 James Campos * Copyright (c) 2012 Nicolas Stepien * http://mayhemydg.github.com/4chan-x/ - * 4chan X 2.29.3 + * 4chan X 2.29.4 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -825,36 +825,30 @@ ExpandThread = { init: function() { var a, span, _i, _len, _ref, _results; - _ref = $$('.omittedposts'); + _ref = $$('.summary'); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { span = _ref[_i]; a = $.el('a', { textContent: "+ " + span.textContent, - className: 'omittedposts', + className: 'summary desktop', href: 'javascript:;' }); - $.on(a, 'click', ExpandThread.cb.toggle); + $.on(a, 'click', function() { + return ExpandThread.toggle(this.parentNode); + }); _results.push($.replace(span, a)); } return _results; }, - cb: { - toggle: function() { - var thread; - thread = this.parentNode; - return ExpandThread.toggle(thread); - } - }, toggle: function(thread) { - var a, backlink, num, pathname, prev, table, threadID, _i, _len, _ref, _ref1, _results; - threadID = thread.firstChild.id; - pathname = "/" + g.BOARD + "/res/" + threadID; - a = $('.omittedposts', thread); + var a, backlink, container, div, next, num, pathname, _i, _len, _ref, _results; + pathname = "/" + g.BOARD + "/res/" + thread.id.slice(1); + a = $('.summary', thread); switch (a.textContent[0]) { case '+': - if ((_ref = $('.op .container', thread)) != null) { - _ref.textContent = ''; + if (container = $('.container', thread.firstElementChild)) { + $.rm(container); } a.textContent = a.textContent.replace('+', '\u00d7 Loading...'); return $.cache(pathname, (function() { @@ -876,14 +870,14 @@ return 5; } })(); - table = $.x("following::br[@clear]/preceding::table[" + num + "]", a); - while ((prev = table.previousSibling) && (prev.nodeName !== 'A')) { - $.rm(prev); + div = $.x("following-sibling::div[last()]/preceding-sibling::div[" + (num - 1) + "]", a); + while ((next = a.nextSibling) && next !== div) { + $.rm(next); } - _ref1 = $$('.backlink', $('.op', thread)); + _ref = $$('.backlink', a.previousElementSibling); _results = []; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - backlink = _ref1[_i]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + backlink = _ref[_i]; if (!$.id(backlink.hash.slice(1))) { _results.push($.rm(backlink)); } else { @@ -894,7 +888,7 @@ } }, parse: function(req, pathname, thread, a) { - var doc, href, link, next, nodes, quote, reply, table, _i, _j, _len, _len1, _ref, _ref1; + var doc, href, id, link, next, nodes, quote, reply, threadID, _i, _j, _len, _len1, _ref, _ref1; if (req.status !== 200) { a.textContent = "" + req.status + " " + req.statusText; $.off(a, 'click', ExpandThread.cb.toggle); @@ -903,29 +897,32 @@ a.textContent = a.textContent.replace('\u00d7 Loading...', '-'); doc = d.implementation.createHTMLDocument(''); doc.documentElement.innerHTML = req.response; + threadID = thread.id.slice(1); nodes = []; - _ref = $$('.reply', doc); + _ref = $$('.replyContainer', doc); for (_i = 0, _len = _ref.length; _i < _len; _i++) { reply = _ref[_i]; - table = d.importNode(reply.parentNode.parentNode.parentNode); - _ref1 = $$('.quotelink', table); + reply = d.importNode(reply); + _ref1 = $$('.quotelink', reply); for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { quote = _ref1[_j]; - if (quote.hash === (href = quote.getAttribute('href'))) { + href = quote.getAttribute('href'); + if (quote.hash === href) { quote.pathname = pathname; } else if (href !== quote.href) { quote.href = "res/" + href; } } - link = $('.quotejs', table); - link.href = "res/" + thread.firstChild.id + "#" + reply.id; - link.nextSibling.href = "res/" + thread.firstChild.id + "#q" + reply.id; - nodes.push(table); + id = reply.firstElementChild.id.slice(2); + link = $('.postNum.desktop', reply).firstElementChild; + link.href = "res/" + threadID + "#p" + id; + link.nextSibling.href = "res/" + threadID + "#q" + id; + nodes.push(reply); } - while ((next = a.nextSibling) && !next.clear) { + while (next = a.nextSibling) { $.rm(next); } - return $.before(next, nodes); + return $.after(a, nodes); } }; @@ -4206,7 +4203,7 @@ } }, namespace: '4chan_x.', - version: '2.29.3', + version: '2.29.4', callbacks: [], css: '\ /* dialog styling */\ diff --git a/Cakefile b/Cakefile index 1a84dda37..42e212fe7 100644 --- a/Cakefile +++ b/Cakefile @@ -2,7 +2,7 @@ {exec} = require 'child_process' fs = require 'fs' -VERSION = '2.29.3' +VERSION = '2.29.4' HEADER = """ // ==UserScript== diff --git a/changelog b/changelog index f8413bbd0..11067256f 100644 --- a/changelog +++ b/changelog @@ -1,6 +1,9 @@ master + +2.29.4 - Mayhem Auto-GIF will not run in /gif/. + Fix QR filetype checking. 2.29.3 - Mayhem diff --git a/latest.js b/latest.js index 1dda30899..a287f3eca 100644 --- a/latest.js +++ b/latest.js @@ -1 +1 @@ -postMessage({version:'2.29.3'},'*') \ No newline at end of file +postMessage({version:'2.29.4'},'*') \ No newline at end of file diff --git a/script.coffee b/script.coffee index 2d8f49d5d..6cf60faa3 100644 --- a/script.coffee +++ b/script.coffee @@ -550,7 +550,7 @@ Filter = name: (post) -> $('.name', post.el).textContent or false uniqueid: (post) -> - # NEW FORMAT ??? + # NEW HTML ??? if uid = $ '.posteruid', post.el return uid.textContent false @@ -656,29 +656,24 @@ ExpandComment = ExpandThread = init: -> - for span in $$ '.omittedposts' + for span in $$ '.summary' a = $.el 'a', textContent: "+ #{span.textContent}" - className: 'omittedposts' + className: 'summary desktop' href: 'javascript:;' - $.on a, 'click', ExpandThread.cb.toggle + $.on a, 'click', -> ExpandThread.toggle @parentNode $.replace span, a - cb: - toggle: -> - thread = @parentNode - ExpandThread.toggle thread - toggle: (thread) -> - threadID = thread.firstChild.id - pathname = "/#{g.BOARD}/res/#{threadID}" - a = $ '.omittedposts', thread + pathname = "/#{g.BOARD}/res/#{thread.id[1..]}" + a = $ '.summary', thread # \u00d7 is × switch a.textContent[0] when '+' - $('.op .container', thread)?.textContent = '' + if container = $ '.container', thread.firstElementChild + $.rm container a.textContent = a.textContent.replace '+', '\u00d7 Loading...' $.cache pathname, (-> ExpandThread.parse @, pathname, thread, a) @@ -693,11 +688,11 @@ ExpandThread = when 'b', 'vg' then 3 when 't' then 1 else 5 - table = $.x "following::br[@clear]/preceding::table[#{num}]", a - while (prev = table.previousSibling) and (prev.nodeName isnt 'A') - $.rm prev - for backlink in $$ '.backlink', $ '.op', thread - $.rm backlink if !$.id backlink.hash[1..] + div = $.x "following-sibling::div[last()]/preceding-sibling::div[#{num - 1}]", a + while (next = a.nextSibling) and next isnt div + $.rm next + for backlink in $$ '.backlink', a.previousElementSibling + $.rm backlink unless $.id backlink.hash[1..] parse: (req, pathname, thread, a) -> @@ -711,22 +706,28 @@ ExpandThread = doc = d.implementation.createHTMLDocument '' doc.documentElement.innerHTML = req.response - nodes = [] - for reply in $$ '.reply', doc - table = d.importNode reply.parentNode.parentNode.parentNode - for quote in $$ '.quotelink', table - if quote.hash is href = quote.getAttribute 'href' # Add pathname to in-thread quotes + threadID = thread.id[1..] + nodes = [] + for reply in $$ '.replyContainer', doc + reply = d.importNode reply + for quote in $$ '.quotelink', reply + href = quote.getAttribute 'href' + if quote.hash is href # Add pathname to in-thread quotes quote.pathname = pathname + # NEW HTML ??? + # OP quotes have different href attribute than normal quotes. + # Waiting for a reply from moot. 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}" - link.nextSibling.href = "res/#{thread.firstChild.id}#q#{reply.id}" - nodes.push table + id = reply.firstElementChild.id[2..] + link = $('.postNum.desktop', reply).firstElementChild + link.href = "res/#{threadID}#p#{id}" + link.nextSibling.href = "res/#{threadID}#q#{id}" + nodes.push reply # eat everything, then replace with fresh full posts - while (next = a.nextSibling) and not next.clear #br[clear] + while next = a.nextSibling $.rm next - $.before next, nodes + $.after a, nodes ReplyHiding = init: -> @@ -3220,7 +3221,7 @@ Main = Main.node [Main.preParse target] namespace: '4chan_x.' - version: '2.29.3' + version: '2.29.4' callbacks: [] css: ' /* dialog styling */