diff --git a/4chan_x.user.js b/4chan_x.user.js index b3ef0761e..7e5bc4b3e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -118,7 +118,8 @@ 'Quote Inline': [true, 'Show quoted post inline on quote click'], 'Quote Preview': [true, 'Show quote content on hover'], 'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes'], - 'Indicate Cross-thread Quotes': [true, 'Add \'(Cross-thread)\' to cross-threads quotes'] + 'Indicate Cross-thread Quotes': [true, 'Add \'(Cross-thread)\' to cross-threads quotes'], + 'Forward Hiding': [true, 'Hide original posts of inlined backlinks'] } }, filter: { @@ -2446,7 +2447,7 @@ e.preventDefault(); id = this.hash.slice(1); if (/\binlined\b/.test(this.className)) { - $.rm($.x("following::*[@id='i" + id + "']", this)); + quoteInline.rm(this, id); } else { if ($.x("ancestor::*[@id='" + id + "']", this)) return; quoteInline.add(this, id); @@ -2460,6 +2461,9 @@ inline = quoteInline.table(id, el.innerHTML); if (/\bbacklink\b/.test(q.className)) { $.after(q.parentNode, inline); + if (conf['Forward Hiding']) { + $.addClass($.x('ancestor::table', el), 'forwarded'); + } return; } return $.after(root, inline); @@ -2477,6 +2481,20 @@ })); } }, + rm: function(q, id) { + var inlined, table, _i, _len, _ref; + table = $.x("following::*[@id='i" + id + "']", q); + $.rm(table); + if (!conf['Forward Hiding']) return; + _ref = $$('.backlink.inlined', table); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + inlined = _ref[_i]; + $.removeClass($.x('ancestor::table', $.id(inlined.hash.slice(1))), 'forwarded'); + } + if (/\bbacklink\b/.test(q.className)) { + return $.removeClass($.x('ancestor::table', $.id(id)), 'forwarded'); + } + }, parse: function(req, pathname, id, threadID, inline) { var body, href, html, link, newInline, op, quote, reply, _i, _j, _len, _len2, _ref, _ref2; if (!inline.parentNode) return; @@ -3166,9 +3184,6 @@ }, css: '\ /* dialog styling */\ - a[href="javascript:;"] {\ - text-decoration: none;\ - }\ div.dialog {\ border: 1px solid;\ }\ @@ -3178,6 +3193,17 @@ label, a, .favicon, #qr img {\ cursor: pointer;\ }\ + a[href="javascript:;"] {\ + 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),\ + #qp > input, #qp .inline, .forwarded {\ + display: none;\ + }\ \ .new {\ background: lime;\ @@ -3194,10 +3220,6 @@ td.replyhider {\ vertical-align: top;\ }\ -\ - div.thread.stub > *:not(.block) {\ - display: none;\ - }\ \ .filesize + br + a {\ float: left;\ @@ -3261,9 +3283,6 @@ #options label {\ text-decoration: underline;\ }\ - #options [name=tab]:not(:checked) + * {\ - display: none;\ - }\ #content > div {\ height: 450px;\ overflow: auto;\ @@ -3330,9 +3349,6 @@ border: none;\ background: transparent;\ }\ - #updater:not(:hover) > div:not(.move) {\ - display: none;\ - }\ \ #stats {\ border: none;\ @@ -3362,9 +3378,6 @@ border: 1px solid;\ padding-bottom: 5px;\ }\ - #qp input, #qp .inline {\ - display: none;\ - }\ .qphl {\ outline: 2px solid rgba(216, 94, 49, .7);\ }\ @@ -3381,11 +3394,6 @@ .filtered {\ text-decoration: line-through;\ }\ -\ - /* Firefox bug: hidden tables are not hidden. fixed in 9.0 */\ - [hidden] {\ - display: none;\ - }\ \ #files > input {\ display: block;\ diff --git a/changelog b/changelog index 9461230bb..964e8cd22 100644 --- a/changelog +++ b/changelog @@ -1,5 +1,6 @@ master - mayhem + hide original posts from inlined backlinks - optional enable autoposting when submitting a captcha while on cooldown fix caret position when quoting on Opera diff --git a/script.coffee b/script.coffee index 6be3dd4cd..1e3452372 100644 --- a/script.coffee +++ b/script.coffee @@ -46,6 +46,7 @@ config = 'Quote Preview': [true, 'Show quote content on hover'] 'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes'] 'Indicate Cross-thread Quotes': [true, 'Add \'(Cross-thread)\' to cross-threads quotes'] + 'Forward Hiding': [true, 'Hide original posts of inlined backlinks'] filter: name: '' tripcode: '' @@ -1929,8 +1930,7 @@ quoteInline = e.preventDefault() id = @hash[1..] if /\binlined\b/.test @className - # remove the corresponding table or loading td - $.rm $.x "following::*[@id='i#{id}']", @ + quoteInline.rm @, id else return if $.x "ancestor::*[@id='#{id}']", @ quoteInline.add @, id @@ -1942,6 +1942,7 @@ quoteInline = inline = quoteInline.table id, el.innerHTML if /\bbacklink\b/.test q.className $.after q.parentNode, inline + $.addClass $.x('ancestor::table', el), 'forwarded' if conf['Forward Hiding'] return $.after root, inline else @@ -1954,6 +1955,16 @@ quoteInline = threadID = pathname.split('/').pop() $.cache pathname, (-> quoteInline.parse @, pathname, id, threadID, inline) + rm: (q, id) -> + #select the corresponding table or loading td + table = $.x "following::*[@id='i#{id}']", q + $.rm table + return unless conf['Forward Hiding'] + for inlined in $$ '.backlink.inlined', table + $.removeClass $.x('ancestor::table', $.id inlined.hash[1..]), 'forwarded' + if /\bbacklink\b/.test q.className + $.removeClass $.x('ancestor::table', $.id id), 'forwarded' + parse: (req, pathname, id, threadID, inline) -> return unless inline.parentNode @@ -2526,9 +2537,6 @@ Main = css: ' /* dialog styling */ - a[href="javascript:;"] { - text-decoration: none; - } div.dialog { border: 1px solid; } @@ -2538,6 +2546,17 @@ Main = label, a, .favicon, #qr img { cursor: pointer; } + a[href="javascript:;"] { + 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), + #qp > input, #qp .inline, .forwarded { + display: none; + } .new { background: lime; @@ -2555,10 +2574,6 @@ Main = vertical-align: top; } - div.thread.stub > *:not(.block) { - display: none; - } - .filesize + br + a { float: left; pointer-events: none; @@ -2621,9 +2636,6 @@ Main = #options label { text-decoration: underline; } - #options [name=tab]:not(:checked) + * { - display: none; - } #content > div { height: 450px; overflow: auto; @@ -2690,9 +2702,6 @@ Main = border: none; background: transparent; } - #updater:not(:hover) > div:not(.move) { - display: none; - } #stats { border: none; @@ -2722,9 +2731,6 @@ Main = border: 1px solid; padding-bottom: 5px; } - #qp input, #qp .inline { - display: none; - } .qphl { outline: 2px solid rgba(216, 94, 49, .7); } @@ -2742,11 +2748,6 @@ Main = text-decoration: line-through; } - /* Firefox bug: hidden tables are not hidden. fixed in 9.0 */ - [hidden] { - display: none; - } - #files > input { display: block; }