diff --git a/4chan_x.user.js b/4chan_x.user.js index 244dec029..51d01c0c3 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -58,7 +58,7 @@ */ (function() { - var $, $$, DAY, Favicon, HOUR, MINUTE, NAMESPACE, Recaptcha, SECOND, Time, anonymize, conf, config, cooldown, d, expandComment, expandThread, firstRun, g, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher, _ref; + var $, $$, DAY, Favicon, HOUR, MINUTE, NAMESPACE, Recaptcha, SECOND, Time, anonymize, conf, config, cooldown, d, expandComment, expandThread, firstRun, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher, _ref; var __slice = Array.prototype.slice; config = { main: { @@ -300,13 +300,6 @@ return object; }; $.extend($, { - innerText: function(el) { - var span; - span = $.el('span', { - innerHTML: el.innerHTML.replace(/
/g, ' ') - }); - return span.textContent; - }, id: function(id) { return d.getElementById(id); }, @@ -1894,17 +1887,10 @@ return watcher.refresh(); }, watch: function(thread, id) { - var el, props, watched, _name; - el = $('span.filetitle', thread); - if (!el.textContent) { - el = $('blockquote', thread); - if (!el.textContent) { - el = $('span.postername', thread); - } - } + var props, watched, _name; props = { href: "/" + g.BOARD + "/res/" + id, - textContent: "/" + g.BOARD + "/ - " + ($.innerText(el).slice(0, 25)) + textContent: getTitle(thread) }; watched = $.get('watched', {}); watched[_name = g.BOARD] || (watched[_name] = {}); @@ -2087,17 +2073,23 @@ } } }; + getTitle = function(thread) { + var el, span; + el = $('span.filetitle', thread); + if (!el.textContent) { + el = $('blockquote', thread); + if (!el.textContent) { + el = $('span.postername', thread); + } + } + span = $.el('span', { + innerHTML: el.innerHTML.replace(/
/g, ' ') + }); + return "/" + g.BOARD + "/ - " + span.textContent; + }; titlePost = { init: function() { - var el; - el = $('span.filetitle'); - if (!el.textContent) { - el = $('blockquote'); - if (!el.textContent) { - return; - } - } - return d.title = "/" + g.BOARD + "/ - " + ($.innerText(el)); + return d.title = getTitle(); } }; quoteBacklink = { diff --git a/script.coffee b/script.coffee index 949b5250d..683be42a0 100644 --- a/script.coffee +++ b/script.coffee @@ -210,9 +210,6 @@ $.extend = (object, properties) -> object $.extend $, - innerText: (el) -> - span = $.el 'span', innerHTML: el.innerHTML.replace /
/g, ' ' - span.textContent id: (id) -> d.getElementById id globalEval: (code) -> @@ -1558,14 +1555,9 @@ watcher = watcher.refresh() watch: (thread, id) -> - el = $ 'span.filetitle', thread - if not el.textContent - el = $ 'blockquote', thread - if not el.textContent - el = $ 'span.postername', thread props = href: "/#{g.BOARD}/res/#{id}" - textContent: "/#{g.BOARD}/ - #{$.innerText(el)[...25]}" + textContent: getTitle thread watched = $.get 'watched', {} watched[g.BOARD] or= {} @@ -1673,14 +1665,18 @@ Time = P: -> if Time.date.getHours() < 12 then 'am' else 'pm' y: -> Time.date.getFullYear() - 2000 +getTitle = (thread) -> + el = $ 'span.filetitle', thread + if not el.textContent + el = $ 'blockquote', thread + if not el.textContent + el = $ 'span.postername', thread + span = $.el 'span', innerHTML: el.innerHTML.replace /
/g, ' ' + "/#{g.BOARD}/ - #{span.textContent}" + titlePost = init: -> - el = $ 'span.filetitle' - if not el.textContent - el = $ 'blockquote' - if not el.textContent - return - d.title = "/#{g.BOARD}/ - #{$.innerText el}" + d.title = getTitle() quoteBacklink = init: ->