begin thread hiding rewrite
This commit is contained in:
parent
110fe98fd9
commit
7c6772bdba
151
4chan_x.js
151
4chan_x.js
@ -58,7 +58,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, DAY, a, arr, as, autoWatch, callback, changeCheckbox, changeValue, clearHidden, config, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, g, getThread, hideReply, hideThread, href, html, i, id, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, img, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, log, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyNav, report, request, scroll, scrollThread, showReply, showThread, span, src, start, stopPropagation, temp, text, textContent, threadF, threads, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updaterMake, watch, watchX, watcher, watcherUpdate, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _len7, _m, _n, _ref, _ref2, _ref3, _ref4;
|
var $, $$, DAY, a, arr, as, autoWatch, callback, changeCheckbox, changeValue, clearHidden, config, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, g, getThread, hideReply, hideThread, href, html, i, id, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, img, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, log, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyNav, report, request, scroll, scrollThread, showReply, showThread, span, src, stopPropagation, temp, text, textContent, threadHiding, threads, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updaterMake, watch, watchX, watcher, watcherUpdate, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _len7, _m, _n, _ref, _ref2, _ref3, _ref4;
|
||||||
var __slice = Array.prototype.slice;
|
var __slice = Array.prototype.slice;
|
||||||
if (typeof console != "undefined" && console !== null) {
|
if (typeof console != "undefined" && console !== null) {
|
||||||
log = console.log;
|
log = console.log;
|
||||||
@ -290,6 +290,9 @@
|
|||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
},
|
},
|
||||||
|
prepend: function(parent, child) {
|
||||||
|
return parent.insertBefore(child, parent.firstChild);
|
||||||
|
},
|
||||||
after: function(root, el) {
|
after: function(root, el) {
|
||||||
return root.parentNode.insertBefore(el, root.nextSibling);
|
return root.parentNode.insertBefore(el, root.nextSibling);
|
||||||
},
|
},
|
||||||
@ -471,35 +474,6 @@
|
|||||||
return $.before(table, div);
|
return $.before(table, div);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
hideThread = function(div) {
|
|
||||||
var a, name, num, p, span, text, trip, _ref;
|
|
||||||
if (p = this.parentNode) {
|
|
||||||
div = p;
|
|
||||||
g.hiddenThreads.push({
|
|
||||||
id: div.id,
|
|
||||||
timestamp: Date.now()
|
|
||||||
});
|
|
||||||
GM_setValue("hiddenThreads/" + g.BOARD + "/", JSON.stringify(g.hiddenThreads));
|
|
||||||
}
|
|
||||||
$.hide(div);
|
|
||||||
if ($.config('Show Stubs')) {
|
|
||||||
if (span = $('.omittedposts', div)) {
|
|
||||||
num = Number(span.textContent.match(/\d+/)[0]);
|
|
||||||
} else {
|
|
||||||
num = 0;
|
|
||||||
}
|
|
||||||
num += $$('table', div).length;
|
|
||||||
text = num === 1 ? "1 reply" : "" + num + " replies";
|
|
||||||
name = $('span.postername', div).textContent;
|
|
||||||
trip = ((_ref = $('span.postername + span.postertrip', div)) != null ? _ref.textContent : void 0) || '';
|
|
||||||
a = $.el('a', {
|
|
||||||
textContent: "[ + ] " + name + trip + " (" + text + ")",
|
|
||||||
className: 'pointer'
|
|
||||||
});
|
|
||||||
$.bind(a, 'click', showThread);
|
|
||||||
return $.before(div, a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
imageHover = {
|
imageHover = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var img;
|
var img;
|
||||||
@ -1278,36 +1252,90 @@
|
|||||||
stopPropagation = function(e) {
|
stopPropagation = function(e) {
|
||||||
return e.stopPropagation();
|
return e.stopPropagation();
|
||||||
};
|
};
|
||||||
threadF = function(current) {
|
hideThread = function(div) {
|
||||||
var a, div, hidden, id, _i, _len, _ref;
|
var a, name, num, p, span, text, trip, _ref;
|
||||||
div = $.el('div', {
|
if (p = this.parentNode) {
|
||||||
className: 'thread'
|
div = p;
|
||||||
});
|
g.hiddenThreads.push({
|
||||||
a = $.el('a', {
|
id: div.id,
|
||||||
textContent: '[ - ]',
|
timestamp: Date.now()
|
||||||
className: 'pointer'
|
});
|
||||||
});
|
GM_setValue("hiddenThreads/" + g.BOARD + "/", JSON.stringify(g.hiddenThreads));
|
||||||
$.bind(a, 'click', hideThread);
|
|
||||||
$.append(div, a);
|
|
||||||
$.before(current, div);
|
|
||||||
while (!current.clear) {
|
|
||||||
$.append(div, current);
|
|
||||||
current = div.nextSibling;
|
|
||||||
}
|
}
|
||||||
$.append(div, current);
|
$.hide(div);
|
||||||
current = div.nextSibling;
|
if ($.config('Show Stubs')) {
|
||||||
id = $('input[value="delete"]', div).name;
|
if (span = $('.omittedposts', div)) {
|
||||||
div.id = id;
|
num = Number(span.textContent.match(/\d+/)[0]);
|
||||||
_ref = g.hiddenThreads;
|
} else {
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
num = 0;
|
||||||
hidden = _ref[_i];
|
|
||||||
if (id === hidden.id) {
|
|
||||||
hideThread(div);
|
|
||||||
}
|
}
|
||||||
|
num += $$('table', div).length;
|
||||||
|
text = num === 1 ? "1 reply" : "" + num + " replies";
|
||||||
|
name = $('span.postername', div).textContent;
|
||||||
|
trip = ((_ref = $('span.postername + span.postertrip', div)) != null ? _ref.textContent : void 0) || '';
|
||||||
|
a = $.el('a', {
|
||||||
|
textContent: "[ + ] " + name + trip + " (" + text + ")",
|
||||||
|
className: 'pointer'
|
||||||
|
});
|
||||||
|
$.bind(a, 'click', showThread);
|
||||||
|
return $.before(div, a);
|
||||||
}
|
}
|
||||||
current = current.nextSibling.nextSibling;
|
};
|
||||||
if (current.nodeName !== 'CENTER') {
|
threadHiding = {
|
||||||
return threadF(current);
|
init: function() {
|
||||||
|
var a, hiddenThreads, id, node, thread, _i, _len, _ref, _results;
|
||||||
|
node = $('form[name=delform] > *');
|
||||||
|
threadHiding.thread(node);
|
||||||
|
hiddenThreads = JSON.parse(GM_getValue("hiddenThread/" + g.BOARD + "/", '{}'));
|
||||||
|
_ref = $$('div.thread');
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
thread = _ref[_i];
|
||||||
|
a = $.el('a', {
|
||||||
|
textContent: '[ - ]'
|
||||||
|
});
|
||||||
|
$.bind(a, 'click', threadHiding.cb.hide);
|
||||||
|
$.prepend(thread, a);
|
||||||
|
id = $('input[value=delete]', thread).name;
|
||||||
|
_results.push(id in hiddenThreads ? threadHiding.hideHide(thread) : void 0);
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
},
|
||||||
|
cb: {
|
||||||
|
hide: function(e) {
|
||||||
|
var thread;
|
||||||
|
thread = e.target.parentNode;
|
||||||
|
return threadHiding.hide(thread);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hide: function(thread) {
|
||||||
|
var hiddenThreads, id;
|
||||||
|
threadHiding.hideHide(thread);
|
||||||
|
id = $('input[value=delete]', thread).name;
|
||||||
|
hiddenThreads = JSON.parse(GM_getValue("hiddenThread/" + g.BOARD + "/", '{}'));
|
||||||
|
hiddenThreads[id] = Date.now();
|
||||||
|
return GM_setValue("hiddenThread/" + g.BOARD + "/", JSON.stringify(hiddenThreads));
|
||||||
|
},
|
||||||
|
hideHide: function(thread) {
|
||||||
|
if (true) {
|
||||||
|
$.hide(thread);
|
||||||
|
return $.hide(thread.nextSibling);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
thread: function(node) {
|
||||||
|
var div;
|
||||||
|
div = $.el('div', {
|
||||||
|
className: 'thread'
|
||||||
|
});
|
||||||
|
$.before(node, div);
|
||||||
|
while (node.nodeName !== 'HR') {
|
||||||
|
$.append(div, node);
|
||||||
|
node = div.nextSibling;
|
||||||
|
}
|
||||||
|
node = node.nextElementSibling;
|
||||||
|
if (node.nodeName !== 'CENTER') {
|
||||||
|
return threadHiding.thread(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
request = function(url, callback) {
|
request = function(url, callback) {
|
||||||
@ -2005,14 +2033,7 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($.config('Thread Hiding')) {
|
if ($.config('Thread Hiding')) {
|
||||||
delform = $('form[name=delform]');
|
threadHiding.init();
|
||||||
start = $('form[name=delform] > *');
|
|
||||||
if ($.config('Image Expansion')) {
|
|
||||||
start = start.nextSibling;
|
|
||||||
}
|
|
||||||
$.bind(d, 'DOMNodeInserted', stopPropagation);
|
|
||||||
threadF(start);
|
|
||||||
$.unbind(d, 'DOMNodeInserted', stopPropagation);
|
|
||||||
}
|
}
|
||||||
if ($.config('Auto Watch')) {
|
if ($.config('Auto Watch')) {
|
||||||
$.bind($('form[name=post]'), 'submit', autoWatch);
|
$.bind($('form[name=post]'), 'submit', autoWatch);
|
||||||
|
|||||||
128
script.coffee
128
script.coffee
@ -162,6 +162,8 @@ $.extend $,
|
|||||||
append: (parent, children...) ->
|
append: (parent, children...) ->
|
||||||
for child in children
|
for child in children
|
||||||
parent.appendChild child
|
parent.appendChild child
|
||||||
|
prepend: (parent, child) ->
|
||||||
|
parent.insertBefore child, parent.firstChild
|
||||||
after: (root, el) ->
|
after: (root, el) ->
|
||||||
root.parentNode.insertBefore el, root.nextSibling
|
root.parentNode.insertBefore el, root.nextSibling
|
||||||
before: (root, el) ->
|
before: (root, el) ->
|
||||||
@ -319,30 +321,6 @@ hideReply = (reply) ->
|
|||||||
$.append div, a
|
$.append div, a
|
||||||
$.before table, div
|
$.before table, div
|
||||||
|
|
||||||
hideThread = (div) ->
|
|
||||||
if p = @parentNode
|
|
||||||
div = p
|
|
||||||
g.hiddenThreads.push {
|
|
||||||
id: div.id
|
|
||||||
timestamp: Date.now()
|
|
||||||
}
|
|
||||||
GM_setValue("hiddenThreads/#{g.BOARD}/", JSON.stringify(g.hiddenThreads))
|
|
||||||
$.hide div
|
|
||||||
if $.config 'Show Stubs'
|
|
||||||
if span = $ '.omittedposts', div
|
|
||||||
num = Number(span.textContent.match(/\d+/)[0])
|
|
||||||
else
|
|
||||||
num = 0
|
|
||||||
num += $$('table', div).length
|
|
||||||
text = if num is 1 then "1 reply" else "#{num} replies"
|
|
||||||
name = $('span.postername', div).textContent
|
|
||||||
trip = $('span.postername + span.postertrip', div)?.textContent || ''
|
|
||||||
a = $.el 'a',
|
|
||||||
textContent: "[ + ] #{name}#{trip} (#{text})"
|
|
||||||
className: 'pointer'
|
|
||||||
$.bind a, 'click', showThread
|
|
||||||
$.before div, a
|
|
||||||
|
|
||||||
imageHover =
|
imageHover =
|
||||||
init: ->
|
init: ->
|
||||||
img = $.el 'img', id: 'iHover'
|
img = $.el 'img', id: 'iHover'
|
||||||
@ -951,29 +929,77 @@ showThread = ->
|
|||||||
stopPropagation = (e) ->
|
stopPropagation = (e) ->
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|
||||||
threadF = (current) ->
|
hideThread = (div) ->
|
||||||
div = $.el 'div',
|
if p = @parentNode
|
||||||
className: 'thread'
|
div = p
|
||||||
a = $.el 'a',
|
g.hiddenThreads.push {
|
||||||
textContent: '[ - ]'
|
id: div.id
|
||||||
className: 'pointer'
|
timestamp: Date.now()
|
||||||
$.bind a, 'click', hideThread
|
}
|
||||||
$.append div, a
|
GM_setValue("hiddenThreads/#{g.BOARD}/", JSON.stringify(g.hiddenThreads))
|
||||||
$.before current, div
|
$.hide div
|
||||||
while (!current.clear)#<br clear>
|
if $.config 'Show Stubs'
|
||||||
$.append div, current
|
if span = $ '.omittedposts', div
|
||||||
current = div.nextSibling
|
num = Number(span.textContent.match(/\d+/)[0])
|
||||||
$.append div, current
|
else
|
||||||
current = div.nextSibling
|
num = 0
|
||||||
id = $('input[value="delete"]', div).name
|
num += $$('table', div).length
|
||||||
div.id = id
|
text = if num is 1 then "1 reply" else "#{num} replies"
|
||||||
#check if we should hide the thread
|
name = $('span.postername', div).textContent
|
||||||
for hidden in g.hiddenThreads
|
trip = $('span.postername + span.postertrip', div)?.textContent || ''
|
||||||
if id == hidden.id
|
a = $.el 'a',
|
||||||
hideThread(div)
|
textContent: "[ + ] #{name}#{trip} (#{text})"
|
||||||
current = current.nextSibling.nextSibling
|
className: 'pointer'
|
||||||
if current.nodeName isnt 'CENTER'
|
$.bind a, 'click', showThread
|
||||||
threadF(current)
|
$.before div, a
|
||||||
|
|
||||||
|
threadHiding =
|
||||||
|
init: ->
|
||||||
|
node = $ 'form[name=delform] > *'
|
||||||
|
threadHiding.thread node
|
||||||
|
|
||||||
|
hiddenThreads = JSON.parse GM_getValue "hiddenThread/#{g.BOARD}/", '{}'
|
||||||
|
for thread in $$ 'div.thread'
|
||||||
|
a = $.el 'a',
|
||||||
|
textContent: '[ - ]'
|
||||||
|
$.bind a, 'click', threadHiding.cb.hide
|
||||||
|
$.prepend thread, a
|
||||||
|
|
||||||
|
id = $('input[value=delete]', thread).name
|
||||||
|
if id of hiddenThreads
|
||||||
|
threadHiding.hideHide thread
|
||||||
|
|
||||||
|
cb:
|
||||||
|
hide: (e) ->
|
||||||
|
thread = e.target.parentNode
|
||||||
|
threadHiding.hide thread
|
||||||
|
|
||||||
|
hide: (thread) ->
|
||||||
|
threadHiding.hideHide thread
|
||||||
|
|
||||||
|
id = $('input[value=delete]', thread).name
|
||||||
|
|
||||||
|
hiddenThreads = JSON.parse GM_getValue "hiddenThread/#{g.BOARD}/", '{}'
|
||||||
|
hiddenThreads[id] = Date.now()
|
||||||
|
GM_setValue "hiddenThread/#{g.BOARD}/", JSON.stringify hiddenThreads
|
||||||
|
|
||||||
|
hideHide: (thread) ->
|
||||||
|
if true
|
||||||
|
$.hide thread
|
||||||
|
$.hide thread.nextSibling
|
||||||
|
|
||||||
|
thread: (node) ->
|
||||||
|
div = $.el 'div',
|
||||||
|
className: 'thread'
|
||||||
|
$.before node, div
|
||||||
|
|
||||||
|
while node.nodeName isnt 'HR'
|
||||||
|
$.append div, node
|
||||||
|
node = div.nextSibling
|
||||||
|
|
||||||
|
node = node.nextElementSibling #skip text node
|
||||||
|
unless node.nodeName is 'CENTER'
|
||||||
|
threadHiding.thread node
|
||||||
|
|
||||||
request = (url, callback) ->
|
request = (url, callback) ->
|
||||||
r = new XMLHttpRequest()
|
r = new XMLHttpRequest()
|
||||||
@ -1543,13 +1569,7 @@ if g.REPLY
|
|||||||
|
|
||||||
else #not reply
|
else #not reply
|
||||||
if $.config 'Thread Hiding'
|
if $.config 'Thread Hiding'
|
||||||
delform = $('form[name=delform]')
|
threadHiding.init()
|
||||||
start = $ 'form[name=delform] > *'
|
|
||||||
start = start.nextSibling if $.config 'Image Expansion' #skip over image expansion dialog
|
|
||||||
#don't confuse other scripts
|
|
||||||
$.bind d, 'DOMNodeInserted', stopPropagation
|
|
||||||
threadF start
|
|
||||||
$.unbind d, 'DOMNodeInserted', stopPropagation
|
|
||||||
|
|
||||||
if $.config 'Auto Watch'
|
if $.config 'Auto Watch'
|
||||||
$.bind $('form[name=post]'), 'submit', autoWatch
|
$.bind $('form[name=post]'), 'submit', autoWatch
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user