diff --git a/4chan_x.coffee b/4chan_x.coffee
index 4f28c2638..23c949fba 100644
--- a/4chan_x.coffee
+++ b/4chan_x.coffee
@@ -176,6 +176,38 @@ x = (path, root) ->
d.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).
singleNodeValue
+#globals
+iframeLoop = false
+xhrs = []
+r = null
+callbacks = []
+hiddenThreads = JSON.parse(GM_getValue("hiddenThreads/#{BOARD}/", '[]'))
+hiddenReplies = JSON.parse(GM_getValue("hiddenReplies/#{BOARD}/", '[]'))
+
+#godammit moot
+head = $('head', d)
+unless favicon = $('link[rel="shortcut icon"]', head)#/f/
+ favicon = n 'link',
+ rel: 'shortcut icon'
+ href: 'http://static.4chan.org/image/favicon.ico'
+ addTo head, favicon
+favNormal = favicon.href
+favEmpty = 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw=='
+sauceVarieties = [
+ 'http://regex.info/exif.cgi?url='
+ 'http://iqdb.org/?url='
+ 'http://saucenao.com/search.php?db=999&url='
+ 'http://tineye.com/search?url='
+].join '\n'
+pathname = location.pathname.substring(1).split('/')
+[BOARD, magic] = pathname
+if magic is 'res'
+ REPLY = magic
+ THREAD_ID = pathname[2]
+else
+ PAGENUM = parseInt(magic) || 0
+watched = JSON.parse(GM_getValue('watched', '{}'))
+
#funks
autohide = ->
qr = $ '#qr'
@@ -401,14 +433,14 @@ options = ->
description = value[1]
checked = if getConfig option then "checked" else ""
html += "
"
- html += "
';
- _ref = config;
- for (option in _ref) {
- if (!__hasProp.call(_ref, option)) continue;
- value = _ref[option];
+ _ref2 = config;
+ for (option in _ref2) {
+ if (!__hasProp.call(_ref2, option)) continue;
+ value = _ref2[option];
description = value[1];
checked = getConfig(option) ? "checked" : "";
html += ("
");
}
- html += "
";
+ html += "
";
html += "
";
html += ("
");
div.innerHTML = html;
$('div.move', div).addEventListener('mousedown', AEOS.move, true);
$('a.pointer', div).addEventListener('click', optionsClose, true);
$('a.sauce', div).addEventListener('click', editSauce, true);
- $('textarea', div).value = GM_getValue('saucePrefix', defaultSaucePrefix);
+ $('textarea', div).value = GM_getValue('saucePrefix', sauceVarieties);
$('input[type="button"]', div).addEventListener('click', clearHidden, true);
return addTo(d.body, div);
}
};
optionsClose = function() {
- var _i, _len, _ref, div, input, inputs;
+ var _i, _len, _ref2, div, input, inputs;
div = this.parentNode.parentNode;
inputs = $$('input', div);
- _ref = inputs;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- input = _ref[_i];
+ _ref2 = inputs;
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+ input = _ref2[_i];
GM_setValue(input.name, input.checked);
}
GM_setValue('saucePrefix', $('textarea', div).value);
@@ -554,7 +581,7 @@
return [replies, opbq];
};
quickReply = function(e) {
- var _i, _len, _ref, _ref2, auto, autoBox, autohideB, clone, closeB, form, id, input, qr, script, selection, submit, text, textarea, titlebar, xpath;
+ var _i, _len, _ref2, _ref3, auto, autoBox, autohideB, clone, closeB, form, id, input, qr, script, selection, submit, text, textarea, titlebar, xpath;
if (!(qr = $('#qr'))) {
qr = AEOS.makeDialog('qr', 'topleft');
titlebar = n('div', {
@@ -578,9 +605,9 @@
addTo(titlebar, autohideB, tn(' '), closeB);
form = $('form[name=post]');
clone = form.cloneNode(true);
- _ref = $$('script', clone);
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- script = _ref[_i];
+ _ref2 = $$('script', clone);
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+ script = _ref2[_i];
remove(script);
}
m($('input[name=recaptcha_response_field]', clone), {
@@ -612,9 +639,9 @@
}
if (e) {
e.preventDefault();
- (typeof (_ref2 = ((_ref = $('input[title=autohide]:checked', qr)))) === "undefined" || _ref2 === null) ? undefined : _ref2.click();
+ (typeof (_ref3 = ((_ref2 = $('input[title=autohide]:checked', qr)))) === "undefined" || _ref3 === null) ? undefined : _ref3.click();
selection = window.getSelection();
- id = (typeof (_ref2 = ((_ref = x('preceding::span[@id][1]', selection.anchorNode)))) === "undefined" || _ref2 === null) ? undefined : _ref2.id;
+ id = (typeof (_ref3 = ((_ref2 = x('preceding::span[@id][1]', selection.anchorNode)))) === "undefined" || _ref3 === null) ? undefined : _ref3.id;
text = selection.toString();
textarea = $('textarea', qr);
textarea.focus();
@@ -689,7 +716,7 @@
return e.stopPropagation();
};
threadF = function(current) {
- var _i, _len, _ref, a, div, hidden, id;
+ var _i, _len, _ref2, a, div, hidden, id;
div = n('div', {
className: 'thread'
});
@@ -708,9 +735,9 @@
current = div.nextSibling;
id = $('input[value="delete"]', div).name;
div.id = id;
- _ref = hiddenThreads;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- hidden = _ref[_i];
+ _ref2 = hiddenThreads;
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+ hidden = _ref2[_i];
if (id === hidden.id) {
hideThread(div);
}
@@ -737,15 +764,15 @@
return watcherUpdate();
};
watcherUpdate = function() {
- var _i, _j, _len, _ref, _ref2, a, board, div, link, old, thread;
+ var _i, _j, _len, _ref2, _ref3, a, board, div, link, old, thread;
div = n('div');
- _ref = watched;
- for (board in _ref) {
- if (!__hasProp.call(_ref, board)) continue;
- _i = _ref[board];
- _ref2 = watched[board];
- for (_j = 0, _len = _ref2.length; _j < _len; _j++) {
- thread = _ref2[_j];
+ _ref2 = watched;
+ for (board in _ref2) {
+ if (!__hasProp.call(_ref2, board)) continue;
+ _i = _ref2[board];
+ _ref3 = watched[board];
+ for (_j = 0, _len = _ref3.length; _j < _len; _j++) {
+ thread = _ref3[_j];
a = n('a', {
textContent: 'X',
className: 'pointer',
@@ -762,11 +789,11 @@
return replace(old, div);
};
watchX = function() {
- var _, _ref, board, favicon, id, input;
- _ref = this.nextElementSibling.getAttribute('href').substring(1).split('/');
- board = _ref[0];
- _ = _ref[1];
- id = _ref[2];
+ var _, _ref2, board, id, input;
+ _ref2 = this.nextElementSibling.getAttribute('href').substring(1).split('/');
+ board = _ref2[0];
+ _ = _ref2[1];
+ id = _ref2[2];
watched[board] = slice(watched[board], id);
GM_setValue('watched', JSON.stringify(watched));
watcherUpdate();
@@ -775,7 +802,6 @@
return (favicon.src = favEmpty);
}
};
- watched = JSON.parse(GM_getValue('watched', '{}'));
if (location.hostname.split('.')[0] === 'sys') {
if (recaptcha = $('#recaptcha_response_field')) {
m(recaptcha, {
@@ -804,32 +830,6 @@
}
return null;
}
- pathname = location.pathname.substring(1).split('/');
- _ref = pathname;
- BOARD = _ref[0];
- magic = _ref[1];
- if (magic === 'res') {
- REPLY = magic;
- THREAD_ID = pathname[2];
- } else {
- PAGENUM = parseInt(magic) || 0;
- }
- xhrs = [];
- r = null;
- iframeLoop = false;
- callbacks = [];
- head = $('head', d);
- if (!(favicon = $('link[rel="shortcut icon"]', head))) {
- favicon = n('link', {
- rel: 'shortcut icon',
- href: 'http://static.4chan.org/image/favicon.ico'
- });
- addTo(head, favicon);
- }
- favNormal = favicon.href;
- favEmpty = 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==';
- hiddenThreads = JSON.parse(GM_getValue("hiddenThreads/" + (BOARD) + "/", '[]'));
- hiddenReplies = JSON.parse(GM_getValue("hiddenReplies/" + (BOARD) + "/", '[]'));
lastChecked = GM_getValue('lastChecked', 0);
now = getTime();
DAY = 24 * 60 * 60;
@@ -851,7 +851,6 @@
GM_setValue("hiddenReplies/" + (BOARD) + "/", JSON.stringify(hiddenReplies));
GM_setValue('lastChecked', now);
}
- defaultSaucePrefix = ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://saucenao.com/search.php?db=999&url=', 'http://tineye.com/search?url='].join('\n');
GM_addStyle('\
#watcher {\
position: absolute;\
@@ -936,7 +935,7 @@
callbacks.push(function(root) {
var _j, _len2, _ref2, _result, _result2, i, l, link, names, prefix, prefixes, span, spans, suffix;
spans = $$('span.filesize', root);
- prefixes = GM_getValue('saucePrefix', defaultSaucePrefix).split('\n');
+ prefixes = GM_getValue('saucePrefix', sauceVarieties).split('\n');
names = (function() {
_result = []; _ref2 = prefixes;
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {