From 162988ace5d460636deeb3def53891f6f49a0d5c Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 8 Nov 2010 09:23:11 -0800 Subject: [PATCH] anonymize checkWatched --- 4chan_x.coffee | 15 +++++++-------- 4chan_x.js | 44 +++++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/4chan_x.coffee b/4chan_x.coffee index eb3b624e5..dec540f74 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -777,12 +777,6 @@ redirect = -> url = "http://boards.4chan.org/#{BOARD}" location.href = url -checkWatched = (id) -> - for thread in threads - if id is thread.id - return favNormal - favEmpty - #main part 2... if navtopr = $ '#navtopr a' text = navtopr.nextSibling #css doesn't see text nodes @@ -885,9 +879,14 @@ if getConfig 'Thread Watcher' inputs = $$('form > input[value="delete"], div > input[value="delete"]') for input in inputs id = input.name - src = checkWatched id + src = (-> + for thread in threads + if id is thread.id + return favNormal + favEmpty + )() img = n 'img', - src: checkWatched id + src: src className: 'pointer' listener: ['click', watch] inBefore input, img diff --git a/4chan_x.js b/4chan_x.js index bb1ee96f9..ee594a08a 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1,5 +1,5 @@ (function() { - var $, $$, AEOS, BOARD, DAY, PAGENUM, REPLY, THREAD_ID, _, _i, _len, _ref, a, addTo, arr, as, autoWatch, autohide, b, board, callback, callbacks, checkWatched, clearHidden, close, config, cooldown, cutoff, d, defaultSaucePrefix, delform, down, editSauce, el, expandComment, expandThread, favEmpty, favNormal, favicon, getConfig, getTime, head, hiddenReplies, hiddenThreads, hide, hideReply, hideThread, href, html, i, i1, id, iframe, iframeLoad, iframeLoop, img, inAfter, inBefore, input, inputs, l, l1, lastChecked, magic, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, quickReply, r, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, show, showReply, showThread, slice, span, src, stopPropagation, submit, text, textContent, thread, threadF, threads, tn, up, watch, watchX, watched, watcher, watcherUpdate, x, xhrs; + var $, $$, AEOS, BOARD, DAY, PAGENUM, REPLY, THREAD_ID, _, _i, _len, _ref, a, addTo, arr, as, autoWatch, autohide, b, board, callback, callbacks, clearHidden, close, config, cooldown, cutoff, d, defaultSaucePrefix, delform, down, editSauce, el, expandComment, expandThread, favEmpty, favNormal, favicon, getConfig, getTime, head, hiddenReplies, hiddenThreads, hide, hideReply, hideThread, href, html, i, i1, id, iframe, iframeLoad, iframeLoop, inAfter, inBefore, inputs, l, l1, lastChecked, magic, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, quickReply, r, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, show, showReply, showThread, slice, span, stopPropagation, submit, text, textContent, thread, threadF, threads, tn, up, watch, watchX, watched, watcher, watcherUpdate, x, xhrs; var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty; config = { 'Thread Hiding': [true, 'Hide entire threads'], @@ -890,17 +890,6 @@ } return (location.href = url); }; - checkWatched = function(id) { - var _i, _len, _ref2, thread; - _ref2 = threads; - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - thread = _ref2[_i]; - if (id === thread.id) { - return favNormal; - } - } - return favEmpty; - }; if (navtopr = $('#navtopr a')) { text = navtopr.nextSibling; a = n('a', { @@ -1044,15 +1033,28 @@ inputs = $$('form > input[value="delete"], div > input[value="delete"]'); _ref = inputs; for (_i = 0, _len = _ref.length; _i < _len; _i++) { - input = _ref[_i]; - id = input.name; - src = checkWatched(id); - img = n('img', { - src: checkWatched(id), - className: 'pointer', - listener: ['click', watch] - }); - inBefore(input, img); + (function() { + var img, src; + var input = _ref[_i]; + id = input.name; + src = (function() { + var _j, _len2, _ref2, thread; + _ref2 = threads; + for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { + thread = _ref2[_j]; + if (id === thread.id) { + return favNormal; + } + } + return favEmpty; + })(); + img = n('img', { + src: src, + className: 'pointer', + listener: ['click', watch] + }); + return inBefore(input, img); + })(); } } if (getConfig('Anonymize')) {