collect old stuff
This commit is contained in:
parent
b8fa5724f1
commit
daffd9cd34
464
4chan_x.js
464
4chan_x.js
@ -59,7 +59,7 @@
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var $, $$, NAMESPACE, autoWatch, callback, changeCheckbox, changeValue, config, d, delform, el, expand, expandComment, expandThread, g, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, keybinds, log, nav, navtopr, nodeInserted, option, options, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyHiding, replyNav, report, scroll, scrollThread, temp, text, threadHiding, tzOffset, ui, updateFavicon, updateTitle, updater, watcher, _config, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4;
|
||||
var $, $$, NAMESPACE, autoWatch, callback, changeCheckbox, changeValue, config, d, delform, el, expand, expandComment, expandThread, g, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, keybinds, log, nav, navtopr, nodeInserted, option, options, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyHiding, report, scroll, scrollThread, temp, text, threadHiding, tzOffset, ui, updateFavicon, updateTitle, updater, watcher, _config, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4;
|
||||
var __slice = Array.prototype.slice;
|
||||
if (typeof console != "undefined" && console !== null) {
|
||||
log = console.log;
|
||||
@ -418,11 +418,6 @@
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
autoWatch = function() {
|
||||
var autoText;
|
||||
autoText = $('textarea', this).value.slice(0, 25);
|
||||
return GM_setValue('autoText', "/" + g.BOARD + "/ - " + autoText);
|
||||
};
|
||||
expandComment = {
|
||||
init: function() {
|
||||
var a, _i, _len, _ref, _results;
|
||||
@ -670,98 +665,6 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
imageClick = function(e) {
|
||||
if (e.shiftKey || e.altKey || e.ctrlKey) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
return imageToggle(this);
|
||||
};
|
||||
imageToggle = function(image) {
|
||||
var ch, cw, imageType, thumb;
|
||||
thumb = image.firstChild;
|
||||
cw = d.body.clientWidth;
|
||||
ch = d.body.clientHeight;
|
||||
imageType = $("#imageType").value;
|
||||
if (thumb.className === 'hide') {
|
||||
return imageThumb(thumb);
|
||||
} else {
|
||||
return imageExpand(thumb, cw, ch, imageType);
|
||||
}
|
||||
};
|
||||
imageTypeChange = function() {
|
||||
var ch, cw, image, imageType, images, _i, _len, _results;
|
||||
images = $$('img[md5] + img');
|
||||
cw = d.body.clientWidth;
|
||||
ch = d.body.clientHeight;
|
||||
imageType = this.value;
|
||||
_results = [];
|
||||
for (_i = 0, _len = images.length; _i < _len; _i++) {
|
||||
image = images[_i];
|
||||
_results.push(imageResize(cw, ch, imageType, image));
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
imageExpandClick = function() {
|
||||
var ch, cw, imageType, thumb, thumbs, _i, _j, _len, _len2, _results, _results2;
|
||||
thumbs = $$('img[md5]');
|
||||
g.expand = this.checked;
|
||||
cw = d.body.clientWidth;
|
||||
ch = d.body.clientHeight;
|
||||
imageType = $("#imageType").value;
|
||||
if (this.checked) {
|
||||
_results = [];
|
||||
for (_i = 0, _len = thumbs.length; _i < _len; _i++) {
|
||||
thumb = thumbs[_i];
|
||||
_results.push(thumb.className !== 'hide' ? imageExpand(thumb, cw, ch, imageType) : void 0);
|
||||
}
|
||||
return _results;
|
||||
} else {
|
||||
_results2 = [];
|
||||
for (_j = 0, _len2 = thumbs.length; _j < _len2; _j++) {
|
||||
thumb = thumbs[_j];
|
||||
_results2.push(thumb.className === 'hide' ? imageThumb(thumb) : void 0);
|
||||
}
|
||||
return _results2;
|
||||
}
|
||||
};
|
||||
imageExpand = function(thumb, cw, ch, imageType) {
|
||||
var image, link;
|
||||
thumb.className = 'hide';
|
||||
link = thumb.parentNode;
|
||||
image = $.el('img', {
|
||||
src: link.href
|
||||
});
|
||||
link.appendChild(image);
|
||||
return imageResize(cw, ch, imageType, image);
|
||||
};
|
||||
imageResize = function(cw, ch, imageType, image) {
|
||||
var ih, iw, ratio, _, _ref;
|
||||
_ref = $.x("preceding::span[@class][1]/text()[2]", image).textContent.match(/(\d+)x(\d+)/), _ = _ref[0], iw = _ref[1], ih = _ref[2];
|
||||
iw = Number(iw);
|
||||
ih = Number(ih);
|
||||
switch (imageType) {
|
||||
case 'full':
|
||||
image.removeAttribute('style');
|
||||
break;
|
||||
case 'fit width':
|
||||
if (iw > cw) {
|
||||
image.style.width = '100%';
|
||||
image.style.margin = '0px';
|
||||
}
|
||||
break;
|
||||
case 'fit screen':
|
||||
ratio = Math.min(cw / iw, ch / ih);
|
||||
if (ratio < 1) {
|
||||
image.style.width = Math.floor(ratio * iw);
|
||||
return image.style.margin = '0px';
|
||||
}
|
||||
}
|
||||
};
|
||||
imageThumb = function(thumb) {
|
||||
thumb.className = '';
|
||||
return $.remove(thumb.nextSibling);
|
||||
};
|
||||
keybinds = {
|
||||
init: function() {
|
||||
$.bind(d, 'keydown', keybinds.cb.keydown);
|
||||
@ -1002,48 +905,6 @@
|
||||
return window.scrollBy(0, top);
|
||||
}
|
||||
};
|
||||
scrollThread = function(count) {
|
||||
var hash, idx, temp, thread, top, _ref;
|
||||
_ref = getThread(), thread = _ref[0], idx = _ref[1];
|
||||
top = thread.getBoundingClientRect().top;
|
||||
if (idx === 0 && top > 1) {
|
||||
idx = -1;
|
||||
}
|
||||
if (count < 0 && top < -1) {
|
||||
count++;
|
||||
}
|
||||
temp = idx + count;
|
||||
if (temp < 0) {
|
||||
hash = '';
|
||||
} else if (temp > 9) {
|
||||
hash = 'p9';
|
||||
} else {
|
||||
hash = "p" + temp;
|
||||
}
|
||||
return location.hash = hash;
|
||||
};
|
||||
nodeInserted = function(e) {
|
||||
var callback, dialog, target, _i, _len, _ref, _results;
|
||||
target = e.target;
|
||||
if (target.nodeName === 'TABLE') {
|
||||
_ref = g.callbacks;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
callback = _ref[_i];
|
||||
_results.push(callback(target));
|
||||
}
|
||||
return _results;
|
||||
} else if (target.id === 'recaptcha_challenge_field' && (dialog = $('#qr'))) {
|
||||
$('#recaptcha_image img', dialog).src = "http://www.google.com/recaptcha/api/image?c=" + target.value;
|
||||
return $('#recaptcha_challenge_field', dialog).value = target.value;
|
||||
}
|
||||
};
|
||||
changeCheckbox = function() {
|
||||
return GM_setValue(this.name, this.checked);
|
||||
};
|
||||
changeValue = function() {
|
||||
return GM_setValue(this.name, this.value);
|
||||
};
|
||||
options = {
|
||||
init: function() {
|
||||
var a, home;
|
||||
@ -1362,76 +1223,6 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
recaptchaListener = function(e) {
|
||||
if (e.keyCode === 8 && this.value === '') {
|
||||
return recaptchaReload();
|
||||
}
|
||||
};
|
||||
recaptchaReload = function() {
|
||||
return window.location = 'javascript:Recaptcha.reload()';
|
||||
};
|
||||
redirect = function() {
|
||||
var url;
|
||||
switch (g.BOARD) {
|
||||
case 'a':
|
||||
case 'g':
|
||||
case 'lit':
|
||||
case 'sci':
|
||||
case 'tv':
|
||||
url = "http://green-oval.net/cgi-board.pl/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
||||
break;
|
||||
case 'cgl':
|
||||
case 'jp':
|
||||
case 'm':
|
||||
case 'tg':
|
||||
url = "http://archive.easymodo.net/cgi-board.pl/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
||||
break;
|
||||
case '3':
|
||||
case 'adv':
|
||||
case 'an':
|
||||
case 'c':
|
||||
case 'ck':
|
||||
case 'co':
|
||||
case 'fa':
|
||||
case 'fit':
|
||||
case 'int':
|
||||
case 'k':
|
||||
case 'mu':
|
||||
case 'n':
|
||||
case 'o':
|
||||
case 'p':
|
||||
case 'po':
|
||||
case 'soc':
|
||||
case 'sp':
|
||||
case 'toy':
|
||||
case 'trv':
|
||||
case 'v':
|
||||
case 'vp':
|
||||
case 'x':
|
||||
url = "http://archive.no-ip.org/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
||||
break;
|
||||
default:
|
||||
url = "http://boards.4chan.org/" + g.BOARD;
|
||||
}
|
||||
return location.href = url;
|
||||
};
|
||||
replyNav = function() {
|
||||
var direction, op;
|
||||
if (g.REPLY) {
|
||||
return window.location = this.textContent === '▲' ? '#navtop' : '#navbot';
|
||||
} else {
|
||||
direction = this.textContent === '▲' ? 'preceding' : 'following';
|
||||
op = $.x("" + direction + "::span[starts-with(@id, 'nothread')][1]", this).id;
|
||||
return window.location = "#" + op;
|
||||
}
|
||||
};
|
||||
report = function() {
|
||||
var input;
|
||||
input = $.x('preceding-sibling::input[1]', this);
|
||||
input.click();
|
||||
$('input[value="Report"]').click();
|
||||
return input.click();
|
||||
};
|
||||
threadHiding = {
|
||||
init: function() {
|
||||
var a, hiddenThreads, node, op, thread, _i, _len, _ref, _results;
|
||||
@ -1544,33 +1335,6 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
updateFavicon = function() {
|
||||
var clone, favicon, href, len;
|
||||
len = g.replies.length;
|
||||
if (g.dead) {
|
||||
if (len > 0) {
|
||||
href = g.favDeadHalo;
|
||||
} else {
|
||||
href = g.favDead;
|
||||
}
|
||||
} else {
|
||||
if (len > 0) {
|
||||
href = g.favHalo;
|
||||
} else {
|
||||
href = g.favDefault;
|
||||
}
|
||||
}
|
||||
favicon = $('link[rel="shortcut icon"]', d);
|
||||
clone = favicon.cloneNode(true);
|
||||
clone.href = href;
|
||||
return $.replace(favicon, clone);
|
||||
};
|
||||
updateTitle = function() {
|
||||
var len;
|
||||
len = g.replies.length;
|
||||
d.title = d.title.replace(/\d+/, len);
|
||||
return updateFavicon();
|
||||
};
|
||||
updater = {
|
||||
init: function() {
|
||||
var autoUpT, checked, conf, dialog, html, input, interva, name, title, updNow, verbose, _i, _len, _ref;
|
||||
@ -1796,6 +1560,232 @@
|
||||
return watcher.addLink(props);
|
||||
}
|
||||
};
|
||||
scrollThread = function(count) {
|
||||
var hash, idx, temp, thread, top, _ref;
|
||||
_ref = getThread(), thread = _ref[0], idx = _ref[1];
|
||||
top = thread.getBoundingClientRect().top;
|
||||
if (idx === 0 && top > 1) {
|
||||
idx = -1;
|
||||
}
|
||||
if (count < 0 && top < -1) {
|
||||
count++;
|
||||
}
|
||||
temp = idx + count;
|
||||
if (temp < 0) {
|
||||
hash = '';
|
||||
} else if (temp > 9) {
|
||||
hash = 'p9';
|
||||
} else {
|
||||
hash = "p" + temp;
|
||||
}
|
||||
return location.hash = hash;
|
||||
};
|
||||
nodeInserted = function(e) {
|
||||
var callback, dialog, target, _i, _len, _ref, _results;
|
||||
target = e.target;
|
||||
if (target.nodeName === 'TABLE') {
|
||||
_ref = g.callbacks;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
callback = _ref[_i];
|
||||
_results.push(callback(target));
|
||||
}
|
||||
return _results;
|
||||
} else if (target.id === 'recaptcha_challenge_field' && (dialog = $('#qr'))) {
|
||||
$('#recaptcha_image img', dialog).src = "http://www.google.com/recaptcha/api/image?c=" + target.value;
|
||||
return $('#recaptcha_challenge_field', dialog).value = target.value;
|
||||
}
|
||||
};
|
||||
autoWatch = function() {
|
||||
var autoText;
|
||||
autoText = $('textarea', this).value.slice(0, 25);
|
||||
return GM_setValue('autoText', "/" + g.BOARD + "/ - " + autoText);
|
||||
};
|
||||
imageClick = function(e) {
|
||||
if (e.shiftKey || e.altKey || e.ctrlKey) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
return imageToggle(this);
|
||||
};
|
||||
imageToggle = function(image) {
|
||||
var ch, cw, imageType, thumb;
|
||||
thumb = image.firstChild;
|
||||
cw = d.body.clientWidth;
|
||||
ch = d.body.clientHeight;
|
||||
imageType = $("#imageType").value;
|
||||
if (thumb.className === 'hide') {
|
||||
return imageThumb(thumb);
|
||||
} else {
|
||||
return imageExpand(thumb, cw, ch, imageType);
|
||||
}
|
||||
};
|
||||
imageTypeChange = function() {
|
||||
var ch, cw, image, imageType, images, _i, _len, _results;
|
||||
images = $$('img[md5] + img');
|
||||
cw = d.body.clientWidth;
|
||||
ch = d.body.clientHeight;
|
||||
imageType = this.value;
|
||||
_results = [];
|
||||
for (_i = 0, _len = images.length; _i < _len; _i++) {
|
||||
image = images[_i];
|
||||
_results.push(imageResize(cw, ch, imageType, image));
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
imageExpandClick = function() {
|
||||
var ch, cw, imageType, thumb, thumbs, _i, _j, _len, _len2, _results, _results2;
|
||||
thumbs = $$('img[md5]');
|
||||
g.expand = this.checked;
|
||||
cw = d.body.clientWidth;
|
||||
ch = d.body.clientHeight;
|
||||
imageType = $("#imageType").value;
|
||||
if (this.checked) {
|
||||
_results = [];
|
||||
for (_i = 0, _len = thumbs.length; _i < _len; _i++) {
|
||||
thumb = thumbs[_i];
|
||||
_results.push(thumb.className !== 'hide' ? imageExpand(thumb, cw, ch, imageType) : void 0);
|
||||
}
|
||||
return _results;
|
||||
} else {
|
||||
_results2 = [];
|
||||
for (_j = 0, _len2 = thumbs.length; _j < _len2; _j++) {
|
||||
thumb = thumbs[_j];
|
||||
_results2.push(thumb.className === 'hide' ? imageThumb(thumb) : void 0);
|
||||
}
|
||||
return _results2;
|
||||
}
|
||||
};
|
||||
imageExpand = function(thumb, cw, ch, imageType) {
|
||||
var image, link;
|
||||
thumb.className = 'hide';
|
||||
link = thumb.parentNode;
|
||||
image = $.el('img', {
|
||||
src: link.href
|
||||
});
|
||||
link.appendChild(image);
|
||||
return imageResize(cw, ch, imageType, image);
|
||||
};
|
||||
imageResize = function(cw, ch, imageType, image) {
|
||||
var ih, iw, ratio, _, _ref;
|
||||
_ref = $.x("preceding::span[@class][1]/text()[2]", image).textContent.match(/(\d+)x(\d+)/), _ = _ref[0], iw = _ref[1], ih = _ref[2];
|
||||
iw = Number(iw);
|
||||
ih = Number(ih);
|
||||
switch (imageType) {
|
||||
case 'full':
|
||||
image.removeAttribute('style');
|
||||
break;
|
||||
case 'fit width':
|
||||
if (iw > cw) {
|
||||
image.style.width = '100%';
|
||||
image.style.margin = '0px';
|
||||
}
|
||||
break;
|
||||
case 'fit screen':
|
||||
ratio = Math.min(cw / iw, ch / ih);
|
||||
if (ratio < 1) {
|
||||
image.style.width = Math.floor(ratio * iw);
|
||||
return image.style.margin = '0px';
|
||||
}
|
||||
}
|
||||
};
|
||||
imageThumb = function(thumb) {
|
||||
thumb.className = '';
|
||||
return $.remove(thumb.nextSibling);
|
||||
};
|
||||
changeCheckbox = function() {
|
||||
return GM_setValue(this.name, this.checked);
|
||||
};
|
||||
changeValue = function() {
|
||||
return GM_setValue(this.name, this.value);
|
||||
};
|
||||
recaptchaListener = function(e) {
|
||||
if (e.keyCode === 8 && this.value === '') {
|
||||
return recaptchaReload();
|
||||
}
|
||||
};
|
||||
recaptchaReload = function() {
|
||||
return window.location = 'javascript:Recaptcha.reload()';
|
||||
};
|
||||
redirect = function() {
|
||||
var url;
|
||||
switch (g.BOARD) {
|
||||
case 'a':
|
||||
case 'g':
|
||||
case 'lit':
|
||||
case 'sci':
|
||||
case 'tv':
|
||||
url = "http://green-oval.net/cgi-board.pl/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
||||
break;
|
||||
case 'cgl':
|
||||
case 'jp':
|
||||
case 'm':
|
||||
case 'tg':
|
||||
url = "http://archive.easymodo.net/cgi-board.pl/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
||||
break;
|
||||
case '3':
|
||||
case 'adv':
|
||||
case 'an':
|
||||
case 'c':
|
||||
case 'ck':
|
||||
case 'co':
|
||||
case 'fa':
|
||||
case 'fit':
|
||||
case 'int':
|
||||
case 'k':
|
||||
case 'mu':
|
||||
case 'n':
|
||||
case 'o':
|
||||
case 'p':
|
||||
case 'po':
|
||||
case 'soc':
|
||||
case 'sp':
|
||||
case 'toy':
|
||||
case 'trv':
|
||||
case 'v':
|
||||
case 'vp':
|
||||
case 'x':
|
||||
url = "http://archive.no-ip.org/" + g.BOARD + "/thread/" + g.THREAD_ID;
|
||||
break;
|
||||
default:
|
||||
url = "http://boards.4chan.org/" + g.BOARD;
|
||||
}
|
||||
return location.href = url;
|
||||
};
|
||||
report = function() {
|
||||
var input;
|
||||
input = $.x('preceding-sibling::input[1]', this);
|
||||
input.click();
|
||||
$('input[value="Report"]').click();
|
||||
return input.click();
|
||||
};
|
||||
updateFavicon = function() {
|
||||
var clone, favicon, href, len;
|
||||
len = g.replies.length;
|
||||
if (g.dead) {
|
||||
if (len > 0) {
|
||||
href = g.favDeadHalo;
|
||||
} else {
|
||||
href = g.favDead;
|
||||
}
|
||||
} else {
|
||||
if (len > 0) {
|
||||
href = g.favHalo;
|
||||
} else {
|
||||
href = g.favDefault;
|
||||
}
|
||||
}
|
||||
favicon = $('link[rel="shortcut icon"]', d);
|
||||
clone = favicon.cloneNode(true);
|
||||
clone.href = href;
|
||||
return $.replace(favicon, clone);
|
||||
};
|
||||
updateTitle = function() {
|
||||
var len;
|
||||
len = g.replies.length;
|
||||
d.title = d.title.replace(/\d+/, len);
|
||||
return updateFavicon();
|
||||
};
|
||||
NAMESPACE = 'AEOS.4chan_x.';
|
||||
g = {
|
||||
cache: {},
|
||||
|
||||
334
script.coffee
334
script.coffee
@ -274,11 +274,6 @@ $$ = (selector, root=d.body) ->
|
||||
node for node in result
|
||||
|
||||
#funks
|
||||
autoWatch = ->
|
||||
#TODO look for subject
|
||||
autoText = $('textarea', this).value.slice(0, 25)
|
||||
GM_setValue('autoText', "/#{g.BOARD}/ - #{autoText}")
|
||||
|
||||
expandComment =
|
||||
init: ->
|
||||
for a in $$ 'span.abbr a'
|
||||
@ -474,83 +469,6 @@ imageHover =
|
||||
$.unbind target, 'mousemove', imageHover.cb.mousemove
|
||||
$.unbind target, 'mouseout', imageHover.cb.mouseout
|
||||
|
||||
imageClick = (e) ->
|
||||
return if e.shiftKey or e.altKey or e.ctrlKey
|
||||
e.preventDefault()
|
||||
imageToggle this
|
||||
|
||||
imageToggle = (image) ->
|
||||
# 'image' is actually the <a> container
|
||||
thumb = image.firstChild
|
||||
cw = d.body.clientWidth
|
||||
ch = d.body.clientHeight
|
||||
imageType = $("#imageType").value
|
||||
if thumb.className is 'hide'
|
||||
imageThumb thumb
|
||||
else
|
||||
imageExpand thumb, cw, ch, imageType
|
||||
|
||||
imageTypeChange = ->
|
||||
images = $$ 'img[md5] + img'
|
||||
cw = d.body.clientWidth
|
||||
ch = d.body.clientHeight
|
||||
imageType = @value
|
||||
for image in images
|
||||
imageResize cw, ch, imageType, image
|
||||
|
||||
imageExpandClick = ->
|
||||
thumbs = $$ 'img[md5]'
|
||||
g.expand = @checked
|
||||
cw = d.body.clientWidth
|
||||
ch = d.body.clientHeight
|
||||
imageType = $("#imageType").value
|
||||
if @checked #expand
|
||||
for thumb in thumbs
|
||||
if thumb.className isnt 'hide'
|
||||
#hide the thumb and show image
|
||||
imageExpand thumb, cw, ch, imageType
|
||||
else #contract
|
||||
for thumb in thumbs
|
||||
if thumb.className is 'hide'
|
||||
#unhide thumb and remove image
|
||||
imageThumb thumb
|
||||
|
||||
|
||||
imageExpand = (thumb, cw, ch, imageType) ->
|
||||
thumb.className = 'hide'
|
||||
link = thumb.parentNode
|
||||
image = $.el 'img',
|
||||
src: link.href
|
||||
link.appendChild image
|
||||
|
||||
imageResize cw, ch, imageType, image
|
||||
|
||||
imageResize = (cw, ch, imageType, image) ->
|
||||
[_, iw, ih] =
|
||||
$.x("preceding::span[@class][1]/text()[2]", image)
|
||||
.textContent.match(/(\d+)x(\d+)/)
|
||||
iw = Number iw
|
||||
ih = Number ih
|
||||
|
||||
switch imageType
|
||||
when 'full'
|
||||
image.removeAttribute 'style'
|
||||
return
|
||||
when 'fit width'
|
||||
if iw > cw
|
||||
image.style.width = '100%'
|
||||
image.style.margin = '0px'
|
||||
break
|
||||
when 'fit screen'
|
||||
ratio = Math.min cw/iw, ch/ih
|
||||
if ratio < 1
|
||||
image.style.width = Math.floor ratio * iw
|
||||
image.style.margin = '0px'
|
||||
|
||||
imageThumb = (thumb) ->
|
||||
thumb.className = ''
|
||||
$.remove thumb.nextSibling
|
||||
|
||||
keybinds =
|
||||
init: ->
|
||||
$.bind d, 'keydown', keybinds.cb.keydown
|
||||
@ -757,40 +675,6 @@ nav =
|
||||
{top} = nav.threads[i].getBoundingClientRect()
|
||||
window.scrollBy 0, top
|
||||
|
||||
scrollThread = (count) ->
|
||||
[thread, idx] = getThread()
|
||||
top = thread.getBoundingClientRect().top
|
||||
if idx is 0 and top > 1
|
||||
#we haven't scrolled to the first thread
|
||||
idx = -1
|
||||
if count < 0 and top < -1
|
||||
#we've started scrolling past this thread,
|
||||
# but now want to read from the beginning
|
||||
count++
|
||||
temp = idx + count
|
||||
if temp < 0
|
||||
hash = ''
|
||||
else if temp > 9
|
||||
hash = 'p9'
|
||||
else
|
||||
hash = "p#{temp}"
|
||||
location.hash = hash
|
||||
|
||||
nodeInserted = (e) ->
|
||||
target = e.target
|
||||
if target.nodeName is 'TABLE'
|
||||
for callback in g.callbacks
|
||||
callback target
|
||||
else if target.id is 'recaptcha_challenge_field' and dialog = $ '#qr'
|
||||
$('#recaptcha_image img', dialog).src = "http://www.google.com/recaptcha/api/image?c=" + target.value
|
||||
$('#recaptcha_challenge_field', dialog).value = target.value
|
||||
|
||||
changeCheckbox = ->
|
||||
GM_setValue @name, @checked
|
||||
|
||||
changeValue = ->
|
||||
GM_setValue @name, @value
|
||||
|
||||
options =
|
||||
init: ->
|
||||
home = $ '#navtopr a'
|
||||
@ -1057,39 +941,6 @@ qr =
|
||||
}
|
||||
GM_setValue 'watched', JSON.stringify g.watched
|
||||
|
||||
recaptchaListener = (e) ->
|
||||
if e.keyCode is 8 and @value is ''
|
||||
recaptchaReload()
|
||||
|
||||
recaptchaReload = ->
|
||||
window.location = 'javascript:Recaptcha.reload()'
|
||||
|
||||
redirect = ->
|
||||
switch g.BOARD
|
||||
when 'a', 'g', 'lit', 'sci', 'tv'
|
||||
url = "http://green-oval.net/cgi-board.pl/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
||||
when 'cgl', 'jp', 'm', 'tg'
|
||||
url = "http://archive.easymodo.net/cgi-board.pl/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
||||
when '3', 'adv', 'an', 'c', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'soc', 'sp', 'toy', 'trv', 'v', 'vp', 'x'
|
||||
url = "http://archive.no-ip.org/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
||||
else
|
||||
url = "http://boards.4chan.org/#{g.BOARD}"
|
||||
location.href = url
|
||||
|
||||
replyNav = ->
|
||||
if g.REPLY
|
||||
window.location = if @textContent is '▲' then '#navtop' else '#navbot'
|
||||
else
|
||||
direction = if @textContent is '▲' then 'preceding' else 'following'
|
||||
op = $.x("#{direction}::span[starts-with(@id, 'nothread')][1]", this).id
|
||||
window.location = "##{op}"
|
||||
|
||||
report = ->
|
||||
input = $.x('preceding-sibling::input[1]', this)
|
||||
input.click()
|
||||
$('input[value="Report"]').click()
|
||||
input.click()
|
||||
|
||||
threadHiding =
|
||||
init: ->
|
||||
node = $ 'form[name=delform] > *'
|
||||
@ -1190,28 +1041,6 @@ threadHiding =
|
||||
unless node.nodeName is 'CENTER'
|
||||
threadHiding.thread node
|
||||
|
||||
updateFavicon = ->
|
||||
len = g.replies.length
|
||||
if g.dead
|
||||
if len > 0
|
||||
href = g.favDeadHalo
|
||||
else
|
||||
href = g.favDead
|
||||
else
|
||||
if len > 0
|
||||
href = g.favHalo
|
||||
else
|
||||
href = g.favDefault
|
||||
favicon = $ 'link[rel="shortcut icon"]', d
|
||||
clone = favicon.cloneNode true
|
||||
clone.href = href
|
||||
$.replace favicon, clone
|
||||
|
||||
updateTitle = ->
|
||||
len = g.replies.length
|
||||
d.title = d.title.replace /\d+/, len
|
||||
updateFavicon()
|
||||
|
||||
updater =
|
||||
init: ->
|
||||
html = "<div class=move><span id=count></span> <span id=timer></span></div>"
|
||||
@ -1406,6 +1235,169 @@ watcher =
|
||||
|
||||
watcher.addLink props
|
||||
|
||||
# TODO rewrite these
|
||||
scrollThread = (count) ->
|
||||
[thread, idx] = getThread()
|
||||
top = thread.getBoundingClientRect().top
|
||||
if idx is 0 and top > 1
|
||||
#we haven't scrolled to the first thread
|
||||
idx = -1
|
||||
if count < 0 and top < -1
|
||||
#we've started scrolling past this thread,
|
||||
# but now want to read from the beginning
|
||||
count++
|
||||
temp = idx + count
|
||||
if temp < 0
|
||||
hash = ''
|
||||
else if temp > 9
|
||||
hash = 'p9'
|
||||
else
|
||||
hash = "p#{temp}"
|
||||
location.hash = hash
|
||||
|
||||
nodeInserted = (e) ->
|
||||
target = e.target
|
||||
if target.nodeName is 'TABLE'
|
||||
for callback in g.callbacks
|
||||
callback target
|
||||
else if target.id is 'recaptcha_challenge_field' and dialog = $ '#qr'
|
||||
$('#recaptcha_image img', dialog).src = "http://www.google.com/recaptcha/api/image?c=" + target.value
|
||||
$('#recaptcha_challenge_field', dialog).value = target.value
|
||||
|
||||
autoWatch = ->
|
||||
#TODO look for subject
|
||||
autoText = $('textarea', this).value.slice(0, 25)
|
||||
GM_setValue('autoText', "/#{g.BOARD}/ - #{autoText}")
|
||||
|
||||
imageClick = (e) ->
|
||||
return if e.shiftKey or e.altKey or e.ctrlKey
|
||||
e.preventDefault()
|
||||
imageToggle this
|
||||
|
||||
imageToggle = (image) ->
|
||||
# 'image' is actually the <a> container
|
||||
thumb = image.firstChild
|
||||
cw = d.body.clientWidth
|
||||
ch = d.body.clientHeight
|
||||
imageType = $("#imageType").value
|
||||
if thumb.className is 'hide'
|
||||
imageThumb thumb
|
||||
else
|
||||
imageExpand thumb, cw, ch, imageType
|
||||
|
||||
imageTypeChange = ->
|
||||
images = $$ 'img[md5] + img'
|
||||
cw = d.body.clientWidth
|
||||
ch = d.body.clientHeight
|
||||
imageType = @value
|
||||
for image in images
|
||||
imageResize cw, ch, imageType, image
|
||||
|
||||
imageExpandClick = ->
|
||||
thumbs = $$ 'img[md5]'
|
||||
g.expand = @checked
|
||||
cw = d.body.clientWidth
|
||||
ch = d.body.clientHeight
|
||||
imageType = $("#imageType").value
|
||||
if @checked #expand
|
||||
for thumb in thumbs
|
||||
if thumb.className isnt 'hide'
|
||||
#hide the thumb and show image
|
||||
imageExpand thumb, cw, ch, imageType
|
||||
else #contract
|
||||
for thumb in thumbs
|
||||
if thumb.className is 'hide'
|
||||
#unhide thumb and remove image
|
||||
imageThumb thumb
|
||||
|
||||
imageExpand = (thumb, cw, ch, imageType) ->
|
||||
thumb.className = 'hide'
|
||||
link = thumb.parentNode
|
||||
image = $.el 'img',
|
||||
src: link.href
|
||||
link.appendChild image
|
||||
|
||||
imageResize cw, ch, imageType, image
|
||||
|
||||
imageResize = (cw, ch, imageType, image) ->
|
||||
[_, iw, ih] =
|
||||
$.x("preceding::span[@class][1]/text()[2]", image)
|
||||
.textContent.match(/(\d+)x(\d+)/)
|
||||
iw = Number iw
|
||||
ih = Number ih
|
||||
|
||||
switch imageType
|
||||
when 'full'
|
||||
image.removeAttribute 'style'
|
||||
return
|
||||
when 'fit width'
|
||||
if iw > cw
|
||||
image.style.width = '100%'
|
||||
image.style.margin = '0px'
|
||||
break
|
||||
when 'fit screen'
|
||||
ratio = Math.min cw/iw, ch/ih
|
||||
if ratio < 1
|
||||
image.style.width = Math.floor ratio * iw
|
||||
image.style.margin = '0px'
|
||||
|
||||
imageThumb = (thumb) ->
|
||||
thumb.className = ''
|
||||
$.remove thumb.nextSibling
|
||||
|
||||
changeCheckbox = ->
|
||||
GM_setValue @name, @checked
|
||||
|
||||
changeValue = ->
|
||||
GM_setValue @name, @value
|
||||
|
||||
recaptchaListener = (e) ->
|
||||
if e.keyCode is 8 and @value is ''
|
||||
recaptchaReload()
|
||||
|
||||
recaptchaReload = ->
|
||||
window.location = 'javascript:Recaptcha.reload()'
|
||||
|
||||
redirect = ->
|
||||
switch g.BOARD
|
||||
when 'a', 'g', 'lit', 'sci', 'tv'
|
||||
url = "http://green-oval.net/cgi-board.pl/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
||||
when 'cgl', 'jp', 'm', 'tg'
|
||||
url = "http://archive.easymodo.net/cgi-board.pl/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
||||
when '3', 'adv', 'an', 'c', 'ck', 'co', 'fa', 'fit', 'int', 'k', 'mu', 'n', 'o', 'p', 'po', 'soc', 'sp', 'toy', 'trv', 'v', 'vp', 'x'
|
||||
url = "http://archive.no-ip.org/#{g.BOARD}/thread/#{g.THREAD_ID}"
|
||||
else
|
||||
url = "http://boards.4chan.org/#{g.BOARD}"
|
||||
location.href = url
|
||||
|
||||
report = ->
|
||||
input = $.x('preceding-sibling::input[1]', this)
|
||||
input.click()
|
||||
$('input[value="Report"]').click()
|
||||
input.click()
|
||||
|
||||
updateFavicon = ->
|
||||
len = g.replies.length
|
||||
if g.dead
|
||||
if len > 0
|
||||
href = g.favDeadHalo
|
||||
else
|
||||
href = g.favDead
|
||||
else
|
||||
if len > 0
|
||||
href = g.favHalo
|
||||
else
|
||||
href = g.favDefault
|
||||
favicon = $ 'link[rel="shortcut icon"]', d
|
||||
clone = favicon.cloneNode true
|
||||
clone.href = href
|
||||
$.replace favicon, clone
|
||||
|
||||
updateTitle = ->
|
||||
len = g.replies.length
|
||||
d.title = d.title.replace /\d+/, len
|
||||
updateFavicon()
|
||||
|
||||
#main
|
||||
NAMESPACE = 'AEOS.4chan_x.'
|
||||
g =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user