document -> d
This commit is contained in:
parent
d86bde6f4f
commit
0642cb9e0b
@ -124,12 +124,13 @@ AEOS =
|
||||
GM_setValue "#{id}Left", div.style.left
|
||||
GM_setValue "#{id}Top", div.style.top
|
||||
|
||||
d = document
|
||||
#utility funks
|
||||
$ = (selector, root) ->
|
||||
root or= document.body
|
||||
root or= d.body
|
||||
root.querySelector(selector)
|
||||
$$ = (selector, root) ->
|
||||
root or= document.body
|
||||
root or= d.body
|
||||
result = root.querySelectorAll(selector)
|
||||
#magic that turns the results object into an array:
|
||||
node for node in result
|
||||
@ -147,7 +148,7 @@ inAfter = (root, el) ->
|
||||
inBefore = (root, el) ->
|
||||
root.parentNode.insertBefore(el, root)
|
||||
n = (tag, props) -> #new
|
||||
el = document.createElement tag
|
||||
el = d.createElement tag
|
||||
if props
|
||||
if l = props.listener
|
||||
delete props.listener
|
||||
@ -183,10 +184,10 @@ slice = (arr, id) ->
|
||||
return arr
|
||||
i++
|
||||
tn = (s) ->
|
||||
document.createTextNode s
|
||||
d.createTextNode s
|
||||
x = (path, root) ->
|
||||
root or= document.body
|
||||
document.
|
||||
root or= d.body
|
||||
d.
|
||||
evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).
|
||||
singleNodeValue
|
||||
|
||||
@ -201,7 +202,7 @@ if location.hostname.split('.')[0] is 'sys'
|
||||
html = $('b').innerHTML
|
||||
[nop, thread, id] = html.match(/<!-- thread:(\d+),no:(\d+) -->/)
|
||||
if thread is '0'
|
||||
board = $('meta', document).content.match(/4chan.org\/(\w+)\//)[1]
|
||||
board = $('meta', d).content.match(/4chan.org\/(\w+)\//)[1]
|
||||
watched[board] or= []
|
||||
watched[board].push({
|
||||
id: id,
|
||||
@ -220,7 +221,7 @@ r = null
|
||||
iframeLoop = false
|
||||
callbacks = []
|
||||
#godammit moot
|
||||
head = $('head', document)
|
||||
head = $('head', d)
|
||||
if not favicon = $('link[rel="shortcut icon"]', head)#/f/
|
||||
favicon = n 'link', {
|
||||
rel: 'shortcut icon'
|
||||
@ -343,7 +344,7 @@ options = ->
|
||||
$('input[type="button"]', div).addEventListener('click', clearHidden, true)
|
||||
$('a[name="save"]', div).addEventListener('click', optionsSave, true)
|
||||
$('a[name="cancel"]', div).addEventListener('click', close, true)
|
||||
addTo document.body, div
|
||||
addTo d.body, div
|
||||
|
||||
|
||||
showThread = ->
|
||||
@ -553,7 +554,7 @@ quickReply = (e) ->
|
||||
}
|
||||
addTo clone, input
|
||||
addTo qr, clone
|
||||
addTo document.body, qr
|
||||
addTo d.body, qr
|
||||
|
||||
if e
|
||||
e.preventDefault()
|
||||
@ -784,7 +785,7 @@ if getConfig('Quick Reply')
|
||||
listener: ['load', iframeLoad]
|
||||
}
|
||||
hide(iframe)
|
||||
addTo document.body, iframe
|
||||
addTo d.body, iframe
|
||||
|
||||
callbacks.push((root) ->
|
||||
quotes = $$('a.quotejs:not(:first-child)', root)
|
||||
@ -818,7 +819,7 @@ if getConfig('Thread Watcher')
|
||||
}
|
||||
position(watcher)
|
||||
$('div', watcher).addEventListener('mousedown', AEOS.move, true)
|
||||
addTo document.body, watcher
|
||||
addTo d.body, watcher
|
||||
watcherUpdate()
|
||||
|
||||
#add buttons
|
||||
@ -880,9 +881,9 @@ else # not reply
|
||||
if getConfig('Thread Hiding')
|
||||
delform = $('form[name=delform]')
|
||||
#don't confuse other scripts
|
||||
document.addEventListener('DOMNodeInserted', stopPropagation, true)
|
||||
d.addEventListener('DOMNodeInserted', stopPropagation, true)
|
||||
threadF(delform.firstChild)
|
||||
document.removeEventListener('DOMNodeInserted', stopPropagation, true)
|
||||
d.removeEventListener('DOMNodeInserted', stopPropagation, true)
|
||||
|
||||
if getConfig('Auto Watch')
|
||||
$('form[name="post"]').addEventListener('submit', autoWatch, true)
|
||||
@ -947,4 +948,4 @@ else # not reply
|
||||
|
||||
for callback in callbacks
|
||||
callback()
|
||||
document.body.addEventListener('DOMNodeInserted', nodeInserted, true)
|
||||
d.body.addEventListener('DOMNodeInserted', nodeInserted, true)
|
||||
|
||||
33
4chan_x.js
33
4chan_x.js
@ -1,5 +1,5 @@
|
||||
(function() {
|
||||
var $, $$, AEOS, 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, href, html, i, i1, id, iframe, iframeLoad, iframeLoop, img, inAfter, inBefore, input, inputs, l, l1, lastChecked, magic, n, navtopr, nodeInserted, nop, now, omitted, onloadComment, onloadThread, options, optionsSave, parseResponse, position, quickReply, r, 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, _i, _j, _len, _len2, _ref, _ref2, a, addTo, arr, as, autoWatch, autohide, b, board, callback, callbacks, clearHidden, close, config, cutoff, d, delform, down, 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, navtopr, nodeInserted, nop, now, omitted, onloadComment, onloadThread, options, optionsSave, parseResponse, position, quickReply, r, 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,
|
||||
@ -137,13 +137,14 @@
|
||||
return GM_setValue("" + (id) + "Top", div.style.top);
|
||||
}
|
||||
};
|
||||
d = document;
|
||||
$ = function(selector, root) {
|
||||
root || (root = document.body);
|
||||
root || (root = d.body);
|
||||
return root.querySelector(selector);
|
||||
};
|
||||
$$ = function(selector, root) {
|
||||
var _i, _len, _ref, _result, node, result;
|
||||
root || (root = document.body);
|
||||
root || (root = d.body);
|
||||
result = root.querySelectorAll(selector);
|
||||
_result = []; _ref = result;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
@ -179,7 +180,7 @@
|
||||
};
|
||||
n = function(tag, props) {
|
||||
var _ref, el, event, funk, key, l, val;
|
||||
el = document.createElement(tag);
|
||||
el = d.createElement(tag);
|
||||
if (props) {
|
||||
if (l = props.listener) {
|
||||
delete props.listener;
|
||||
@ -231,11 +232,11 @@
|
||||
return _result;
|
||||
};
|
||||
tn = function(s) {
|
||||
return document.createTextNode(s);
|
||||
return d.createTextNode(s);
|
||||
};
|
||||
x = function(path, root) {
|
||||
root || (root = document.body);
|
||||
return document.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
|
||||
root || (root = d.body);
|
||||
return d.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
|
||||
};
|
||||
watched = JSON.parse(GM_getValue('watched', '{}'));
|
||||
if (location.hostname.split('.')[0] === 'sys') {
|
||||
@ -250,7 +251,7 @@
|
||||
thread = _ref[1];
|
||||
id = _ref[2];
|
||||
if (thread === '0') {
|
||||
board = $('meta', document).content.match(/4chan.org\/(\w+)\//)[1];
|
||||
board = $('meta', d).content.match(/4chan.org\/(\w+)\//)[1];
|
||||
watched[board] || (watched[board] = []);
|
||||
watched[board].push({
|
||||
id: id,
|
||||
@ -275,7 +276,7 @@
|
||||
r = null;
|
||||
iframeLoop = false;
|
||||
callbacks = [];
|
||||
head = $('head', document);
|
||||
head = $('head', d);
|
||||
if (!(favicon = $('link[rel="shortcut icon"]', head))) {
|
||||
favicon = n('link', {
|
||||
rel: 'shortcut icon',
|
||||
@ -398,7 +399,7 @@
|
||||
$('input[type="button"]', div).addEventListener('click', clearHidden, true);
|
||||
$('a[name="save"]', div).addEventListener('click', optionsSave, true);
|
||||
$('a[name="cancel"]', div).addEventListener('click', close, true);
|
||||
return addTo(document.body, div);
|
||||
return addTo(d.body, div);
|
||||
}
|
||||
};
|
||||
showThread = function() {
|
||||
@ -618,7 +619,7 @@
|
||||
addTo(clone, input);
|
||||
}
|
||||
addTo(qr, clone);
|
||||
addTo(document.body, qr);
|
||||
addTo(d.body, qr);
|
||||
}
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
@ -886,7 +887,7 @@
|
||||
listener: ['load', iframeLoad]
|
||||
});
|
||||
hide(iframe);
|
||||
addTo(document.body, iframe);
|
||||
addTo(d.body, iframe);
|
||||
callbacks.push(function(root) {
|
||||
var _j, _len2, _ref2, _result, quote, quotes;
|
||||
quotes = $$('a.quotejs:not(:first-child)', root);
|
||||
@ -927,7 +928,7 @@
|
||||
});
|
||||
position(watcher);
|
||||
$('div', watcher).addEventListener('mousedown', AEOS.move, true);
|
||||
addTo(document.body, watcher);
|
||||
addTo(d.body, watcher);
|
||||
watcherUpdate();
|
||||
threads = watched[BOARD] || [];
|
||||
inputs = $$('form > input[value="delete"], div > input[value="delete"]');
|
||||
@ -1004,9 +1005,9 @@
|
||||
} else {
|
||||
if (getConfig('Thread Hiding')) {
|
||||
delform = $('form[name=delform]');
|
||||
document.addEventListener('DOMNodeInserted', stopPropagation, true);
|
||||
d.addEventListener('DOMNodeInserted', stopPropagation, true);
|
||||
threadF(delform.firstChild);
|
||||
document.removeEventListener('DOMNodeInserted', stopPropagation, true);
|
||||
d.removeEventListener('DOMNodeInserted', stopPropagation, true);
|
||||
}
|
||||
if (getConfig('Auto Watch')) {
|
||||
$('form[name="post"]').addEventListener('submit', autoWatch, true);
|
||||
@ -1083,5 +1084,5 @@
|
||||
callback = _ref[_i];
|
||||
callback();
|
||||
}
|
||||
document.body.addEventListener('DOMNodeInserted', nodeInserted, true);
|
||||
d.body.addEventListener('DOMNodeInserted', nodeInserted, true);
|
||||
}).call(this);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user