From c5abc905d9f88e07c44a22bd56fed018a25e0ebc Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 13 Aug 2010 22:22:43 -0700 Subject: [PATCH] update to coffeescript 0.9.1 1eebbfe2bcc1a0d46a0d need the git version for quoted object keys: obj = 'foo': 'bar' 'baz': 'qux' --- 4chan_x.coffee | 693 ++++++++++++++++++++++++------------------------- 4chan_x.js | 351 +++++++++++++------------ 2 files changed, 537 insertions(+), 507 deletions(-) diff --git a/4chan_x.coffee b/4chan_x.coffee index 523d5e859..b83821335 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -4,91 +4,90 @@ #todo: hotkeys? navlink at top? #thread watching doesn't work in opera? -config: { - 'Thread Hiding': true, - 'Reply Hiding': true, - 'Show Stubs': true, - 'Thread Navigation': true, - 'Reply Navigation': true, - 'Thread Watcher': true, - 'Thread Expansion': true, - 'Comment Expansion': true, - 'Quick Reply': true, - 'Quick Report': true, - 'Auto Watch': true, - 'Anonymize': false, -} -getValue: (name) -> +config = + 'Thread Hiding': true + 'Reply Hiding': true + 'Show Stubs': true + 'Thread Navigation': true + 'Reply Navigation': true + 'Thread Watcher': true + 'Thread Expansion': true + 'Comment Expansion': true + 'Quick Reply': true + 'Quick Report': true + 'Auto Watch': true + 'Anonymize': false +getValue = (name) -> GM_getValue(name, config[name]) -x: (path, root) -> - root ||= document.body +x = (path, root) -> + root or= document.body document. evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null). singleNodeValue -$: (selector, root) -> - root ||= document.body +$ = (selector, root) -> + root or= document.body root.querySelector(selector) -$$: (selector, root) -> - root ||= document.body - result: root.querySelectorAll(selector) +$$ = (selector, root) -> + root or= document.body + result = root.querySelectorAll(selector) #magic that turns the results object into an array: node for node in result -inBefore: (root, el) -> +inBefore = (root, el) -> root.parentNode.insertBefore(el, root) -inAfter: (root, el) -> +inAfter = (root, el) -> root.parentNode.insertBefore(el, root.nextSibling) -tag: (el) -> +tag = (el) -> document.createElement(el) -hide: (el) -> +hide = (el) -> el.style.display = 'none' -show: (el) -> +show = (el) -> el.style.display = '' -remove: (el) -> +remove = (el) -> el.parentNode.removeChild(el) -replace: (root, el) -> +replace = (root, el) -> root.parentNode.replaceChild(el, root) -getTime: -> +getTime = -> Math.floor(new Date().getTime() / 1000) -make: (tag, obj) -> - el: document.createElement(tag) +make = (tag, obj) -> + el = document.createElement(tag) if obj for key of obj - el[key]: obj[key] + el[key] = obj[key] return el -slice: (arr, id) -> +slice = (arr, id) -> # the while loop is the only low-level loop left in coffeescript. # we need to use it to see the index. # would it be better to just use objects and the `delete` keyword? - i: 0 - l: arr.length + i = 0 + l = arr.length while (i < l) if id == arr[i].id arr.splice(i, 1) return arr i++ -position: (el) -> - id: el.id - if left: GM_getValue("${id}Left", '0px') - el.style.left: left +position = (el) -> + id = el.id + if left = GM_getValue("#{id}Left", '0px') + el.style.left = left else - el.style.right: '0px' - if top: GM_getValue("${id}Top", '0px') - el.style.top: top + el.style.right = '0px' + if top = GM_getValue("#{id}Top", '0px') + el.style.top = top else - el.style.bottom: '0px' + el.style.bottom = '0px' # x-browser if typeof GM_deleteValue == 'undefined' - this.GM_setValue: (name, value) -> - value: (typeof value)[0] + value + this.GM_setValue = (name, value) -> + value = (typeof value)[0] + value localStorage.setItem(name, value) - this.GM_getValue: (name, defaultValue) -> - if not value: localStorage.getItem(name) + this.GM_getValue = (name, defaultValue) -> + if not value = localStorage.getItem(name) return defaultValue - type: value[0] - value: value.substring(1) + type = value[0] + value = value.substring(1) switch type when 'b' return value == 'true' @@ -97,24 +96,24 @@ if typeof GM_deleteValue == 'undefined' else return value - this.GM_addStyle: (css) -> - style: tag('style') - style.type: 'text/css' - style.textContent: css + this.GM_addStyle = (css) -> + style = tag('style') + style.type = 'text/css' + style.textContent = css $('head', document).appendChild(style) -watched: JSON.parse(GM_getValue('watched', '{}')) +watched = JSON.parse(GM_getValue('watched', '{}')) if location.hostname.split('.')[0] is 'sys' - if b: $('table font b') + if b = $('table font b') GM_setValue('error', b.firstChild.textContent) else GM_setValue('error', '') if GM_getValue('Auto Watch') - html: $('b').innerHTML - [nop, thread, id]: html.match(//) + html = $('b').innerHTML + [nop, thread, id] = html.match(//) if thread is '0' - board: $('meta', document).content.match(/4chan.org\/(\w+)\//)[1] - watched[board] ||= [] + board = $('meta', document).content.match(/4chan.org\/(\w+)\//)[1] + watched[board] or= [] watched[board].push({ id: id, text: GM_getValue('autoText') @@ -122,34 +121,34 @@ if location.hostname.split('.')[0] is 'sys' GM_setValue('watched', JSON.stringify(watched)) return -[nop, BOARD, magic]: location.pathname.split('/') +[nop, BOARD, magic] = location.pathname.split('/') if magic is 'res' - REPLY: magic + REPLY = magic else - PAGENUM: parseInt(magic) || 0 -xhrs: [] -r: null -iframeLoop: false -move: { } -callbacks: [] + PAGENUM = parseInt(magic) || 0 +xhrs = [] +r = null +iframeLoop = false +move = { } +callbacks = [] #godammit moot -head: $('head', document) -if not favicon: $('link[rel="shortcut icon"]', head)#/f/ - favicon: tag('link') - favicon.rel: 'shortcut icon' - favicon.href: 'http://static.4chan.org/image/favicon.ico' +head = $('head', document) +if not favicon = $('link[rel="shortcut icon"]', head)#/f/ + favicon = tag('link') + favicon.rel = 'shortcut icon' + favicon.href = 'http://static.4chan.org/image/favicon.ico' head.appendChild(favicon) -favNormal: favicon.href -favEmpty: 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==' +favNormal = favicon.href +favEmpty = 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==' -hiddenThreads: JSON.parse(GM_getValue("hiddenThreads/$BOARD/", '[]')) -hiddenReplies: JSON.parse(GM_getValue("hiddenReplies/$BOARD/", '[]')) +hiddenThreads = JSON.parse(GM_getValue("hiddenThreads/#{BOARD}/", '[]')) +hiddenReplies = JSON.parse(GM_getValue("hiddenReplies/#{BOARD}/", '[]')) -lastChecked: GM_getValue('lastChecked', 0) -now: getTime() -DAY: 24 * 60 * 60 +lastChecked = GM_getValue('lastChecked', 0) +now = getTime() +DAY = 24 * 60 * 60 if lastChecked < now - 1*DAY - cutoff: now - 7*DAY + cutoff = now - 7*DAY while hiddenThreads.length if hiddenThreads[0].timestamp > cutoff break @@ -160,8 +159,8 @@ if lastChecked < now - 1*DAY break hiddenReplies.shift() - GM_setValue("hiddenThreads/$BOARD/", JSON.stringify(hiddenThreads)) - GM_setValue("hiddenReplies/$BOARD/", JSON.stringify(hiddenReplies)) + GM_setValue("hiddenThreads/#{BOARD}/", JSON.stringify(hiddenThreads)) + GM_setValue("hiddenReplies/#{BOARD}/", JSON.stringify(hiddenReplies)) GM_setValue('lastChecked', now) GM_addStyle(' @@ -220,33 +219,33 @@ GM_addStyle(' ') -clearHidden: -> +clearHidden = -> #'hidden' might be misleading; it's the number of IDs we're *looking* for, # not the number of posts actually hidden on the page. - GM_deleteValue("hiddenReplies/$BOARD/") - GM_deleteValue("hiddenThreads/$BOARD/") - @value: "hidden: 0" - hiddenReplies: [] - hiddenThreads: [] + GM_deleteValue("hiddenReplies/#{BOARD}/") + GM_deleteValue("hiddenThreads/#{BOARD}/") + @value = "hidden: 0" + hiddenReplies = [] + hiddenThreads = [] -options: -> +options = -> #redo this - if div: $('#options') + if div = $('#options') remove(div) else - hiddenNum: hiddenReplies.length + hiddenThreads.length - div: tag('div') - div.id: 'options' - div.className: 'reply' + hiddenNum = hiddenReplies.length + hiddenThreads.length + div = tag('div') + div.id = 'options' + div.className = 'reply' position(div) - html: '
4chan X
' + html = '
4chan X
' for option of config - checked: if getValue(option) then "checked" else "" - html += "
" - html += "
" + checked = if getValue(option) then "checked" else "" + html += "
" + html += "
" html += 'save cancel
' - div.innerHTML: html + div.innerHTML = html $('div', div).addEventListener('mousedown', mousedown, true) $('input[type="button"]', div).addEventListener('click', clearHidden, true) $('a[name="save"]', div).addEventListener('click', optionsSave, true) @@ -254,208 +253,208 @@ options: -> document.body.appendChild(div) -mousedown: (e) -> - div: this.parentNode - move.div: div - move.clientX: e.clientX - move.clientY: e.clientY - move.bodyX: document.body.clientWidth - move.bodyY: document.body.clientHeight +mousedown = (e) -> + div = this.parentNode + move.div = div + move.clientX = e.clientX + move.clientY = e.clientY + move.bodyX = document.body.clientWidth + move.bodyY = document.body.clientHeight # check if the string exists. parseInt('0px') is falsey. l = div.style.left - move.divX: if l then parseInt(l) else move.bodyX - div.offsetWidth + move.divX = if l then parseInt(l) else move.bodyX - div.offsetWidth t = div.style.top - move.divY: if t then parseInt(t) else move.bodyY - div.offsetHeight + move.divY = if t then parseInt(t) else move.bodyY - div.offsetHeight window.addEventListener('mousemove', mousemove, true) window.addEventListener('mouseup', mouseup, true) -mousemove: (e) -> - div: move.div - realX: move.divX + (e.clientX - move.clientX)# x + dx - left: if realX < 20 then 0 else realX +mousemove = (e) -> + div = move.div + realX = move.divX + (e.clientX - move.clientX)# x + dx + left = if realX < 20 then 0 else realX if move.bodyX - div.offsetWidth - realX < 20 - div.style.left: '' - div.style.right: '0px' + div.style.left = '' + div.style.right = '0px' else - div.style.left: left + 'px' - div.style.right: '' + div.style.left = left + 'px' + div.style.right = '' - realY: move.divY + (e.clientY - move.clientY)# y + dy - top: if realY < 20 then 0 else realY + realY = move.divY + (e.clientY - move.clientY)# y + dy + top = if realY < 20 then 0 else realY if move.bodyY - div.offsetHeight - realY < 20 - div.style.top: '' - div.style.bottom: '0px' + div.style.top = '' + div.style.bottom = '0px' else - div.style.top: top + 'px' - div.style.bottom: '' + div.style.top = top + 'px' + div.style.bottom = '' -mouseup: -> - id: move.div.id - GM_setValue("${id}Left", move.div.style.left) - GM_setValue("${id}Top", move.div.style.top) +mouseup = -> + id = move.div.id + GM_setValue("#{id}Left", move.div.style.left) + GM_setValue("#{id}Top", move.div.style.top) window.removeEventListener('mousemove', mousemove, true) window.removeEventListener('mouseup', mouseup, true) -showThread: -> - div: this.nextSibling +showThread = -> + div = this.nextSibling show(div) hide(this) - id: div.id + id = div.id slice(hiddenThreads, id) - GM_setValue("hiddenThreads/$BOARD/", JSON.stringify(hiddenThreads)) + GM_setValue("hiddenThreads/#{BOARD}/", JSON.stringify(hiddenThreads)) -hideThread: (div) -> - if p: this.parentNode - div: p +hideThread = (div) -> + if p = this.parentNode + div = p hiddenThreads.push({ id: div.id timestamp: getTime() }) - GM_setValue("hiddenThreads/$BOARD/", JSON.stringify(hiddenThreads)) + GM_setValue("hiddenThreads/#{BOARD}/", JSON.stringify(hiddenThreads)) hide(div) if getValue('Show Stubs') - a: tag('a') - if span: $('.omittedposts', div) - n: Number(span.textContent.match(/\d+/)[0]) + a = tag('a') + if span = $('.omittedposts', div) + n = Number(span.textContent.match(/\d+/)[0]) else - n: 0 + n = 0 n += $$('table', div).length - text: if n is 1 then "1 reply" else "$n replies" - name: $('span.postername', div).textContent - trip: $('span.postername + span.postertrip', div)?.textContent || '' - a.textContent: "[ + ] $name$trip ($text)" - a.className: 'pointer' + text = if n is 1 then "1 reply" else "#{n} replies" + name = $('span.postername', div).textContent + trip = $('span.postername + span.postertrip', div)?.textContent || '' + a.textContent = "[ + ] #{name}#{trip} (#{text})" + a.className = 'pointer' a.addEventListener('click', showThread, true) inBefore(div, a) -threadF: (current) -> - div: tag('div') - div.className: 'thread' - a: tag('a') - a.textContent: '[ - ]' - a.className: 'pointer' +threadF = (current) -> + div = tag('div') + div.className = 'thread' + a = tag('a') + a.textContent = '[ - ]' + a.className = 'pointer' a.addEventListener('click', hideThread, true) div.appendChild(a) inBefore(current, div) while (!current.clear)#
div.appendChild(current) - current: div.nextSibling + current = div.nextSibling div.appendChild(current) - current: div.nextSibling + current = div.nextSibling - id: $('input[value="delete"]', div).name - div.id: id + id = $('input[value="delete"]', div).name + div.id = id #check if we should hide the thread for hidden in hiddenThreads if id == hidden.id hideThread(div) - current: current.nextSibling.nextSibling + current = current.nextSibling.nextSibling if current.nodeName isnt 'CENTER' threadF(current) -showReply: -> - div: this.parentNode - table: div.nextSibling +showReply = -> + div = this.parentNode + table = div.nextSibling show(table) remove(div) - id: $('td.reply, td.replyhl', table).id + id = $('td.reply, td.replyhl', table).id slice(hiddenReplies, id) - GM_setValue("hiddenReplies/$BOARD/", JSON.stringify(hiddenReplies)) + GM_setValue("hiddenReplies/#{BOARD}/", JSON.stringify(hiddenReplies)) -hideReply: (reply) -> - if p: this.parentNode - reply: p.nextSibling +hideReply = (reply) -> + if p = this.parentNode + reply = p.nextSibling hiddenReplies.push({ id: reply.id timestamp: getTime() }) - GM_setValue("hiddenReplies/$BOARD/", JSON.stringify(hiddenReplies)) + GM_setValue("hiddenReplies/#{BOARD}/", JSON.stringify(hiddenReplies)) - name: $('span.commentpostername', reply).textContent - trip: $('span.postertrip', reply)?.textContent || '' - table: x('ancestor::table', reply) + name = $('span.commentpostername', reply).textContent + trip = $('span.postertrip', reply)?.textContent || '' + table = x('ancestor::table', reply) hide(table) if getValue('Show Stubs') - a: tag('a') - a.textContent: "[ + ] $name $trip" - a.className: 'pointer' + a = tag('a') + a.textContent = "[ + ] #{name} #{trip}" + a.className = 'pointer' a.addEventListener('click', showReply, true) - div: tag('div') + div = tag('div') div.appendChild(a) inBefore(table, div) -optionsSave: -> - div: this.parentNode.parentNode - inputs: $$('input', div) +optionsSave = -> + div = this.parentNode.parentNode + inputs = $$('input', div) for input in inputs GM_setValue(input.name, input.checked) remove(div) -close: -> - div: this.parentNode.parentNode +close = -> + div = this.parentNode.parentNode remove(div) -iframeLoad: -> - if iframeLoop: !iframeLoop +iframeLoad = -> + if iframeLoop = !iframeLoop return - $('iframe').src: 'about:blank' + $('iframe').src = 'about:blank' - qr: $('#qr') - if error: GM_getValue('error') - $('form', qr).style.visibility: '' - span: tag('span') - span.textContent: error - span.className: 'error' + qr = $('#qr') + if error = GM_getValue('error') + $('form', qr).style.visibility = '' + span = tag('span') + span.textContent = error + span.className = 'error' qr.appendChild(span) else remove(qr) -submit: -> - this.style.visibility: 'collapse' - if span: this.nextSibling +submit = -> + this.style.visibility = 'collapse' + if span = this.nextSibling remove(span) -minimize: -> - form: this.parentNode.nextSibling +minimize = -> + form = this.parentNode.nextSibling if form.style.visibility - form.style.visibility: '' + form.style.visibility = '' else - form.style.visibility: 'collapse' + form.style.visibility = 'collapse' -quickReply: (e) -> +quickReply = (e) -> e.preventDefault() - if !qr: $('#qr') + if !qr = $('#qr') #make quick reply dialog - qr: tag('div') - qr.id: 'qr' - qr.className: 'reply' + qr = tag('div') + qr.id = 'qr' + qr.className = 'reply' position(qr) - div: tag('div') - div.innerHTML: 'Quick Reply ' - div.className: 'move' + div = tag('div') + div.innerHTML = 'Quick Reply ' + div.className = 'move' div.addEventListener('mousedown', mousedown, true) qr.appendChild(div) - minimizeB: make('a', { + minimizeB = make('a', { textContent: '_' className: 'pointer' title: 'minimize' @@ -463,7 +462,7 @@ quickReply: (e) -> minimizeB.addEventListener('click', minimize, true) div.appendChild(minimizeB) div.appendChild(document.createTextNode(' ')) - closeB: make('a', { + closeB = make('a', { textContent: 'X' className: 'pointer' title: 'close' @@ -471,14 +470,14 @@ quickReply: (e) -> closeB.addEventListener('click', close, true) div.appendChild(closeB) - clone: $('form[name="post"]').cloneNode(true) + clone = $('form[name="post"]').cloneNode(true) #remove buzzfeed - if bf: $('.bf', clone) then remove(bf) + if bf = $('.bf', clone) then remove(bf) clone.addEventListener('submit', submit, true) - clone.target: 'iframe' + clone.target = 'iframe' if not REPLY - xpath: 'preceding::span[@class="postername"][1]/preceding::input[1]' - input: make 'input', { + xpath = 'preceding::span[@class="postername"][1]/preceding::input[1]' + input = make 'input', { value: x(xpath, this).name type: 'hidden' name: 'resto' @@ -487,108 +486,108 @@ quickReply: (e) -> qr.appendChild(clone) document.body.appendChild(qr) - textarea: $('textarea', qr) + textarea = $('textarea', qr) textarea.focus() #we can't just use @textContent b/c of the xxxs. goddamit moot. textarea.value += '>>' + @parentNode.id.match(/\d+$/)[0] + '\n' - selection: window.getSelection() - id: x('preceding::span[@id][1]', selection.anchorNode)?.id + selection = window.getSelection() + id = x('preceding::span[@id][1]', selection.anchorNode)?.id if id is this.parentNode.id - if selText: selection.toString() - textarea.value += ">$selText\n" + if selText = selection.toString() + textarea.value += ">#{selText}\n" return -watch: -> - id: this.nextSibling.name +watch = -> + id = this.nextSibling.name if this.src[0] is 'd'#data:png - this.src: favNormal - text: "/$BOARD/ - " + + this.src = favNormal + text = "/#{BOARD}/ - " + x('following-sibling::blockquote', this).textContent.slice(0,25) - watched[BOARD] ||= [] + watched[BOARD] or= [] watched[BOARD].push({ id: id, text: text }) else - this.src: favEmpty - watched[BOARD]: slice(watched[BOARD], id) + this.src = favEmpty + watched[BOARD] = slice(watched[BOARD], id) GM_setValue('watched', JSON.stringify(watched)) watcherUpdate() -watchX: -> - [board, nop, id]: +watchX = -> + [board, nop, id] = this.nextElementSibling.getAttribute('href').substring(1).split('/') - watched[board]: slice(watched[board], id) + watched[board] = slice(watched[board], id) GM_setValue('watched', JSON.stringify(watched)) watcherUpdate() - if input: $("input[name=\"$id\"]") - favicon: input.previousSibling - favicon.src: favEmpty + if input = $("input[name=\"#{id}\"]") + favicon = input.previousSibling + favicon.src = favEmpty -watcherUpdate: -> - div: tag('div') +watcherUpdate = -> + div = tag('div') for board of watched for thread in watched[board] - a: tag('a') - a.textContent: 'X' - a.className: 'pointer' + a = tag('a') + a.textContent = 'X' + a.className = 'pointer' a.addEventListener('click', watchX, true) div.appendChild(a) div.appendChild(document.createTextNode(' ')) - link: tag('a') - link.textContent: thread.text - link.href: "/$board/res/${thread.id}" + link = tag('a') + link.textContent = thread.text + link.href = "/#{board}/res/#{thread.id}" div.appendChild(link) div.appendChild(tag('br')) - old: $('#watcher div:last-child') + old = $('#watcher div:last-child') replace(old, div) -parseResponse: (responseText) -> - body: make('body', { +parseResponse = (responseText) -> + body = make('body', { innerHTML: responseText }) - replies: $$('td.reply', body) - opbq: $('blockquote', body) + replies = $$('td.reply', body) + opbq = $('blockquote', body) return [replies, opbq] -onloadThread: (responseText, span) -> - [replies, opbq]: parseResponse(responseText) - span.textContent: span.textContent.replace('X Loading...', '- ') +onloadThread = (responseText, span) -> + [replies, opbq] = parseResponse(responseText) + span.textContent = span.textContent.replace('X Loading...', '- ') #make sure all comments are fully expanded - span.previousSibling.innerHTML: opbq.innerHTML - while (next: span.nextSibling) and not next.clear#
+ span.previousSibling.innerHTML = opbq.innerHTML + while (next = span.nextSibling) and not next.clear#
remove(next) if next for reply in replies inBefore(next, x('ancestor::table', reply)) else#threading - div: span.parentNode + div = span.parentNode for reply in replies div.appendChild(x('ancestor::table', reply)) -expandThread: -> - id: x('preceding-sibling::input[1]', this).name - span: this +expandThread = -> + id = x('preceding-sibling::input[1]', this).name + span = this #close expanded thread if span.textContent[0] is '-' #goddamit moot - num: if board is 'b' then 3 else 5 - table: x("following::br[@clear][1]/preceding::table[$num]", span) - while (prev: table.previousSibling) and (prev.nodeName is 'TABLE') + num = if board is 'b' then 3 else 5 + table = x("following::br[@clear][1]/preceding::table[#{num}]", span) + while (prev = table.previousSibling) and (prev.nodeName is 'TABLE') remove(prev) - span.textContent: span.textContent.replace('-', '+') + span.textContent = span.textContent.replace('-', '+') return - span.textContent: span.textContent.replace('+', 'X Loading...') + span.textContent = span.textContent.replace('+', 'X Loading...') #load cache for xhr in xhrs if xhr.id == id @@ -597,10 +596,10 @@ expandThread: -> return #create new request - r: new XMLHttpRequest() - r.onload: -> + r = new XMLHttpRequest() + r.onload = -> onloadThread(this.responseText, span) - r.open('GET', "res/$id", true) + r.open('GET', "res/#{id}", true) r.send() xhrs.push({ r: r, @@ -608,27 +607,27 @@ expandThread: -> }) -onloadComment: (responseText, a, href) -> - [nop, op, id]: href.match(/(\d+)#(\d+)/) - [replies, opbq]: parseResponse(responseText) +onloadComment = (responseText, a, href) -> + [nop, op, id] = href.match(/(\d+)#(\d+)/) + [replies, opbq] = parseResponse(responseText) if id is op - html: opbq.innerHTML + html = opbq.innerHTML else #css selectors don't like ids starting with numbers, # getElementById only works for root document. for reply in replies if reply.id == id - html: $('blockquote', reply).innerHTML - bq: x('ancestor::blockquote', a) - bq.innerHTML: html + html = $('blockquote', reply).innerHTML + bq = x('ancestor::blockquote', a) + bq.innerHTML = html -expandComment: (e) -> +expandComment = (e) -> e.preventDefault() - a: this - href: a.getAttribute('href') - r: new XMLHttpRequest() - r.onload: -> + a = this + href = a.getAttribute('href') + r = new XMLHttpRequest() + r.onload = -> onloadComment(this.responseText, a, href) r.open('GET', href, true) r.send() @@ -638,73 +637,73 @@ expandComment: (e) -> }) -report: -> - input: x('preceding-sibling::input[1]', this) +report = -> + input = x('preceding-sibling::input[1]', this) input.click() $('input[value="Report"]').click() input.click() -nodeInserted: (e) -> - target: e.target +nodeInserted = (e) -> + target = e.target if target.nodeName is 'TABLE' for callback in callbacks callback(target) -autoWatch: -> - autoText: $('textarea', this).value.slice(0, 25) - GM_setValue('autoText', "/$BOARD/ - $autoText") +autoWatch = -> + autoText = $('textarea', this).value.slice(0, 25) + GM_setValue('autoText', "/#{BOARD}/ - #{autoText}") -stopPropagation: (e) -> +stopPropagation = (e) -> e.stopPropagation() -replyNav: -> +replyNav = -> if REPLY - window.location: if @textContent is '▲' then '#navtop' else '#navbot' + window.location = if @textContent is '▲' then '#navtop' else '#navbot' else - direction: if @textContent is '▲' then 'preceding' else 'following' - op: x("$direction::span[starts-with(@id, 'nothread')][1]", this).id - window.location: "#$op" + direction = if @textContent is '▲' then 'preceding' else 'following' + op = x("#{direction}::span[starts-with(@id, 'nothread')][1]", this).id + window.location = "##{op}" #error out if there's no #navtopr. -text: $('#navtopr a').nextSibling -a: tag('a') -a.textContent: 'X' -a.className: 'pointer' +text = $('#navtopr a').nextSibling +a = tag('a') +a.textContent = 'X' +a.className = 'pointer' a.addEventListener('click', options, true) inBefore(text, document.createTextNode(' / ')) inBefore(text, a) if getValue('Reply Hiding') callbacks.push((root) -> - tds: $$('td.doubledash', root) + tds = $$('td.doubledash', root) for td in tds - a: tag('a') - a.textContent: '[ - ]' - a.className: 'pointer' + a = tag('a') + a.textContent = '[ - ]' + a.className = 'pointer' a.addEventListener('click', hideReply, true) replace(td.firstChild, a) - next: td.nextSibling - id: next.id + next = td.nextSibling + id = next.id for obj in hiddenReplies if obj.id is id hideReply(next) ) if getValue('Quick Reply') - iframe: tag('iframe') + iframe = tag('iframe') hide(iframe) - iframe.name: 'iframe' + iframe.name = 'iframe' iframe.addEventListener('load', iframeLoad, true) document.body.appendChild(iframe) callbacks.push((root) -> - quotes: $$('a.quotejs:not(:first-child)', root) + quotes = $$('a.quotejs:not(:first-child)', root) for quote in quotes quote.addEventListener('click', quickReply, true) ) @@ -712,11 +711,11 @@ if getValue('Quick Reply') if getValue('Quick Report') callbacks.push((root) -> - arr: $$('span[id^=no]', root) + arr = $$('span[id^=no]', root) for el in arr - a: tag('a') - a.textContent: '[ ! ]' - a.className: 'pointer' + a = tag('a') + a.textContent = '[ ! ]' + a.className = 'pointer' a.addEventListener('click', report, true) inAfter(el, a) inAfter(el, document.createTextNode(' ')) @@ -724,37 +723,37 @@ if getValue('Quick Report') if getValue('Thread Watcher') #create watcher - watcher: tag('div') - watcher.innerHTML: '
Thread Watcher
' - watcher.className: 'reply' - watcher.id: 'watcher' + watcher = tag('div') + watcher.innerHTML = '
Thread Watcher
' + watcher.className = 'reply' + watcher.id = 'watcher' position(watcher) $('div', watcher).addEventListener('mousedown', mousedown, true) document.body.appendChild(watcher) watcherUpdate() #add buttons - threads: watched[BOARD] || [] + threads = watched[BOARD] || [] #normal, threading - inputs: $$('form > input[value="delete"], div > input[value="delete"]') + inputs = $$('form > input[value="delete"], div > input[value="delete"]') for input in inputs - img: tag('img') - id: input.name + img = tag('img') + id = input.name for thread in threads if id == thread.id - img.src: favNormal + img.src = favNormal break - img.src ||= favEmpty - img.className: 'pointer' + img.src or= favEmpty + img.className = 'pointer' img.addEventListener('click', watch, true) inBefore(input, img) if getValue('Anonymize') callbacks.push((root) -> - names: $$('span.postername, span.commentpostername', root) + names = $$('span.postername, span.commentpostername', root) for name in names - name.innerHTML: 'Anonymous' - trips: $$('span.postertrip', root) + name.innerHTML = 'Anonymous' + trips = $$('span.postertrip', root) for trip in trips if trip.parentNode.nodeName is 'A' remove(trip.parentNode) @@ -764,16 +763,16 @@ if getValue('Anonymize') if getValue('Reply Navigation') callbacks.push((root) -> - arr: $$('span[id^=norep]', root) + arr = $$('span[id^=norep]', root) for el in arr - span: tag('span') - up: tag('a') - up.textContent: '▲' - up.className: 'pointer' + span = tag('span') + up = tag('a') + up.textContent = '▲' + up.className = 'pointer' up.addEventListener('click', replyNav, true) - down: tag('a') - down.textContent: '▼' - down.className: 'pointer' + down = tag('a') + down.textContent = '▼' + down.className = 'pointer' down.addEventListener('click', replyNav, true) span.appendChild(document.createTextNode(' ')) span.appendChild(up) @@ -795,54 +794,54 @@ if not REPLY $('form[name="post"]').addEventListener('submit', autoWatch, true) if getValue('Thread Navigation') - arr: $$('div > span.filesize, form > span.filesize') - i: 0 - l: arr.length - l1: l + 1 + arr = $$('div > span.filesize, form > span.filesize') + i = 0 + l = arr.length + l1 = l + 1 #should this be a while loop? for el in arr - up: tag('a') - up.className: 'pointer' + up = tag('a') + up.className = 'pointer' if i isnt 0 - up.textContent: '▲' - up.href: "#$i" + up.textContent = '▲' + up.href = "##{i}" else if PAGENUM isnt 0 - up.textContent: '◀' - up.href: "${PAGENUM - 1}" + up.textContent = '◀' + up.href = "#{PAGENUM - 1}" else - up.textContent: '▲' - up.href: "#navtop" + up.textContent = '▲' + up.href = "#navtop" - span: tag('span') - span.className: 'navlinks' - span.id: ++i - i1: i + 1 - down: tag('a') - down.className: 'pointer' + span = tag('span') + span.className = 'navlinks' + span.id = ++i + i1 = i + 1 + down = tag('a') + down.className = 'pointer' span.appendChild(up) span.appendChild(document.createTextNode(' ')) span.appendChild(down) if i1 == l1 - down.textContent: '▶' - down.href: "${PAGENUM + 1}#1" + down.textContent = '▶' + down.href = "#{PAGENUM + 1}#1" else - down.textContent: '▼' - down.href: "#$i1" + down.textContent = '▼' + down.href = "##{i1}" inBefore(el, span) if location.hash is '#1' - window.location: window.location + window.location = window.location if getValue('Thread Expansion') - omitted: $$('span.omittedposts') + omitted = $$('span.omittedposts') for span in omitted - a: tag('a') - a.className: 'pointer omittedposts' - a.textContent: "+ ${span.textContent}" + a = tag('a') + a.className = 'pointer omittedposts' + a.textContent = "+ #{span.textContent}" a.addEventListener('click', expandThread, true) replace(span, a) if getValue('Comment Expansion') - as: $$('span.abbr a') + as = $$('span.abbr a') for a in as a.addEventListener('click', expandComment, true) diff --git a/4chan_x.js b/4chan_x.js index 4ed059e0a..f92cf2861 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1,4 +1,4 @@ -(function(){ +(function() { var $, $$, BOARD, DAY, PAGENUM, REPLY, _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, a, arr, as, autoWatch, b, board, callback, callbacks, clearHidden, close, config, cutoff, delform, down, el, expandComment, expandThread, favEmpty, favNormal, favicon, getTime, getValue, head, hiddenReplies, hiddenThreads, hide, hideReply, hideThread, html, i, i1, id, iframe, iframeLoad, iframeLoop, img, inAfter, inBefore, input, inputs, l, l1, lastChecked, magic, make, minimize, mousedown, mousemove, mouseup, move, nodeInserted, nop, now, omitted, onloadComment, onloadThread, options, optionsSave, parseResponse, position, quickReply, r, remove, replace, replyNav, report, show, showReply, showThread, slice, span, stopPropagation, submit, tag, text, thread, threadF, threads, up, watch, watchX, watched, watcher, watcherUpdate, x, xhrs; var __hasProp = Object.prototype.hasOwnProperty; config = { @@ -47,12 +47,10 @@ return document.createElement(el); }; hide = function(el) { - el.style.display = 'none'; - return el.style.display; + return (el.style.display = 'none'); }; show = function(el) { - el.style.display = ''; - return el.style.display; + return (el.style.display = ''); }; remove = function(el) { return el.parentNode.removeChild(el); @@ -64,13 +62,15 @@ return Math.floor(new Date().getTime() / 1000); }; make = function(tag, obj) { - var _a, el, key; + var _a, _b, el, key; el = document.createElement(tag); if (obj) { - _a = obj; - for (key in _a) { if (__hasProp.call(_a, key)) { + _b = obj; + for (key in _b) { + if (!__hasProp.call(_b, key)) continue; + _a = _b[key]; el[key] = obj[key]; - }} + } } return el; }; @@ -79,7 +79,7 @@ i = 0; l = arr.length; _a = []; - while (i < l) { + while ((i < l)) { if (id === arr[i].id) { arr.splice(i, 1); return arr; @@ -91,8 +91,12 @@ position = function(el) { var id, left, top; id = el.id; - (left = GM_getValue(("" + (id) + "Left"), '0px')) ? (el.style.left = left) : (el.style.right = '0px'); - return (top = GM_getValue(("" + (id) + "Top"), '0px')) ? (el.style.top = top) : (el.style.bottom = '0px'); + if ((left = GM_getValue("${id}Left", '0px'))) { + el.style.left = left; + } else { + el.style.right = '0px'; + }; + return (top = GM_getValue("${id}Top", '0px')) ? (el.style.top = top) : (el.style.bottom = '0px'); }; if (typeof GM_deleteValue === 'undefined') { this.GM_setValue = function(name, value) { @@ -151,7 +155,11 @@ nop = _b[0]; BOARD = _b[1]; magic = _b[2]; - magic === 'res' ? (REPLY = magic) : (PAGENUM = parseInt(magic) || 0); + if (magic === 'res') { + REPLY = magic; + } else { + PAGENUM = parseInt(magic) || 0; + }; xhrs = []; r = null; iframeLoop = false; @@ -166,8 +174,8 @@ } favNormal = favicon.href; favEmpty = 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw=='; - hiddenThreads = JSON.parse(GM_getValue(("hiddenThreads/" + BOARD + "/"), '[]')); - hiddenReplies = JSON.parse(GM_getValue(("hiddenReplies/" + BOARD + "/"), '[]')); + hiddenThreads = JSON.parse(GM_getValue("hiddenThreads/$BOARD/", '[]')); + hiddenReplies = JSON.parse(GM_getValue("hiddenReplies/$BOARD/", '[]')); lastChecked = GM_getValue('lastChecked', 0); now = getTime(); DAY = 24 * 60 * 60; @@ -185,8 +193,8 @@ } hiddenReplies.shift(); } - GM_setValue(("hiddenThreads/" + BOARD + "/"), JSON.stringify(hiddenThreads)); - GM_setValue(("hiddenReplies/" + BOARD + "/"), JSON.stringify(hiddenReplies)); + GM_setValue("hiddenThreads/$BOARD/", JSON.stringify(hiddenThreads)); + GM_setValue("hiddenReplies/$BOARD/", JSON.stringify(hiddenReplies)); GM_setValue('lastChecked', now); } GM_addStyle(' \ @@ -244,15 +252,14 @@ cursor: pointer; \ } \ '); clearHidden = function() { - GM_deleteValue("hiddenReplies/" + BOARD + "/"); - GM_deleteValue("hiddenThreads/" + BOARD + "/"); + GM_deleteValue("hiddenReplies/$BOARD/"); + GM_deleteValue("hiddenThreads/$BOARD/"); this.value = "hidden: 0"; hiddenReplies = []; - hiddenThreads = []; - return hiddenThreads; + return (hiddenThreads = []); }; options = function() { - var _c, checked, div, hiddenNum, option; + var _c, _d, checked, div, hiddenNum, option; if ((div = $('#options'))) { return remove(div); } else { @@ -262,12 +269,14 @@ cursor: pointer; \ div.className = 'reply'; position(div); html = '
4chan X
'; - _c = config; - for (option in _c) { if (__hasProp.call(_c, option)) { + _d = config; + for (option in _d) { + if (!__hasProp.call(_d, option)) continue; + _c = _d[option]; checked = getValue(option) ? "checked" : ""; - html += ("
"); - }} - html += ("
"); + html += "
"; + } + html += "
"; html += 'save cancel
'; div.innerHTML = html; $('div', div).addEventListener('mousedown', mousedown, true); @@ -308,18 +317,16 @@ cursor: pointer; \ top = realY < 20 ? 0 : realY; if (move.bodyY - div.offsetHeight - realY < 20) { div.style.top = ''; - div.style.bottom = '0px'; - return div.style.bottom; + return (div.style.bottom = '0px'); } else { div.style.top = top + 'px'; - div.style.bottom = ''; - return div.style.bottom; + return (div.style.bottom = ''); } }; mouseup = function() { id = move.div.id; - GM_setValue(("" + (id) + "Left"), move.div.style.left); - GM_setValue(("" + (id) + "Top"), move.div.style.top); + GM_setValue("${id}Left", move.div.style.left); + GM_setValue("${id}Top", move.div.style.top); window.removeEventListener('mousemove', mousemove, true); return window.removeEventListener('mouseup', mouseup, true); }; @@ -330,27 +337,31 @@ cursor: pointer; \ hide(this); id = div.id; slice(hiddenThreads, id); - return GM_setValue(("hiddenThreads/" + BOARD + "/"), JSON.stringify(hiddenThreads)); + return GM_setValue("hiddenThreads/$BOARD/", JSON.stringify(hiddenThreads)); }; hideThread = function(div) { var _c, a, n, name, p, span, text, trip; - if (p = this.parentNode) { + if ((p = this.parentNode)) { div = p; hiddenThreads.push({ id: div.id, timestamp: getTime() }); - GM_setValue(("hiddenThreads/" + BOARD + "/"), JSON.stringify(hiddenThreads)); + GM_setValue("hiddenThreads/$BOARD/", JSON.stringify(hiddenThreads)); } hide(div); if (getValue('Show Stubs')) { a = tag('a'); - (span = $('.omittedposts', div)) ? (n = Number(span.textContent.match(/\d+/)[0])) : (n = 0); + if ((span = $('.omittedposts', div))) { + n = Number(span.textContent.match(/\d+/)[0]); + } else { + n = 0; + }; n += $$('table', div).length; - text = n === 1 ? "1 reply" : ("" + n + " replies"); + text = n === 1 ? "1 reply" : "$n replies"; name = $('span.postername', div).textContent; trip = (typeof (_c = ($('span.postername + span.postertrip', div))) === "undefined" || _c == undefined ? undefined : _c.textContent) || ''; - a.textContent = ("[ + ] " + name + trip + " (" + text + ")"); + a.textContent = "[ + ] $name$trip ($text)"; a.className = 'pointer'; a.addEventListener('click', showThread, true); return inBefore(div, a); @@ -366,7 +377,7 @@ cursor: pointer; \ a.addEventListener('click', hideThread, true); div.appendChild(a); inBefore(current, div); - while (!current.clear) { + while ((!current.clear)) { div.appendChild(current); current = div.nextSibling; } @@ -377,7 +388,9 @@ cursor: pointer; \ _d = hiddenThreads; for (_c = 0, _e = _d.length; _c < _e; _c++) { hidden = _d[_c]; - id === hidden.id ? hideThread(div) : null; + if (id === hidden.id) { + hideThread(div); + }; } current = current.nextSibling.nextSibling; return current.nodeName !== 'CENTER' ? threadF(current) : null; @@ -390,17 +403,17 @@ cursor: pointer; \ remove(div); id = $('td.reply, td.replyhl', table).id; slice(hiddenReplies, id); - return GM_setValue(("hiddenReplies/" + BOARD + "/"), JSON.stringify(hiddenReplies)); + return GM_setValue("hiddenReplies/$BOARD/", JSON.stringify(hiddenReplies)); }; hideReply = function(reply) { var _c, a, div, name, p, table, trip; - if (p = this.parentNode) { + if ((p = this.parentNode)) { reply = p.nextSibling; hiddenReplies.push({ id: reply.id, timestamp: getTime() }); - GM_setValue(("hiddenReplies/" + BOARD + "/"), JSON.stringify(hiddenReplies)); + GM_setValue("hiddenReplies/$BOARD/", JSON.stringify(hiddenReplies)); } name = $('span.commentpostername', reply).textContent; trip = (typeof (_c = ($('span.postertrip', reply))) === "undefined" || _c == undefined ? undefined : _c.textContent) || ''; @@ -408,7 +421,7 @@ cursor: pointer; \ hide(table); if (getValue('Show Stubs')) { a = tag('a'); - a.textContent = ("[ + ] " + name + " " + trip); + a.textContent = "[ + ] $name $trip"; a.className = 'pointer'; a.addEventListener('click', showReply, true); div = tag('div'); @@ -434,7 +447,7 @@ cursor: pointer; \ }; iframeLoad = function() { var error, qr, span; - if (iframeLoop = !iframeLoop) { + if ((iframeLoop = !iframeLoop)) { return null; } $('iframe').src = 'about:blank'; @@ -488,7 +501,9 @@ cursor: pointer; \ closeB.addEventListener('click', close, true); div.appendChild(closeB); clone = $('form[name="post"]').cloneNode(true); - (bf = $('.bf', clone)) ? remove(bf) : null; + if ((bf = $('.bf', clone))) { + remove(bf); + }; clone.addEventListener('submit', submit, true); clone.target = 'iframe'; if (!REPLY) { @@ -508,7 +523,11 @@ cursor: pointer; \ textarea.value += '>>' + this.parentNode.id.match(/\d+$/)[0] + '\n'; selection = window.getSelection(); id = typeof (_c = (x('preceding::span[@id][1]', selection.anchorNode))) === "undefined" || _c == undefined ? undefined : _c.id; - id === this.parentNode.id ? (selText = selection.toString()) ? textarea.value += (">" + selText + "\n") : null : null; + if (id === this.parentNode.id) { + if ((selText = selection.toString())) { + textarea.value += ">$selText\n"; + }; + }; return null; }; watch = function() { @@ -516,7 +535,7 @@ cursor: pointer; \ id = this.nextSibling.name; if (this.src[0] === 'd') { this.src = favNormal; - text = ("/" + BOARD + "/ - ") + x('following-sibling::blockquote', this).textContent.slice(0, 25); + text = "/$BOARD/ - " + x('following-sibling::blockquote', this).textContent.slice(0, 25); watched[BOARD] = watched[BOARD] || []; watched[BOARD].push({ id: id, @@ -538,20 +557,21 @@ cursor: pointer; \ watched[board] = slice(watched[board], id); GM_setValue('watched', JSON.stringify(watched)); watcherUpdate(); - if ((input = $("input[name=\"" + id + "\"]"))) { + if ((input = $("input[name=\"$id\"]"))) { favicon = input.previousSibling; - favicon.src = favEmpty; - return favicon.src; + return (favicon.src = favEmpty); } }; watcherUpdate = function() { - var _c, _d, _e, _f, a, div, link, old; + var _c, _d, _e, _f, _g, a, div, link, old; div = tag('div'); - _c = watched; - for (board in _c) { if (__hasProp.call(_c, board)) { - _e = watched[board]; - for (_d = 0, _f = _e.length; _d < _f; _d++) { - thread = _e[_d]; + _d = watched; + for (board in _d) { + if (!__hasProp.call(_d, board)) continue; + _c = _d[board]; + _f = watched[board]; + for (_e = 0, _g = _f.length; _e < _g; _e++) { + thread = _f[_e]; a = tag('a'); a.textContent = 'X'; a.className = 'pointer'; @@ -560,11 +580,11 @@ cursor: pointer; \ div.appendChild(document.createTextNode(' ')); link = tag('a'); link.textContent = thread.text; - link.href = ("/" + board + "/res/" + (thread.id)); + link.href = "/$board/res/${thread.id}"; div.appendChild(link); div.appendChild(tag('br')); } - }} + } old = $('#watcher div:last-child'); return replace(old, div); }; @@ -610,7 +630,7 @@ cursor: pointer; \ span = this; if (span.textContent[0] === '-') { num = board === 'b' ? 3 : 5; - table = x(("following::br[@clear][1]/preceding::table[" + num + "]"), span); + table = x("following::br[@clear][1]/preceding::table[$num]", span); while ((prev = table.previousSibling) && (prev.nodeName === 'TABLE')) { remove(prev); } @@ -630,7 +650,7 @@ cursor: pointer; \ r.onload = function() { return onloadThread(this.responseText, span); }; - r.open('GET', ("res/" + id), true); + r.open('GET', "res/$id", true); r.send(); return xhrs.push({ r: r, @@ -652,12 +672,13 @@ cursor: pointer; \ _f = replies; for (_e = 0, _g = _f.length; _e < _g; _e++) { reply = _f[_e]; - reply.id === id ? (html = $('blockquote', reply).innerHTML) : null; + if (reply.id === id) { + html = $('blockquote', reply).innerHTML; + }; } } bq = x('ancestor::blockquote', a); - bq.innerHTML = html; - return bq.innerHTML; + return (bq.innerHTML = html); }; expandComment = function(e) { var a, href; @@ -697,7 +718,7 @@ cursor: pointer; \ autoWatch = function() { var autoText; autoText = $('textarea', this).value.slice(0, 25); - return GM_setValue('autoText', ("/" + BOARD + "/ - " + autoText)); + return GM_setValue('autoText', "/$BOARD/ - $autoText"); }; stopPropagation = function(e) { return e.stopPropagation(); @@ -705,13 +726,11 @@ cursor: pointer; \ replyNav = function() { var direction, op; if (REPLY) { - window.location = this.textContent === '▲' ? '#navtop' : '#navbot'; - return window.location; + return (window.location = this.textContent === '▲' ? '#navtop' : '#navbot'); } else { direction = this.textContent === '▲' ? 'preceding' : 'following'; - op = x(("" + direction + "::span[starts-with(@id, 'nothread')][1]"), this).id; - window.location = ("#" + op); - return window.location; + op = x("$direction::span[starts-with(@id, 'nothread')][1]", this).id; + return (window.location = "#$op"); } }; text = $('#navtopr a').nextSibling; @@ -721,30 +740,32 @@ cursor: pointer; \ a.addEventListener('click', options, true); inBefore(text, document.createTextNode(' / ')); inBefore(text, a); - getValue('Reply Hiding') ? callbacks.push(function(root) { - var _c, _d, _e, _f, _g, _h, _i, _j, next, obj, td, tds; - tds = $$('td.doubledash', root); - _c = []; _e = tds; - for (_d = 0, _f = _e.length; _d < _f; _d++) { - td = _e[_d]; - _c.push((function() { - a = tag('a'); - a.textContent = '[ - ]'; - a.className = 'pointer'; - a.addEventListener('click', hideReply, true); - replace(td.firstChild, a); - next = td.nextSibling; - id = next.id; - _g = []; _i = hiddenReplies; - for (_h = 0, _j = _i.length; _h < _j; _h++) { - obj = _i[_h]; - _g.push(obj.id === id ? hideReply(next) : null); - } - return _g; - })()); - } - return _c; - }) : null; + if (getValue('Reply Hiding')) { + callbacks.push(function(root) { + var _c, _d, _e, _f, _g, _h, _i, _j, next, obj, td, tds; + tds = $$('td.doubledash', root); + _c = []; _e = tds; + for (_d = 0, _f = _e.length; _d < _f; _d++) { + td = _e[_d]; + _c.push((function() { + a = tag('a'); + a.textContent = '[ - ]'; + a.className = 'pointer'; + a.addEventListener('click', hideReply, true); + replace(td.firstChild, a); + next = td.nextSibling; + id = next.id; + _g = []; _i = hiddenReplies; + for (_h = 0, _j = _i.length; _h < _j; _h++) { + obj = _i[_h]; + _g.push(obj.id === id ? hideReply(next) : null); + } + return _g; + })()); + } + return _c; + }); + }; if (getValue('Quick Reply')) { iframe = tag('iframe'); hide(iframe); @@ -762,23 +783,25 @@ cursor: pointer; \ return _c; }); } - getValue('Quick Report') ? callbacks.push(function(root) { - var _c, _d, _e, _f, arr, el; - arr = $$('span[id^=no]', root); - _c = []; _e = arr; - for (_d = 0, _f = _e.length; _d < _f; _d++) { - el = _e[_d]; - _c.push((function() { - a = tag('a'); - a.textContent = '[ ! ]'; - a.className = 'pointer'; - a.addEventListener('click', report, true); - inAfter(el, a); - return inAfter(el, document.createTextNode(' ')); - })()); - } - return _c; - }) : null; + if (getValue('Quick Report')) { + callbacks.push(function(root) { + var _c, _d, _e, _f, arr, el; + arr = $$('span[id^=no]', root); + _c = []; _e = arr; + for (_d = 0, _f = _e.length; _d < _f; _d++) { + el = _e[_d]; + _c.push((function() { + a = tag('a'); + a.textContent = '[ ! ]'; + a.className = 'pointer'; + a.addEventListener('click', report, true); + inAfter(el, a); + return inAfter(el, document.createTextNode(' ')); + })()); + } + return _c; + }); + }; if (getValue('Thread Watcher')) { watcher = tag('div'); watcher.innerHTML = '
Thread Watcher
'; @@ -809,47 +832,51 @@ cursor: pointer; \ inBefore(input, img); } } - getValue('Anonymize') ? callbacks.push(function(root) { - var _i, _j, _k, _l, _m, _n, _o, name, names, trip, trips; - names = $$('span.postername, span.commentpostername', root); - _j = names; - for (_i = 0, _k = _j.length; _i < _k; _i++) { - name = _j[_i]; - name.innerHTML = 'Anonymous'; - } - trips = $$('span.postertrip', root); - _l = []; _n = trips; - for (_m = 0, _o = _n.length; _m < _o; _m++) { - trip = _n[_m]; - _l.push(trip.parentNode.nodeName === 'A' ? remove(trip.parentNode) : remove(trip)); - } - return _l; - }) : null; - getValue('Reply Navigation') ? callbacks.push(function(root) { - var _i, _j, _k, _l, arr, down, el, span, up; - arr = $$('span[id^=norep]', root); - _i = []; _k = arr; - for (_j = 0, _l = _k.length; _j < _l; _j++) { - el = _k[_j]; - _i.push((function() { - span = tag('span'); - up = tag('a'); - up.textContent = '▲'; - up.className = 'pointer'; - up.addEventListener('click', replyNav, true); - down = tag('a'); - down.textContent = '▼'; - down.className = 'pointer'; - down.addEventListener('click', replyNav, true); - span.appendChild(document.createTextNode(' ')); - span.appendChild(up); - span.appendChild(document.createTextNode(' ')); - span.appendChild(down); - return inAfter(el, span); - })()); - } - return _i; - }) : null; + if (getValue('Anonymize')) { + callbacks.push(function(root) { + var _i, _j, _k, _l, _m, _n, _o, name, names, trip, trips; + names = $$('span.postername, span.commentpostername', root); + _j = names; + for (_i = 0, _k = _j.length; _i < _k; _i++) { + name = _j[_i]; + name.innerHTML = 'Anonymous'; + } + trips = $$('span.postertrip', root); + _l = []; _n = trips; + for (_m = 0, _o = _n.length; _m < _o; _m++) { + trip = _n[_m]; + _l.push(trip.parentNode.nodeName === 'A' ? remove(trip.parentNode) : remove(trip)); + } + return _l; + }); + }; + if (getValue('Reply Navigation')) { + callbacks.push(function(root) { + var _i, _j, _k, _l, arr, down, el, span, up; + arr = $$('span[id^=norep]', root); + _i = []; _k = arr; + for (_j = 0, _l = _k.length; _j < _l; _j++) { + el = _k[_j]; + _i.push((function() { + span = tag('span'); + up = tag('a'); + up.textContent = '▲'; + up.className = 'pointer'; + up.addEventListener('click', replyNav, true); + down = tag('a'); + down.textContent = '▼'; + down.className = 'pointer'; + down.addEventListener('click', replyNav, true); + span.appendChild(document.createTextNode(' ')); + span.appendChild(up); + span.appendChild(document.createTextNode(' ')); + span.appendChild(down); + return inAfter(el, span); + })()); + } + return _i; + }); + }; if (!REPLY) { if (getValue('Thread Hiding')) { delform = $('form[name=delform]'); @@ -857,7 +884,9 @@ cursor: pointer; \ threadF(delform.firstChild); document.removeEventListener('DOMNodeInserted', stopPropagation, true); } - getValue('Auto Watch') ? $('form[name="post"]').addEventListener('submit', autoWatch, true) : null; + if (getValue('Auto Watch')) { + $('form[name="post"]').addEventListener('submit', autoWatch, true); + }; if (getValue('Thread Navigation')) { arr = $$('div > span.filesize, form > span.filesize'); i = 0; @@ -870,10 +899,10 @@ cursor: pointer; \ up.className = 'pointer'; if (i !== 0) { up.textContent = '▲'; - up.href = ("#" + i); + up.href = "#$i"; } else if (PAGENUM !== 0) { up.textContent = '◀'; - up.href = ("" + (PAGENUM - 1)); + up.href = "${PAGENUM - 1}"; } else { up.textContent = '▲'; up.href = "#navtop"; @@ -889,14 +918,16 @@ cursor: pointer; \ span.appendChild(down); if (i1 === l1) { down.textContent = '▶'; - down.href = ("" + (PAGENUM + 1) + "#1"); + down.href = "${PAGENUM + 1}#1"; } else { down.textContent = '▼'; - down.href = ("#" + i1); + down.href = "#$i1"; } inBefore(el, span); } - location.hash === '#1' ? (window.location = window.location) : null; + if (location.hash === '#1') { + window.location = window.location; + }; } if (getValue('Thread Expansion')) { omitted = $$('span.omittedposts'); @@ -905,7 +936,7 @@ cursor: pointer; \ span = _m[_l]; a = tag('a'); a.className = 'pointer omittedposts'; - a.textContent = ("+ " + (span.textContent)); + a.textContent = "+ ${span.textContent}"; a.addEventListener('click', expandThread, true); replace(span, a); }