addTo - looped appendChild.
This commit is contained in:
parent
61027052c4
commit
891da9f451
@ -30,6 +30,9 @@ $$ = (selector, root) ->
|
|||||||
result = root.querySelectorAll(selector)
|
result = root.querySelectorAll(selector)
|
||||||
#magic that turns the results object into an array:
|
#magic that turns the results object into an array:
|
||||||
node for node in result
|
node for node in result
|
||||||
|
addTo = (parent, children...) ->
|
||||||
|
for child in children
|
||||||
|
parent.appendChild child
|
||||||
getConfig = (name) ->
|
getConfig = (name) ->
|
||||||
GM_getValue(name, config[name])
|
GM_getValue(name, config[name])
|
||||||
getTime = ->
|
getTime = ->
|
||||||
@ -73,6 +76,8 @@ slice = (arr, id) ->
|
|||||||
i++
|
i++
|
||||||
tag = (el) ->
|
tag = (el) ->
|
||||||
document.createElement(el)
|
document.createElement(el)
|
||||||
|
tn = (s) ->
|
||||||
|
document.createTextNode s
|
||||||
x = (path, root) ->
|
x = (path, root) ->
|
||||||
root or= document.body
|
root or= document.body
|
||||||
document.
|
document.
|
||||||
@ -807,19 +812,18 @@ if getConfig('Reply Navigation')
|
|||||||
callbacks.push((root) ->
|
callbacks.push((root) ->
|
||||||
arr = $$('span[id^=norep]', root)
|
arr = $$('span[id^=norep]', root)
|
||||||
for el in arr
|
for el in arr
|
||||||
span = tag('span')
|
span = n 'span'
|
||||||
up = tag('a')
|
up = n 'a', {
|
||||||
up.textContent = '▲'
|
textContent: '▲'
|
||||||
up.className = 'pointer'
|
className: 'pointer'
|
||||||
|
}
|
||||||
up.addEventListener('click', replyNav, true)
|
up.addEventListener('click', replyNav, true)
|
||||||
down = tag('a')
|
down = n 'a', {
|
||||||
down.textContent = '▼'
|
textContent: '▼'
|
||||||
down.className = 'pointer'
|
className: 'pointer'
|
||||||
|
}
|
||||||
down.addEventListener('click', replyNav, true)
|
down.addEventListener('click', replyNav, true)
|
||||||
span.appendChild(document.createTextNode(' '))
|
addTo span, tn(' '), up, tn(' '), down
|
||||||
span.appendChild(up)
|
|
||||||
span.appendChild(document.createTextNode(' '))
|
|
||||||
span.appendChild(down)
|
|
||||||
inAfter(el, span)
|
inAfter(el, span)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
104
4chan_x.js
104
4chan_x.js
@ -1,6 +1,6 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var $, $$, BOARD, DAY, PAGENUM, REPLY, _i, _j, _len, _len2, _ref, _ref2, a, arr, as, autoWatch, autohide, b, board, callback, callbacks, clearHidden, close, config, cutoff, delform, down, el, expandComment, expandThread, favEmpty, favNormal, favicon, getConfig, getTime, head, hiddenReplies, hiddenThreads, hide, hideReply, hideThread, html, i, i1, id, iframe, iframeLoad, iframeLoop, img, inAfter, inBefore, input, inputs, l, l1, lastChecked, magic, mousedown, mousemove, mouseup, move, n, navtopr, nodeInserted, nop, now, omitted, onloadComment, onloadThread, options, optionsSave, parseResponse, position, quickReply, r, remove, replace, replyNav, report, show, showReply, showThread, slice, span, stopPropagation, submit, tag, text, thread, threadF, threads, up, watch, watchX, watched, watcher, watcherUpdate, x, xhrs;
|
var $, $$, BOARD, DAY, PAGENUM, REPLY, _i, _j, _len, _len2, _ref, _ref2, a, addTo, arr, as, autoWatch, autohide, b, board, callback, callbacks, clearHidden, close, config, cutoff, delform, down, el, expandComment, expandThread, favEmpty, favNormal, favicon, getConfig, getTime, head, hiddenReplies, hiddenThreads, hide, hideReply, hideThread, html, i, i1, id, iframe, iframeLoad, iframeLoop, img, inAfter, inBefore, input, inputs, l, l1, lastChecked, magic, mousedown, mousemove, mouseup, move, n, navtopr, nodeInserted, nop, now, omitted, onloadComment, onloadThread, options, optionsSave, parseResponse, position, quickReply, r, remove, replace, replyNav, report, show, showReply, showThread, slice, span, stopPropagation, submit, tag, text, thread, threadF, threads, tn, up, watch, watchX, watched, watcher, watcherUpdate, x, xhrs;
|
||||||
var __hasProp = Object.prototype.hasOwnProperty;
|
var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty;
|
||||||
config = {
|
config = {
|
||||||
'Thread Hiding': true,
|
'Thread Hiding': true,
|
||||||
'Reply Hiding': true,
|
'Reply Hiding': true,
|
||||||
@ -16,13 +16,6 @@
|
|||||||
'Auto Watch': true,
|
'Auto Watch': true,
|
||||||
'Anonymize': false
|
'Anonymize': false
|
||||||
};
|
};
|
||||||
getConfig = function(name) {
|
|
||||||
return GM_getValue(name, config[name]);
|
|
||||||
};
|
|
||||||
x = function(path, root) {
|
|
||||||
root || (root = document.body);
|
|
||||||
return document.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
|
|
||||||
};
|
|
||||||
$ = function(selector, root) {
|
$ = function(selector, root) {
|
||||||
root || (root = document.body);
|
root || (root = document.body);
|
||||||
return root.querySelector(selector);
|
return root.querySelector(selector);
|
||||||
@ -38,29 +31,30 @@
|
|||||||
}
|
}
|
||||||
return _result;
|
return _result;
|
||||||
};
|
};
|
||||||
inBefore = function(root, el) {
|
addTo = function(parent) {
|
||||||
return root.parentNode.insertBefore(el, root);
|
var _i, _len, _ref, _result, child, children;
|
||||||
|
children = __slice.call(arguments, 1);
|
||||||
|
_result = []; _ref = children;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
child = _ref[_i];
|
||||||
|
_result.push(parent.appendChild(child));
|
||||||
|
}
|
||||||
|
return _result;
|
||||||
};
|
};
|
||||||
inAfter = function(root, el) {
|
getConfig = function(name) {
|
||||||
return root.parentNode.insertBefore(el, root.nextSibling);
|
return GM_getValue(name, config[name]);
|
||||||
};
|
};
|
||||||
tag = function(el) {
|
getTime = function() {
|
||||||
return document.createElement(el);
|
return Math.floor(new Date().getTime() / 1000);
|
||||||
};
|
};
|
||||||
hide = function(el) {
|
hide = function(el) {
|
||||||
return (el.style.display = 'none');
|
return (el.style.display = 'none');
|
||||||
};
|
};
|
||||||
show = function(el) {
|
inAfter = function(root, el) {
|
||||||
return (el.style.display = '');
|
return root.parentNode.insertBefore(el, root.nextSibling);
|
||||||
};
|
};
|
||||||
remove = function(el) {
|
inBefore = function(root, el) {
|
||||||
return el.parentNode.removeChild(el);
|
return root.parentNode.insertBefore(el, root);
|
||||||
};
|
|
||||||
replace = function(root, el) {
|
|
||||||
return root.parentNode.replaceChild(el, root);
|
|
||||||
};
|
|
||||||
getTime = function() {
|
|
||||||
return Math.floor(new Date().getTime() / 1000);
|
|
||||||
};
|
};
|
||||||
n = function(tag, props) {
|
n = function(tag, props) {
|
||||||
var _ref, el, key, val;
|
var _ref, el, key, val;
|
||||||
@ -75,6 +69,25 @@
|
|||||||
}
|
}
|
||||||
return el;
|
return el;
|
||||||
};
|
};
|
||||||
|
position = function(el) {
|
||||||
|
var id, left, top;
|
||||||
|
id = el.id;
|
||||||
|
if (left = GM_getValue("" + (id) + "Left", '0px')) {
|
||||||
|
el.style.left = left;
|
||||||
|
} else {
|
||||||
|
el.style.right = '0px';
|
||||||
|
}
|
||||||
|
return (top = GM_getValue("" + (id) + "Top", '0px')) ? (el.style.top = top) : (el.style.bottom = '0px');
|
||||||
|
};
|
||||||
|
remove = function(el) {
|
||||||
|
return el.parentNode.removeChild(el);
|
||||||
|
};
|
||||||
|
replace = function(root, el) {
|
||||||
|
return root.parentNode.replaceChild(el, root);
|
||||||
|
};
|
||||||
|
show = function(el) {
|
||||||
|
return (el.style.display = '');
|
||||||
|
};
|
||||||
slice = function(arr, id) {
|
slice = function(arr, id) {
|
||||||
var _result, i, l;
|
var _result, i, l;
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -89,15 +102,15 @@
|
|||||||
}
|
}
|
||||||
return _result;
|
return _result;
|
||||||
};
|
};
|
||||||
position = function(el) {
|
tag = function(el) {
|
||||||
var id, left, top;
|
return document.createElement(el);
|
||||||
id = el.id;
|
};
|
||||||
if (left = GM_getValue("" + (id) + "Left", '0px')) {
|
tn = function(s) {
|
||||||
el.style.left = left;
|
return document.createTextNode(s);
|
||||||
} else {
|
};
|
||||||
el.style.right = '0px';
|
x = function(path, root) {
|
||||||
}
|
root || (root = document.body);
|
||||||
return (top = GM_getValue("" + (id) + "Top", '0px')) ? (el.style.top = top) : (el.style.bottom = '0px');
|
return document.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
|
||||||
};
|
};
|
||||||
if (typeof GM_deleteValue === 'undefined') {
|
if (typeof GM_deleteValue === 'undefined') {
|
||||||
this.GM_setValue = function(name, value) {
|
this.GM_setValue = function(name, value) {
|
||||||
@ -134,7 +147,7 @@
|
|||||||
GM_setValue('error', b.firstChild.textContent);
|
GM_setValue('error', b.firstChild.textContent);
|
||||||
} else {
|
} else {
|
||||||
GM_setValue('error', '');
|
GM_setValue('error', '');
|
||||||
if (GM_getValue('Auto Watch')) {
|
if (getConfig('Auto Watch')) {
|
||||||
html = $('b').innerHTML;
|
html = $('b').innerHTML;
|
||||||
_ref = html.match(/<!-- thread:(\d+),no:(\d+) -->/);
|
_ref = html.match(/<!-- thread:(\d+),no:(\d+) -->/);
|
||||||
nop = _ref[0];
|
nop = _ref[0];
|
||||||
@ -904,19 +917,18 @@
|
|||||||
for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) {
|
for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) {
|
||||||
el = _ref3[_k];
|
el = _ref3[_k];
|
||||||
_result.push((function() {
|
_result.push((function() {
|
||||||
span = tag('span');
|
span = n('span');
|
||||||
up = tag('a');
|
up = n('a', {
|
||||||
up.textContent = '▲';
|
textContent: '▲',
|
||||||
up.className = 'pointer';
|
className: 'pointer'
|
||||||
|
});
|
||||||
up.addEventListener('click', replyNav, true);
|
up.addEventListener('click', replyNav, true);
|
||||||
down = tag('a');
|
down = n('a', {
|
||||||
down.textContent = '▼';
|
textContent: '▼',
|
||||||
down.className = 'pointer';
|
className: 'pointer'
|
||||||
|
});
|
||||||
down.addEventListener('click', replyNav, true);
|
down.addEventListener('click', replyNav, true);
|
||||||
span.appendChild(document.createTextNode(' '));
|
addTo(span, tn(' '), up, tn(' '), down);
|
||||||
span.appendChild(up);
|
|
||||||
span.appendChild(document.createTextNode(' '));
|
|
||||||
span.appendChild(down);
|
|
||||||
return inAfter(el, span);
|
return inAfter(el, span);
|
||||||
})());
|
})());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user