don't rely on cs internal vars
This commit is contained in:
parent
ea0ace8537
commit
49bc2b96c2
@ -278,10 +278,10 @@ expandThread = ->
|
|||||||
|
|
||||||
getThread = ->
|
getThread = ->
|
||||||
threads = $$ 'div.thread'
|
threads = $$ 'div.thread'
|
||||||
for thread in threads
|
for thread, i in threads
|
||||||
bottom = thread.getBoundingClientRect().bottom
|
bottom = thread.getBoundingClientRect().bottom
|
||||||
if bottom > 0 #we have not scrolled past
|
if bottom > 0 #we have not scrolled past
|
||||||
return [thread, _i]
|
return [thread, i]
|
||||||
|
|
||||||
formSubmit = (e) ->
|
formSubmit = (e) ->
|
||||||
if span = @nextSibling
|
if span = @nextSibling
|
||||||
@ -468,10 +468,10 @@ keypress = (e) ->
|
|||||||
if e.shiftKey
|
if e.shiftKey
|
||||||
[thread] = getThread()
|
[thread] = getThread()
|
||||||
replies = $$ 'td[id]', thread
|
replies = $$ 'td[id]', thread
|
||||||
for reply in replies
|
for reply, i in replies
|
||||||
if reply.className is 'replyhl'
|
if reply.className is 'replyhl'
|
||||||
reply.className = 'reply'
|
reply.className = 'reply'
|
||||||
replies[_i+1]?.className = 'replyhl'
|
replies[i+1]?.className = 'replyhl'
|
||||||
return
|
return
|
||||||
replies[0].className = 'replyhl'
|
replies[0].className = 'replyhl'
|
||||||
else
|
else
|
||||||
@ -480,12 +480,12 @@ keypress = (e) ->
|
|||||||
if e.shiftKey
|
if e.shiftKey
|
||||||
[thread] = getThread()
|
[thread] = getThread()
|
||||||
replies = $$ 'td[id]', thread
|
replies = $$ 'td[id]', thread
|
||||||
for reply in replies
|
for reply, i in replies
|
||||||
if reply.className is 'replyhl'
|
if reply.className is 'replyhl'
|
||||||
reply.className = 'reply'
|
reply.className = 'reply'
|
||||||
replies[_i-1]?.className = 'replyhl'
|
replies[i-1]?.className = 'replyhl'
|
||||||
return
|
return
|
||||||
replies[_len-1].className = 'replyhl'
|
replies.pop().className = 'replyhl'
|
||||||
else
|
else
|
||||||
scroll count * -1
|
scroll count * -1
|
||||||
when "L"
|
when "L"
|
||||||
@ -1104,13 +1104,13 @@ else #not reply
|
|||||||
if getConfig 'Thread Navigation'
|
if getConfig 'Thread Navigation'
|
||||||
arr = $$ 'div > span.filesize, form > span.filesize'
|
arr = $$ 'div > span.filesize, form > span.filesize'
|
||||||
l1 = arr.length - 1
|
l1 = arr.length - 1
|
||||||
for el in arr
|
for el, i in arr
|
||||||
span = n 'span',
|
span = n 'span',
|
||||||
className: 'navlinks'
|
className: 'navlinks'
|
||||||
id: 'p' + _l
|
id: 'p' + i
|
||||||
if _l
|
if i
|
||||||
textContent = '▲'
|
textContent = '▲'
|
||||||
href = "#p#{_i - 1}"
|
href = "#p#{i - 1}"
|
||||||
else if g.PAGENUM
|
else if g.PAGENUM
|
||||||
textContent = '◀'
|
textContent = '◀'
|
||||||
href = "#{g.PAGENUM - 1}#p0"
|
href = "#{g.PAGENUM - 1}#p0"
|
||||||
@ -1121,9 +1121,9 @@ else #not reply
|
|||||||
className: 'pointer'
|
className: 'pointer'
|
||||||
textContent: textContent
|
textContent: textContent
|
||||||
href: href
|
href: href
|
||||||
if _l < l1
|
if i < l1
|
||||||
textContent = '▼'
|
textContent = '▼'
|
||||||
href = "#p#{_i + 1}"
|
href = "#p#{i + 1}"
|
||||||
else
|
else
|
||||||
textContent = '▶'
|
textContent = '▶'
|
||||||
href = "#{g.PAGENUM + 1}#p0"
|
href = "#{g.PAGENUM + 1}#p0"
|
||||||
|
|||||||
52
4chan_x.js
52
4chan_x.js
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var $, $$, AEOS, DAY, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expandComment, expandThread, form, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, id, iframe, iframeLoad, inAfter, inBefore, input, inputs, keybindAdd, keybindRem, keydown, keypress, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, scroll, show, showReply, showThread, slice, span, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _fn, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _len7, _m, _n, _o, _ref, _ref2, _ref3, _ref4;
|
var $, $$, AEOS, DAY, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expandComment, expandThread, form, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, i, id, iframe, iframeLoad, inAfter, inBefore, input, inputs, keybindAdd, keybindRem, keydown, keypress, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, scroll, show, showReply, showThread, slice, span, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _fn, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _len7, _m, _n, _ref, _ref2, _ref3, _ref4;
|
||||||
var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty, __indexOf = Array.prototype.indexOf || function(item) {
|
var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty, __indexOf = Array.prototype.indexOf || function(item) {
|
||||||
for (var i = 0, l = this.length; i < l; i++) {
|
for (var i = 0, l = this.length; i < l; i++) {
|
||||||
if (this[i] === item) return i;
|
if (this[i] === item) return i;
|
||||||
@ -357,13 +357,13 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
getThread = function() {
|
getThread = function() {
|
||||||
var bottom, thread, threads, _i, _len;
|
var bottom, i, thread, threads, _len;
|
||||||
threads = $$('div.thread');
|
threads = $$('div.thread');
|
||||||
for (_i = 0, _len = threads.length; _i < _len; _i++) {
|
for (i = 0, _len = threads.length; i < _len; i++) {
|
||||||
thread = threads[_i];
|
thread = threads[i];
|
||||||
bottom = thread.getBoundingClientRect().bottom;
|
bottom = thread.getBoundingClientRect().bottom;
|
||||||
if (bottom > 0) {
|
if (bottom > 0) {
|
||||||
return [thread, _i];
|
return [thread, i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -489,7 +489,7 @@
|
|||||||
return d.removeEventListener('keypress', keypress, true);
|
return d.removeEventListener('keypress', keypress, true);
|
||||||
};
|
};
|
||||||
keypress = function(e) {
|
keypress = function(e) {
|
||||||
var bot, char, count, hash, height, href, img, kc, next, prev, qrLink, rect, replies, reply, td, temp, thread, top, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref, _ref2;
|
var bot, char, count, hash, height, href, i, img, kc, next, prev, qrLink, rect, replies, reply, td, temp, thread, top, _i, _j, _len, _len2, _len3, _len4, _ref, _ref2;
|
||||||
kc = g.keyCode;
|
kc = g.keyCode;
|
||||||
if (kc === -1) {
|
if (kc === -1) {
|
||||||
return;
|
return;
|
||||||
@ -606,11 +606,11 @@
|
|||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
thread = getThread()[0];
|
thread = getThread()[0];
|
||||||
replies = $$('td[id]', thread);
|
replies = $$('td[id]', thread);
|
||||||
for (_k = 0, _len3 = replies.length; _k < _len3; _k++) {
|
for (i = 0, _len3 = replies.length; i < _len3; i++) {
|
||||||
reply = replies[_k];
|
reply = replies[i];
|
||||||
if (reply.className === 'replyhl') {
|
if (reply.className === 'replyhl') {
|
||||||
reply.className = 'reply';
|
reply.className = 'reply';
|
||||||
if ((_ref = replies[_i + 1]) != null) {
|
if ((_ref = replies[i + 1]) != null) {
|
||||||
_ref.className = 'replyhl';
|
_ref.className = 'replyhl';
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -625,17 +625,17 @@
|
|||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
thread = getThread()[0];
|
thread = getThread()[0];
|
||||||
replies = $$('td[id]', thread);
|
replies = $$('td[id]', thread);
|
||||||
for (_l = 0, _len4 = replies.length; _l < _len4; _l++) {
|
for (i = 0, _len4 = replies.length; i < _len4; i++) {
|
||||||
reply = replies[_l];
|
reply = replies[i];
|
||||||
if (reply.className === 'replyhl') {
|
if (reply.className === 'replyhl') {
|
||||||
reply.className = 'reply';
|
reply.className = 'reply';
|
||||||
if ((_ref2 = replies[_i - 1]) != null) {
|
if ((_ref2 = replies[i - 1]) != null) {
|
||||||
_ref2.className = 'replyhl';
|
_ref2.className = 'replyhl';
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return replies[_len - 1].className = 'replyhl';
|
return replies.pop().className = 'replyhl';
|
||||||
} else {
|
} else {
|
||||||
return scroll(count * -1);
|
return scroll(count * -1);
|
||||||
}
|
}
|
||||||
@ -1413,15 +1413,15 @@
|
|||||||
if (getConfig('Thread Navigation')) {
|
if (getConfig('Thread Navigation')) {
|
||||||
arr = $$('div > span.filesize, form > span.filesize');
|
arr = $$('div > span.filesize, form > span.filesize');
|
||||||
l1 = arr.length - 1;
|
l1 = arr.length - 1;
|
||||||
for (_l = 0, _len4 = arr.length; _l < _len4; _l++) {
|
for (i = 0, _len4 = arr.length; i < _len4; i++) {
|
||||||
el = arr[_l];
|
el = arr[i];
|
||||||
span = n('span', {
|
span = n('span', {
|
||||||
className: 'navlinks',
|
className: 'navlinks',
|
||||||
id: 'p' + _l
|
id: 'p' + i
|
||||||
});
|
});
|
||||||
if (_l) {
|
if (i) {
|
||||||
textContent = '▲';
|
textContent = '▲';
|
||||||
href = "#p" + (_i - 1);
|
href = "#p" + (i - 1);
|
||||||
} else if (g.PAGENUM) {
|
} else if (g.PAGENUM) {
|
||||||
textContent = '◀';
|
textContent = '◀';
|
||||||
href = "" + (g.PAGENUM - 1) + "#p0";
|
href = "" + (g.PAGENUM - 1) + "#p0";
|
||||||
@ -1434,9 +1434,9 @@
|
|||||||
textContent: textContent,
|
textContent: textContent,
|
||||||
href: href
|
href: href
|
||||||
});
|
});
|
||||||
if (_l < l1) {
|
if (i < l1) {
|
||||||
textContent = '▼';
|
textContent = '▼';
|
||||||
href = "#p" + (_i + 1);
|
href = "#p" + (i + 1);
|
||||||
} else {
|
} else {
|
||||||
textContent = '▶';
|
textContent = '▶';
|
||||||
href = "" + (g.PAGENUM + 1) + "#p0";
|
href = "" + (g.PAGENUM + 1) + "#p0";
|
||||||
@ -1455,8 +1455,8 @@
|
|||||||
}
|
}
|
||||||
if (getConfig('Thread Expansion')) {
|
if (getConfig('Thread Expansion')) {
|
||||||
omitted = $$('span.omittedposts');
|
omitted = $$('span.omittedposts');
|
||||||
for (_m = 0, _len5 = omitted.length; _m < _len5; _m++) {
|
for (_l = 0, _len5 = omitted.length; _l < _len5; _l++) {
|
||||||
span = omitted[_m];
|
span = omitted[_l];
|
||||||
a = n('a', {
|
a = n('a', {
|
||||||
className: 'pointer omittedposts',
|
className: 'pointer omittedposts',
|
||||||
textContent: "+ " + span.textContent,
|
textContent: "+ " + span.textContent,
|
||||||
@ -1467,15 +1467,15 @@
|
|||||||
}
|
}
|
||||||
if (getConfig('Comment Expansion')) {
|
if (getConfig('Comment Expansion')) {
|
||||||
as = $$('span.abbr a');
|
as = $$('span.abbr a');
|
||||||
for (_n = 0, _len6 = as.length; _n < _len6; _n++) {
|
for (_m = 0, _len6 = as.length; _m < _len6; _m++) {
|
||||||
a = as[_n];
|
a = as[_m];
|
||||||
a.addEventListener('click', expandComment, true);
|
a.addEventListener('click', expandComment, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ref4 = g.callbacks;
|
_ref4 = g.callbacks;
|
||||||
for (_o = 0, _len7 = _ref4.length; _o < _len7; _o++) {
|
for (_n = 0, _len7 = _ref4.length; _n < _len7; _n++) {
|
||||||
callback = _ref4[_o];
|
callback = _ref4[_n];
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
d.body.addEventListener('DOMNodeInserted', nodeInserted, true);
|
d.body.addEventListener('DOMNodeInserted', nodeInserted, true);
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
1.14.0
|
||||||
|
- reply keybinds: i, J, K
|
||||||
|
|
||||||
1.13.0
|
1.13.0
|
||||||
- localize time
|
- localize time
|
||||||
|
|
||||||
|
|||||||
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.13.0
|
// @version 1.14.0
|
||||||
// @copyright 2009, 2010 James Campos <james.r.campos@gmail.com>
|
// @copyright 2009, 2010 James Campos <james.r.campos@gmail.com>
|
||||||
// @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