fix thread watching
leaky variables in for loop
This commit is contained in:
parent
3d4380494f
commit
ddf9440a8f
@ -28,7 +28,7 @@ config =
|
|||||||
AEOS =
|
AEOS =
|
||||||
init: ->
|
init: ->
|
||||||
#x-browser
|
#x-browser
|
||||||
if typeof GM_deleteValue is 'undefined'
|
unless GM_deleteValue?
|
||||||
window.GM_setValue = (name, value) ->
|
window.GM_setValue = (name, value) ->
|
||||||
value = (typeof value)[0] + value
|
value = (typeof value)[0] + value
|
||||||
localStorage.setItem name, value
|
localStorage.setItem name, value
|
||||||
@ -610,8 +610,8 @@ watch = ->
|
|||||||
|
|
||||||
|
|
||||||
watchX = ->
|
watchX = ->
|
||||||
[board, _, id] =
|
[board, _, id] = @nextElementSibling.
|
||||||
this.nextElementSibling.getAttribute('href').substring(1).split('/')
|
getAttribute('href').substring(1).split('/')
|
||||||
watched[board] = slice(watched[board], id)
|
watched[board] = slice(watched[board], id)
|
||||||
GM_setValue('watched', JSON.stringify(watched))
|
GM_setValue('watched', JSON.stringify(watched))
|
||||||
watcherUpdate()
|
watcherUpdate()
|
||||||
@ -743,6 +743,7 @@ nodeInserted = (e) ->
|
|||||||
|
|
||||||
|
|
||||||
autoWatch = ->
|
autoWatch = ->
|
||||||
|
#TODO look for subject
|
||||||
autoText = $('textarea', this).value.slice(0, 25)
|
autoText = $('textarea', this).value.slice(0, 25)
|
||||||
GM_setValue('autoText', "/#{BOARD}/ - #{autoText}")
|
GM_setValue('autoText', "/#{BOARD}/ - #{autoText}")
|
||||||
|
|
||||||
@ -776,6 +777,12 @@ redirect = ->
|
|||||||
url = "http://boards.4chan.org/#{BOARD}"
|
url = "http://boards.4chan.org/#{BOARD}"
|
||||||
location.href = url
|
location.href = url
|
||||||
|
|
||||||
|
checkWatched = (id) ->
|
||||||
|
for thread in threads
|
||||||
|
if id is thread.id
|
||||||
|
return favNormal
|
||||||
|
favEmpty
|
||||||
|
|
||||||
#main part 2...
|
#main part 2...
|
||||||
if navtopr = $ '#navtopr a'
|
if navtopr = $ '#navtopr a'
|
||||||
text = navtopr.nextSibling #css doesn't see text nodes
|
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"]')
|
inputs = $$('form > input[value="delete"], div > input[value="delete"]')
|
||||||
for input in inputs
|
for input in inputs
|
||||||
id = input.name
|
id = input.name
|
||||||
for thread in threads
|
src = checkWatched id
|
||||||
if id == thread.id
|
|
||||||
src = favNormal
|
|
||||||
break
|
|
||||||
src or= favEmpty
|
|
||||||
img = n 'img',
|
img = n 'img',
|
||||||
src: src
|
src: checkWatched id
|
||||||
className: 'pointer'
|
className: 'pointer'
|
||||||
listener: ['click', watch]
|
listener: ['click', watch]
|
||||||
inBefore input, img
|
inBefore input, img
|
||||||
|
|||||||
49
4chan_x.js
49
4chan_x.js
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(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;
|
var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty;
|
||||||
config = {
|
config = {
|
||||||
'Thread Hiding': [true, 'Hide entire threads'],
|
'Thread Hiding': [true, 'Hide entire threads'],
|
||||||
@ -21,7 +21,7 @@
|
|||||||
};
|
};
|
||||||
AEOS = {
|
AEOS = {
|
||||||
init: function() {
|
init: function() {
|
||||||
if (typeof GM_deleteValue === 'undefined') {
|
if (!(typeof GM_deleteValue !== "undefined" && GM_deleteValue !== null)) {
|
||||||
window.GM_setValue = function(name, value) {
|
window.GM_setValue = function(name, value) {
|
||||||
value = (typeof value)[0] + value;
|
value = (typeof value)[0] + value;
|
||||||
return localStorage.setItem(name, value);
|
return localStorage.setItem(name, value);
|
||||||
@ -890,6 +890,17 @@
|
|||||||
}
|
}
|
||||||
return (location.href = url);
|
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')) {
|
if (navtopr = $('#navtopr a')) {
|
||||||
text = navtopr.nextSibling;
|
text = navtopr.nextSibling;
|
||||||
a = n('a', {
|
a = n('a', {
|
||||||
@ -1035,17 +1046,9 @@
|
|||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
input = _ref[_i];
|
input = _ref[_i];
|
||||||
id = input.name;
|
id = input.name;
|
||||||
_ref2 = threads;
|
src = checkWatched(id);
|
||||||
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
|
||||||
thread = _ref2[_j];
|
|
||||||
if (id === thread.id) {
|
|
||||||
src = favNormal;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
src || (src = favEmpty);
|
|
||||||
img = n('img', {
|
img = n('img', {
|
||||||
src: src,
|
src: checkWatched(id),
|
||||||
className: 'pointer',
|
className: 'pointer',
|
||||||
listener: ['click', watch]
|
listener: ['click', watch]
|
||||||
});
|
});
|
||||||
@ -1054,17 +1057,17 @@
|
|||||||
}
|
}
|
||||||
if (getConfig('Anonymize')) {
|
if (getConfig('Anonymize')) {
|
||||||
callbacks.push(function(root) {
|
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);
|
names = $$('span.postername, span.commentpostername', root);
|
||||||
_ref3 = names;
|
_ref2 = names;
|
||||||
for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) {
|
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
||||||
name = _ref3[_k];
|
name = _ref2[_j];
|
||||||
name.innerHTML = 'Anonymous';
|
name.innerHTML = 'Anonymous';
|
||||||
}
|
}
|
||||||
trips = $$('span.postertrip', root);
|
trips = $$('span.postertrip', root);
|
||||||
_result = []; _ref3 = trips;
|
_result = []; _ref2 = trips;
|
||||||
for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) {
|
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
||||||
trip = _ref3[_k];
|
trip = _ref2[_j];
|
||||||
_result.push(trip.parentNode.nodeName === 'A' ? remove(trip.parentNode) : remove(trip));
|
_result.push(trip.parentNode.nodeName === 'A' ? remove(trip.parentNode) : remove(trip));
|
||||||
}
|
}
|
||||||
return _result;
|
return _result;
|
||||||
@ -1072,11 +1075,11 @@
|
|||||||
}
|
}
|
||||||
if (getConfig('Reply Navigation')) {
|
if (getConfig('Reply Navigation')) {
|
||||||
callbacks.push(function(root) {
|
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);
|
arr = $$('span[id^=norep]', root);
|
||||||
_result = []; _ref3 = arr;
|
_result = []; _ref2 = arr;
|
||||||
for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) {
|
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
||||||
el = _ref3[_k];
|
el = _ref2[_j];
|
||||||
_result.push((function() {
|
_result.push((function() {
|
||||||
span = n('span');
|
span = n('span');
|
||||||
up = n('a', {
|
up = n('a', {
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
1.7.3
|
||||||
|
- fix thread watching
|
||||||
|
|
||||||
1.7.3
|
1.7.3
|
||||||
- fixed descriptions
|
- fixed descriptions
|
||||||
|
|
||||||
|
|||||||
2
readme
2
readme
@ -2,7 +2,7 @@
|
|||||||
// @name 4chan x
|
// @name 4chan x
|
||||||
// @namespace aeosynth
|
// @namespace aeosynth
|
||||||
// @description Adds various features.
|
// @description Adds various features.
|
||||||
// @version 1.7.3
|
// @version 1.7.4
|
||||||
// @copyright 2009, 2010 James Campos
|
// @copyright 2009, 2010 James Campos
|
||||||
// @license MIT; http://en.wikipedia.org/wiki/Mit_license
|
// @license MIT; http://en.wikipedia.org/wiki/Mit_license
|
||||||
// @include http://boards.4chan.org/*
|
// @include http://boards.4chan.org/*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user