diff --git a/4chan_x.coffee b/4chan_x.coffee index b139b9c61..eb3b624e5 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -28,7 +28,7 @@ config = AEOS = init: -> #x-browser - if typeof GM_deleteValue is 'undefined' + unless GM_deleteValue? window.GM_setValue = (name, value) -> value = (typeof value)[0] + value localStorage.setItem name, value @@ -610,8 +610,8 @@ watch = -> watchX = -> - [board, _, id] = - this.nextElementSibling.getAttribute('href').substring(1).split('/') + [board, _, id] = @nextElementSibling. + getAttribute('href').substring(1).split('/') watched[board] = slice(watched[board], id) GM_setValue('watched', JSON.stringify(watched)) watcherUpdate() @@ -743,6 +743,7 @@ nodeInserted = (e) -> autoWatch = -> + #TODO look for subject autoText = $('textarea', this).value.slice(0, 25) GM_setValue('autoText', "/#{BOARD}/ - #{autoText}") @@ -776,6 +777,12 @@ 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 @@ -878,13 +885,9 @@ if getConfig 'Thread Watcher' inputs = $$('form > input[value="delete"], div > input[value="delete"]') for input in inputs id = input.name - for thread in threads - if id == thread.id - src = favNormal - break - src or= favEmpty + src = checkWatched id img = n 'img', - src: src + src: checkWatched id className: 'pointer' listener: ['click', watch] inBefore input, img diff --git a/4chan_x.js b/4chan_x.js index 2327731ce..bb1ee96f9 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1,5 +1,5 @@ (function() { - var $, $$, AEOS, BOARD, DAY, PAGENUM, REPLY, THREAD_ID, _, _i, _j, _len, _len2, _ref, _ref2, 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, 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, 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 __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty; config = { 'Thread Hiding': [true, 'Hide entire threads'], @@ -21,7 +21,7 @@ }; AEOS = { init: function() { - if (typeof GM_deleteValue === 'undefined') { + if (!(typeof GM_deleteValue !== "undefined" && GM_deleteValue !== null)) { window.GM_setValue = function(name, value) { value = (typeof value)[0] + value; return localStorage.setItem(name, value); @@ -890,6 +890,17 @@ } 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', { @@ -1035,17 +1046,9 @@ for (_i = 0, _len = _ref.length; _i < _len; _i++) { input = _ref[_i]; id = input.name; - _ref2 = threads; - for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { - thread = _ref2[_j]; - if (id === thread.id) { - src = favNormal; - break; - } - } - src || (src = favEmpty); + src = checkWatched(id); img = n('img', { - src: src, + src: checkWatched(id), className: 'pointer', listener: ['click', watch] }); @@ -1054,17 +1057,17 @@ } if (getConfig('Anonymize')) { callbacks.push(function(root) { - var _k, _len3, _ref3, _result, name, names, trip, trips; + var _j, _len2, _ref2, _result, name, names, trip, trips; names = $$('span.postername, span.commentpostername', root); - _ref3 = names; - for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) { - name = _ref3[_k]; + _ref2 = names; + for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { + name = _ref2[_j]; name.innerHTML = 'Anonymous'; } trips = $$('span.postertrip', root); - _result = []; _ref3 = trips; - for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) { - trip = _ref3[_k]; + _result = []; _ref2 = trips; + for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { + trip = _ref2[_j]; _result.push(trip.parentNode.nodeName === 'A' ? remove(trip.parentNode) : remove(trip)); } return _result; @@ -1072,11 +1075,11 @@ } if (getConfig('Reply Navigation')) { callbacks.push(function(root) { - var _k, _len3, _ref3, _result, arr, down, el, span, up; + var _j, _len2, _ref2, _result, arr, down, el, span, up; arr = $$('span[id^=norep]', root); - _result = []; _ref3 = arr; - for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) { - el = _ref3[_k]; + _result = []; _ref2 = arr; + for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { + el = _ref2[_j]; _result.push((function() { span = n('span'); up = n('a', { diff --git a/changelog b/changelog index 131f646bd..6b0b9680e 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +1.7.3 +- fix thread watching + 1.7.3 - fixed descriptions diff --git a/readme b/readme index 32bfe6558..14b268e9c 100644 --- a/readme +++ b/readme @@ -2,7 +2,7 @@ // @name 4chan x // @namespace aeosynth // @description Adds various features. -// @version 1.7.3 +// @version 1.7.4 // @copyright 2009, 2010 James Campos // @license MIT; http://en.wikipedia.org/wiki/Mit_license // @include http://boards.4chan.org/*