From 5bfb3d4c18d5949d09180dd3ef9004dbc41b0c61 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 4 Feb 2012 20:06:51 +0100 Subject: [PATCH] A bit of random cleaning. --- 4chan_x.user.js | 19 ++++++++----------- script.coffee | 21 +++++++++------------ 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8142ef40e..b6d854186 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2756,8 +2756,8 @@ quoteBacklink = { init: function() { var format; - format = conf['backlink'].replace(/%id/, "' + id + '"); - quoteBacklink.funk = Function('id', "return'" + format + "'"); + format = conf['backlink'].replace(/%id/g, "' + id + '"); + quoteBacklink.funk = Function('id', "return '" + format + "'"); return g.callbacks.push(function(root) { var a, container, el, id, link, qid, quote, quotes, _i, _len, _ref, _results; if (/\binline\b/.test(root.className)) return; @@ -2765,7 +2765,7 @@ _ref = $$('.quotelink', root); for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; - if (qid = quote.hash.slice(1)) quotes[qid] = quote; + if (qid = quote.hash.slice(1)) quotes[qid] = true; } id = $('input', root).name; a = $.el('a', { @@ -2775,8 +2775,9 @@ }); _results = []; for (qid in quotes) { - if (!(el = $.id(qid))) continue; - if (el.className === 'op' && !conf['OP Backlinks']) continue; + if (!(el = $.id(qid)) || el.className === 'op' && !conf['OP Backlinks']) { + continue; + } link = a.cloneNode(true); if (conf['Quote Preview']) { $.on(link, 'mouseover', quotePreview.mouseover); @@ -3178,15 +3179,11 @@ empty: 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==', dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==', update: function() { - var clone, favicon, l; + var favicon, l; l = unread.replies.length; favicon = $('link[rel="shortcut icon"]', d.head); favicon.href = g.dead ? l ? this.unreadDead : this.dead : l ? this.unread : this["default"]; - if (engine !== 'webkit') { - clone = favicon.cloneNode(true); - favicon.href = null; - return $.replace(favicon, clone); - } + if (engine !== 'webkit') return $.add(d.head, $.rm(favicon)); } }; diff --git a/script.coffee b/script.coffee index 9441d6b34..06b0c84df 100644 --- a/script.coffee +++ b/script.coffee @@ -2157,26 +2157,25 @@ titlePost = quoteBacklink = init: -> - format = conf['backlink'].replace /%id/, "' + id + '" - quoteBacklink.funk = Function 'id', "return'#{format}'" + format = conf['backlink'].replace /%id/g, "' + id + '" + quoteBacklink.funk = Function 'id', "return '#{format}'" g.callbacks.push (root) -> return if /\binline\b/.test root.className quotes = {} for quote in $$ '.quotelink', root - #don't process >>>/b/ + # Don't process >>>/b/. if qid = quote.hash[1..] - #duplicate quotes get overwritten - quotes[qid] = quote - # op or reply + # Duplicate quotes get overwritten. + quotes[qid] = true + # OP or reply id. id = $('input', root).name a = $.el 'a', href: "##{id}" className: if root.hidden then 'filtered backlink' else 'backlink' textContent: quoteBacklink.funk id for qid of quotes - continue unless el = $.id qid - #don't backlink the op - continue if el.className is 'op' and !conf['OP Backlinks'] + # Don't backlink the OP. + continue if !(el = $.id qid) or el.className is 'op' and !conf['OP Backlinks'] link = a.cloneNode true if conf['Quote Preview'] $.on link, 'mouseover', quotePreview.mouseover @@ -2472,9 +2471,7 @@ Favicon = #`favicon.href = href` isn't enough on Opera #Opera won't always update the favicon if the href do not change if engine isnt 'webkit' - clone = favicon.cloneNode true - favicon.href = null - $.replace favicon, clone + $.add d.head, $.rm favicon redirect = init: ->