addTo -> mv
This commit is contained in:
parent
d13c1fc611
commit
f515692e08
@ -138,11 +138,10 @@ $ = (selector, root=d.body) ->
|
|||||||
root.querySelector selector
|
root.querySelector selector
|
||||||
$$ = (selector, root=d.body) ->
|
$$ = (selector, root=d.body) ->
|
||||||
result = root.querySelectorAll selector
|
result = root.querySelectorAll selector
|
||||||
#magic that turns the results object into an array:
|
|
||||||
node for node in result
|
node for node in result
|
||||||
addTo = (parent, children...) ->
|
mv = (args...) ->
|
||||||
for child in children
|
parent = args.pop()
|
||||||
parent.appendChild child
|
(parent.appendChild child) for child in args
|
||||||
getConfig = (name) ->
|
getConfig = (name) ->
|
||||||
GM_getValue name, config[name][0]
|
GM_getValue name, config[name][0]
|
||||||
getTime = ->
|
getTime = ->
|
||||||
@ -297,7 +296,7 @@ formSubmit = (e) ->
|
|||||||
span = n 'span',
|
span = n 'span',
|
||||||
className: 'error'
|
className: 'error'
|
||||||
textContent: 'You forgot to type in the verification.'
|
textContent: 'You forgot to type in the verification.'
|
||||||
addTo @parentNode, span
|
mv span, @parentNode
|
||||||
alert 'You forgot to type in the verification.'
|
alert 'You forgot to type in the verification.'
|
||||||
recaptcha.focus()
|
recaptcha.focus()
|
||||||
|
|
||||||
@ -319,7 +318,7 @@ hideReply = (reply) ->
|
|||||||
className: 'pointer'
|
className: 'pointer'
|
||||||
listener: ['click', showReply]
|
listener: ['click', showReply]
|
||||||
div = n 'div'
|
div = n 'div'
|
||||||
addTo div, a
|
mv a, div
|
||||||
inBefore table, div
|
inBefore table, div
|
||||||
|
|
||||||
hideThread = (div) ->
|
hideThread = (div) ->
|
||||||
@ -355,7 +354,7 @@ iframeLoad = ->
|
|||||||
span = n 'span',
|
span = n 'span',
|
||||||
textContent: error
|
textContent: error
|
||||||
className: 'error'
|
className: 'error'
|
||||||
addTo qr, span
|
mv span, qr
|
||||||
$('input[title=autohide]:checked', qr)?.click()
|
$('input[title=autohide]:checked', qr)?.click()
|
||||||
else if g.REPLY and getConfig 'Persistent QR'
|
else if g.REPLY and getConfig 'Persistent QR'
|
||||||
$('textarea', qr).value = ''
|
$('textarea', qr).value = ''
|
||||||
@ -571,7 +570,7 @@ onloadThread = (responseText, span) ->
|
|||||||
else#threading
|
else#threading
|
||||||
div = span.parentNode
|
div = span.parentNode
|
||||||
for reply in replies
|
for reply in replies
|
||||||
addTo div, x 'ancestor::table', reply
|
mv x('ancestor::table', reply), div
|
||||||
|
|
||||||
changeCheckbox = ->
|
changeCheckbox = ->
|
||||||
GM_setValue @name, @checked
|
GM_setValue @name, @checked
|
||||||
@ -601,7 +600,7 @@ options = ->
|
|||||||
$('a.sauce', div).addEventListener 'click', editSauce, true
|
$('a.sauce', div).addEventListener 'click', editSauce, true
|
||||||
$('textarea', div).addEventListener 'change', changeText, true
|
$('textarea', div).addEventListener 'change', changeText, true
|
||||||
$('input[type="button"]', div).addEventListener 'click', clearHidden, true
|
$('input[type="button"]', div).addEventListener 'click', clearHidden, true
|
||||||
addTo d.body, div
|
mv div, d.body
|
||||||
|
|
||||||
parseResponse = (responseText) ->
|
parseResponse = (responseText) ->
|
||||||
body = n 'body',
|
body = n 'body',
|
||||||
@ -649,17 +648,17 @@ quickReply = (link, text) ->
|
|||||||
type: 'hidden'
|
type: 'hidden'
|
||||||
name: 'resto'
|
name: 'resto'
|
||||||
value: x(xpath, link).name
|
value: x(xpath, link).name
|
||||||
addTo clone, input
|
mv input, clone
|
||||||
else if getConfig 'Persistent QR'
|
else if getConfig 'Persistent QR'
|
||||||
submit = $ 'input[type=submit]', clone
|
submit = $ 'input[type=submit]', clone
|
||||||
auto = n 'label',
|
auto = n 'label',
|
||||||
textContent: 'Auto'
|
textContent: 'Auto'
|
||||||
autoBox = n 'input',
|
autoBox = n 'input',
|
||||||
type: 'checkbox'
|
type: 'checkbox'
|
||||||
addTo auto, autoBox
|
mv autoBox, auto
|
||||||
inBefore submit, auto
|
inBefore submit, auto
|
||||||
addTo qr, clone
|
mv clone, qr
|
||||||
addTo d.body, qr
|
mv qr, d.body
|
||||||
|
|
||||||
$('input[title=autohide]:checked', qr)?.click()
|
$('input[title=autohide]:checked', qr)?.click()
|
||||||
textarea = $('textarea', qr)
|
textarea = $('textarea', qr)
|
||||||
@ -743,12 +742,12 @@ threadF = (current) ->
|
|||||||
textContent: '[ - ]'
|
textContent: '[ - ]'
|
||||||
className: 'pointer'
|
className: 'pointer'
|
||||||
listener: ['click', hideThread]
|
listener: ['click', hideThread]
|
||||||
addTo div, a
|
mv a, div
|
||||||
inBefore current, div
|
inBefore current, div
|
||||||
while (!current.clear)#<br clear>
|
while (!current.clear)#<br clear>
|
||||||
addTo div, current
|
mv current, div
|
||||||
current = div.nextSibling
|
current = div.nextSibling
|
||||||
addTo div, current
|
mv current, div
|
||||||
current = div.nextSibling
|
current = div.nextSibling
|
||||||
id = $('input[value="delete"]', div).name
|
id = $('input[value="delete"]', div).name
|
||||||
div.id = id
|
div.id = id
|
||||||
@ -909,7 +908,7 @@ watcherUpdate = ->
|
|||||||
link = n 'a',
|
link = n 'a',
|
||||||
textContent: thread.text
|
textContent: thread.text
|
||||||
href: "/#{board}/res/#{thread.id}"
|
href: "/#{board}/res/#{thread.id}"
|
||||||
addTo div, a, tn(' '), link, n('br')
|
mv a, tn(' '), link, n('br'), div
|
||||||
old = $('#watcher div:last-child')
|
old = $('#watcher div:last-child')
|
||||||
replace(old, div)
|
replace(old, div)
|
||||||
|
|
||||||
@ -1164,7 +1163,7 @@ if getConfig 'Sauce'
|
|||||||
link = n 'a',
|
link = n 'a',
|
||||||
textContent: names[i]
|
textContent: names[i]
|
||||||
href: prefixes[i] + suffix
|
href: prefixes[i] + suffix
|
||||||
addTo span, tn(' '), link
|
mv tn(' '), link, span
|
||||||
i++
|
i++
|
||||||
|
|
||||||
if getConfig 'Reply Hiding'
|
if getConfig 'Reply Hiding'
|
||||||
@ -1188,7 +1187,7 @@ if getConfig 'Quick Reply'
|
|||||||
name: 'iframe'
|
name: 'iframe'
|
||||||
listener: ['load', iframeLoad]
|
listener: ['load', iframeLoad]
|
||||||
hide(iframe)
|
hide(iframe)
|
||||||
addTo d.body, iframe
|
mv iframe, d.body
|
||||||
|
|
||||||
g.callbacks.push (root) ->
|
g.callbacks.push (root) ->
|
||||||
quotes = $$('a.quotejs:not(:first-child)', root)
|
quotes = $$('a.quotejs:not(:first-child)', root)
|
||||||
@ -1214,7 +1213,7 @@ if getConfig 'Thread Watcher'
|
|||||||
#create watcher
|
#create watcher
|
||||||
html = '<div class="move">Thread Watcher</div><div></div>'
|
html = '<div class="move">Thread Watcher</div><div></div>'
|
||||||
watcher = new Dialog('watcher', 'topleft', html).el
|
watcher = new Dialog('watcher', 'topleft', html).el
|
||||||
addTo d.body, watcher
|
mv watcher, d.body
|
||||||
watcherUpdate()
|
watcherUpdate()
|
||||||
|
|
||||||
#add buttons
|
#add buttons
|
||||||
@ -1260,7 +1259,7 @@ if getConfig 'Reply Navigation'
|
|||||||
textContent: '▼'
|
textContent: '▼'
|
||||||
className: 'pointer'
|
className: 'pointer'
|
||||||
listener: ['click', replyNav]
|
listener: ['click', replyNav]
|
||||||
addTo span, tn(' '), up, tn(' '), down
|
mv tn(' '), up, tn(' '), down, span
|
||||||
inAfter el, span
|
inAfter el, span
|
||||||
|
|
||||||
if getConfig 'Keybinds'
|
if getConfig 'Keybinds'
|
||||||
@ -1329,7 +1328,7 @@ else #not reply
|
|||||||
className: 'pointer'
|
className: 'pointer'
|
||||||
textContent: textContent
|
textContent: textContent
|
||||||
href: href
|
href: href
|
||||||
addTo span, up, tn(' '), down
|
mv up, tn(' '), down, span
|
||||||
inBefore el, span
|
inBefore el, span
|
||||||
if location.hash is '#p0'
|
if location.hash is '#p0'
|
||||||
window.location = window.location
|
window.location = window.location
|
||||||
|
|||||||
49
4chan_x.js
49
4chan_x.js
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var $, $$, DAY, Dialog, a, addTo, arr, as, autoWatch, autohide, b, board, callback, changeCheckbox, changeText, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, i, id, iframe, iframeLoad, imageClick, imageExpandClick, imageFull, imageThumb, imageToggle, img, inAfter, inBefore, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, parseResponse, pathname, qrListener, qrText, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, replace, replyNav, report, request, rm, scroll, scrollThread, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updaterMake, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _ref, _ref2, _ref3, _ref4, _ref5;
|
var $, $$, DAY, Dialog, a, arr, as, autoWatch, autohide, b, board, callback, changeCheckbox, changeText, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, i, id, iframe, iframeLoad, imageClick, imageExpandClick, imageFull, imageThumb, imageToggle, img, inAfter, inBefore, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, m, mv, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, parseResponse, pathname, qrListener, qrText, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, replace, replyNav, report, request, rm, scroll, scrollThread, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updaterMake, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _ref, _ref2, _ref3, _ref4, _ref5;
|
||||||
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __slice = Array.prototype.slice;
|
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __slice = Array.prototype.slice;
|
||||||
config = {
|
config = {
|
||||||
'404 Redirect': [true, 'Redirect dead threads'],
|
'404 Redirect': [true, 'Redirect dead threads'],
|
||||||
@ -182,12 +182,13 @@
|
|||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
};
|
};
|
||||||
addTo = function() {
|
mv = function() {
|
||||||
var child, children, parent, _i, _len, _results;
|
var args, child, parent, _i, _len, _results;
|
||||||
parent = arguments[0], children = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||||
|
parent = args.pop();
|
||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = children.length; _i < _len; _i++) {
|
for (_i = 0, _len = args.length; _i < _len; _i++) {
|
||||||
child = children[_i];
|
child = args[_i];
|
||||||
_results.push(parent.appendChild(child));
|
_results.push(parent.appendChild(child));
|
||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
@ -394,7 +395,7 @@
|
|||||||
className: 'error',
|
className: 'error',
|
||||||
textContent: 'You forgot to type in the verification.'
|
textContent: 'You forgot to type in the verification.'
|
||||||
});
|
});
|
||||||
addTo(this.parentNode, span);
|
mv(span, this.parentNode);
|
||||||
alert('You forgot to type in the verification.');
|
alert('You forgot to type in the verification.');
|
||||||
return recaptcha.focus();
|
return recaptcha.focus();
|
||||||
}
|
}
|
||||||
@ -420,7 +421,7 @@
|
|||||||
listener: ['click', showReply]
|
listener: ['click', showReply]
|
||||||
});
|
});
|
||||||
div = n('div');
|
div = n('div');
|
||||||
addTo(div, a);
|
mv(a, div);
|
||||||
return inBefore(table, div);
|
return inBefore(table, div);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -465,7 +466,7 @@
|
|||||||
textContent: error,
|
textContent: error,
|
||||||
className: 'error'
|
className: 'error'
|
||||||
});
|
});
|
||||||
addTo(qr, span);
|
mv(span, qr);
|
||||||
if ((_ref = $('input[title=autohide]:checked', qr)) != null) {
|
if ((_ref = $('input[title=autohide]:checked', qr)) != null) {
|
||||||
_ref.click();
|
_ref.click();
|
||||||
}
|
}
|
||||||
@ -748,7 +749,7 @@
|
|||||||
_results2 = [];
|
_results2 = [];
|
||||||
for (_j = 0, _len2 = replies.length; _j < _len2; _j++) {
|
for (_j = 0, _len2 = replies.length; _j < _len2; _j++) {
|
||||||
reply = replies[_j];
|
reply = replies[_j];
|
||||||
_results2.push(addTo(div, x('ancestor::table', reply)));
|
_results2.push(mv(x('ancestor::table', reply), div));
|
||||||
}
|
}
|
||||||
return _results2;
|
return _results2;
|
||||||
}
|
}
|
||||||
@ -785,7 +786,7 @@
|
|||||||
$('a.sauce', div).addEventListener('click', editSauce, true);
|
$('a.sauce', div).addEventListener('click', editSauce, true);
|
||||||
$('textarea', div).addEventListener('change', changeText, true);
|
$('textarea', div).addEventListener('change', changeText, true);
|
||||||
$('input[type="button"]', div).addEventListener('click', clearHidden, true);
|
$('input[type="button"]', div).addEventListener('click', clearHidden, true);
|
||||||
return addTo(d.body, div);
|
return mv(div, d.body);
|
||||||
};
|
};
|
||||||
parseResponse = function(responseText) {
|
parseResponse = function(responseText) {
|
||||||
var body, opbq, replies;
|
var body, opbq, replies;
|
||||||
@ -839,7 +840,7 @@
|
|||||||
name: 'resto',
|
name: 'resto',
|
||||||
value: x(xpath, link).name
|
value: x(xpath, link).name
|
||||||
});
|
});
|
||||||
addTo(clone, input);
|
mv(input, clone);
|
||||||
} else if (getConfig('Persistent QR')) {
|
} else if (getConfig('Persistent QR')) {
|
||||||
submit = $('input[type=submit]', clone);
|
submit = $('input[type=submit]', clone);
|
||||||
auto = n('label', {
|
auto = n('label', {
|
||||||
@ -848,11 +849,11 @@
|
|||||||
autoBox = n('input', {
|
autoBox = n('input', {
|
||||||
type: 'checkbox'
|
type: 'checkbox'
|
||||||
});
|
});
|
||||||
addTo(auto, autoBox);
|
mv(autoBox, auto);
|
||||||
inBefore(submit, auto);
|
inBefore(submit, auto);
|
||||||
}
|
}
|
||||||
addTo(qr, clone);
|
mv(clone, qr);
|
||||||
addTo(d.body, qr);
|
mv(qr, d.body);
|
||||||
}
|
}
|
||||||
if ((_ref2 = $('input[title=autohide]:checked', qr)) != null) {
|
if ((_ref2 = $('input[title=autohide]:checked', qr)) != null) {
|
||||||
_ref2.click();
|
_ref2.click();
|
||||||
@ -964,13 +965,13 @@
|
|||||||
className: 'pointer',
|
className: 'pointer',
|
||||||
listener: ['click', hideThread]
|
listener: ['click', hideThread]
|
||||||
});
|
});
|
||||||
addTo(div, a);
|
mv(a, div);
|
||||||
inBefore(current, div);
|
inBefore(current, div);
|
||||||
while (!current.clear) {
|
while (!current.clear) {
|
||||||
addTo(div, current);
|
mv(current, div);
|
||||||
current = div.nextSibling;
|
current = div.nextSibling;
|
||||||
}
|
}
|
||||||
addTo(div, current);
|
mv(current, div);
|
||||||
current = div.nextSibling;
|
current = div.nextSibling;
|
||||||
id = $('input[value="delete"]', div).name;
|
id = $('input[value="delete"]', div).name;
|
||||||
div.id = id;
|
div.id = id;
|
||||||
@ -1162,7 +1163,7 @@
|
|||||||
textContent: thread.text,
|
textContent: thread.text,
|
||||||
href: "/" + board + "/res/" + thread.id
|
href: "/" + board + "/res/" + thread.id
|
||||||
});
|
});
|
||||||
addTo(div, a, tn(' '), link, n('br'));
|
mv(a, tn(' '), link, n('br'), div);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
old = $('#watcher div:last-child');
|
old = $('#watcher div:last-child');
|
||||||
@ -1454,7 +1455,7 @@
|
|||||||
textContent: names[i],
|
textContent: names[i],
|
||||||
href: prefixes[i] + suffix
|
href: prefixes[i] + suffix
|
||||||
});
|
});
|
||||||
addTo(span, tn(' '), link);
|
mv(tn(' '), link, span);
|
||||||
_results.push(i++);
|
_results.push(i++);
|
||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
@ -1498,7 +1499,7 @@
|
|||||||
listener: ['load', iframeLoad]
|
listener: ['load', iframeLoad]
|
||||||
});
|
});
|
||||||
hide(iframe);
|
hide(iframe);
|
||||||
addTo(d.body, iframe);
|
mv(iframe, d.body);
|
||||||
g.callbacks.push(function(root) {
|
g.callbacks.push(function(root) {
|
||||||
var quote, quotes, _i, _len, _results;
|
var quote, quotes, _i, _len, _results;
|
||||||
quotes = $$('a.quotejs:not(:first-child)', root);
|
quotes = $$('a.quotejs:not(:first-child)', root);
|
||||||
@ -1532,7 +1533,7 @@
|
|||||||
if (getConfig('Thread Watcher')) {
|
if (getConfig('Thread Watcher')) {
|
||||||
html = '<div class="move">Thread Watcher</div><div></div>';
|
html = '<div class="move">Thread Watcher</div><div></div>';
|
||||||
watcher = new Dialog('watcher', 'topleft', html).el;
|
watcher = new Dialog('watcher', 'topleft', html).el;
|
||||||
addTo(d.body, watcher);
|
mv(watcher, d.body);
|
||||||
watcherUpdate();
|
watcherUpdate();
|
||||||
threads = g.watched[g.BOARD] || [];
|
threads = g.watched[g.BOARD] || [];
|
||||||
inputs = $$('form > input[value="delete"], div > input[value="delete"]');
|
inputs = $$('form > input[value="delete"], div > input[value="delete"]');
|
||||||
@ -1592,7 +1593,7 @@
|
|||||||
className: 'pointer',
|
className: 'pointer',
|
||||||
listener: ['click', replyNav]
|
listener: ['click', replyNav]
|
||||||
});
|
});
|
||||||
addTo(span, tn(' '), up, tn(' '), down);
|
mv(tn(' '), up, tn(' '), down, span);
|
||||||
_results.push(inAfter(el, span));
|
_results.push(inAfter(el, span));
|
||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
@ -1677,7 +1678,7 @@
|
|||||||
textContent: textContent,
|
textContent: textContent,
|
||||||
href: href
|
href: href
|
||||||
});
|
});
|
||||||
addTo(span, up, tn(' '), down);
|
mv(up, tn(' '), down, span);
|
||||||
inBefore(el, span);
|
inBefore(el, span);
|
||||||
}
|
}
|
||||||
if (location.hash === '#p0') {
|
if (location.hash === '#p0') {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user