diff --git a/4chan_x.user.js b/4chan_x.user.js index 1d18f2678..1f5ff756a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -61,7 +61,7 @@ */ (function() { - var $, $$, DAY, Favicon, HOUR, MINUTE, Main, NAMESPACE, QR, SECOND, Time, anonymize, conf, config, d, expandComment, expandThread, filter, firstRun, flatten, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, nav, options, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher; + var $, $$, DAY, Favicon, HOUR, MINUTE, Main, NAMESPACE, QR, SECOND, Time, anonymize, conf, config, d, expandComment, expandThread, filter, firstRun, flatten, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, nav, options, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, strikethroughQuotes, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher; var __slice = Array.prototype.slice; config = { main: { @@ -586,6 +586,23 @@ } } }; + strikethroughQuotes = { + init: function() { + return g.callbacks.push(function(root) { + var el, quote, _i, _len, _ref, _results; + if (root.className === 'inline') { + return; + } + _ref = $$('.quotelink', root); + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + quote = _ref[_i]; + _results.push((el = $.id(quote.hash.slice(1))) ? el.parentNode.parentNode.parentNode.hidden ? $.addClass(quote, 'filtered') : void 0 : void 0); + } + return _results; + }); + } + }; expandComment = { init: function() { var a, _i, _len, _ref, _results; @@ -791,9 +808,14 @@ } }, hide: function(reply) { - var id; + var id, quote, _i, _len, _ref; replyHiding.hideHide(reply); id = reply.id; + _ref = $$(".quotelink[href='#" + id + "'], .backlink[href='#" + id + "']"); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + quote = _ref[_i]; + $.addClass(quote, 'filtered'); + } g.hiddenReplies[id] = Date.now(); return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies); }, @@ -816,9 +838,14 @@ } }, show: function(table) { - var id; + var id, quote, _i, _len, _ref; table.hidden = false; id = $('td[id]', table).id; + _ref = $$(".quotelink[href='#" + id + "'], .backlink[href='#" + id + "']"); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + quote = _ref[_i]; + $.removeClass(quote, 'filtered'); + } delete g.hiddenReplies[id]; return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies); } @@ -2330,7 +2357,7 @@ } link = $.el('a', { href: "#" + id, - className: 'backlink', + className: root.hidden ? 'filtered backlink' : 'backlink', textContent: quoteBacklink.funk(id) }); if (conf['Quote Preview']) { @@ -2414,16 +2441,15 @@ } }, rm: function(q, id) { - var hidden, inlined, table, _i, _len, _ref; + var inlined, table, _i, _len, _ref; table = $.x("following::*[@id='i" + id + "']", q); - _ref = $$('input', table); + _ref = $$('.backlink.inlined:not(.filtered)', table); for (_i = 0, _len = _ref.length; _i < _len; _i++) { inlined = _ref[_i]; - if (hidden = $.id(inlined.name)) { - if (!hidden.classList.contains('op')) { - $.x('ancestor::table[1]', hidden).hidden = false; - } - } + $.x('ancestor::table[1]', $.id(inlined.hash.slice(1))).hidden = false; + } + if (!q.classList.contains('filtered')) { + $.x('ancestor::table[1]', $.id(id)).hidden = false; } return $.rm(table); }, @@ -3036,6 +3062,9 @@ if (conf['Reply Hiding']) { replyHiding.init(); } + if (conf['Filter'] || conf['Reply Hiding']) { + strikethroughQuotes.init(); + } if (conf['Anonymize']) { anonymize.init(); } @@ -3324,6 +3353,9 @@ .filetitle, .replytitle, .postername, .commentpostername, .postertrip {\ background: none;\ }\ + .filtered {\ + text-decoration: line-through;\ + }\ \ /* Firefox bug: hidden tables are not hidden. fixed in 9.0 */\ [hidden] {\ diff --git a/script.coffee b/script.coffee index 65817bfa1..eec3c543e 100644 --- a/script.coffee +++ b/script.coffee @@ -425,6 +425,15 @@ filter = if img = $ 'img[md5]', root filter.test 'md5', img.getAttribute('md5') +strikethroughQuotes = + init: -> + g.callbacks.push (root) -> + return if root.className is 'inline' + for quote in $$ '.quotelink', root + if el = $.id quote.hash[1..] + if el.parentNode.parentNode.parentNode.hidden + $.addClass quote, 'filtered' + expandComment = init: -> for a in $$ '.abbr a' @@ -571,6 +580,9 @@ replyHiding = replyHiding.hideHide reply id = reply.id + for quote in $$ ".quotelink[href='##{id}'], .backlink[href='##{id}']" + $.addClass quote, 'filtered' + g.hiddenReplies[id] = Date.now() $.set "hiddenReplies/#{g.BOARD}/", g.hiddenReplies @@ -594,6 +606,9 @@ replyHiding = table.hidden = false id = $('td[id]', table).id + for quote in $$ ".quotelink[href='##{id}'], .backlink[href='##{id}']" + $.removeClass quote, 'filtered' + delete g.hiddenReplies[id] $.set "hiddenReplies/#{g.BOARD}/", g.hiddenReplies @@ -1762,7 +1777,7 @@ quoteBacklink = continue if !conf['OP Backlinks'] and el.className is 'op' link = $.el 'a', href: "##{id}" - className: 'backlink' + className: if root.hidden then 'filtered backlink' else 'backlink' textContent: quoteBacklink.funk id if conf['Quote Preview'] $.bind link, 'mouseover', quotePreview.mouseover @@ -1816,10 +1831,10 @@ quoteInline = rm: (q, id) -> #select the corresponding table or loading td table = $.x "following::*[@id='i#{id}']", q - for inlined in $$ 'input', table - if hidden = $.id inlined.name - unless hidden.classList.contains 'op' - $.x('ancestor::table[1]', hidden).hidden = false + for inlined in $$ '.backlink.inlined:not(.filtered)', table + $.x('ancestor::table[1]', $.id inlined.hash[1..]).hidden = false + unless q.classList.contains 'filtered' + $.x('ancestor::table[1]', $.id id).hidden = false $.rm table parse: (req, pathname, id, threadID, inline) -> @@ -2308,6 +2323,9 @@ Main = if conf['Reply Hiding'] replyHiding.init() + if conf['Filter'] or conf['Reply Hiding'] + strikethroughQuotes.init() + if conf['Anonymize'] anonymize.init() @@ -2586,6 +2604,9 @@ Main = .filetitle, .replytitle, .postername, .commentpostername, .postertrip { background: none; } + .filtered { + text-decoration: line-through; + } /* Firefox bug: hidden tables are not hidden. fixed in 9.0 */ [hidden] {