And done!
This commit is contained in:
parent
c0ceefcfad
commit
d327605729
@ -78,6 +78,7 @@
|
|||||||
Filtering: {
|
Filtering: {
|
||||||
'Anonymize': [false, 'Make everybody anonymous'],
|
'Anonymize': [false, 'Make everybody anonymous'],
|
||||||
'Filter': [false, 'Self-moderation placebo'],
|
'Filter': [false, 'Self-moderation placebo'],
|
||||||
|
'Filter OPs': [false, 'Filter OPs along with their threads'],
|
||||||
'Reply Hiding': [true, 'Hide single replies'],
|
'Reply Hiding': [true, 'Hide single replies'],
|
||||||
'Thread Hiding': [true, 'Hide entire threads'],
|
'Thread Hiding': [true, 'Hide entire threads'],
|
||||||
'Show Stubs': [true, 'Of hidden threads / replies']
|
'Show Stubs': [true, 'Of hidden threads / replies']
|
||||||
@ -528,14 +529,14 @@
|
|||||||
};
|
};
|
||||||
filter = {
|
filter = {
|
||||||
regexps: {},
|
regexps: {},
|
||||||
|
callbacks: [],
|
||||||
init: function() {
|
init: function() {
|
||||||
var filter, key, m, regx, _i, _len, _results;
|
var filter, key, m, regx, _i, _len;
|
||||||
HTMLBlockquoteElement.prototype.toString = function() {
|
HTMLBlockquoteElement.prototype.toString = function() {
|
||||||
return ($.el('a', {
|
return ($.el('a', {
|
||||||
innerHTML: this.innerHTML.replace(/<br>/g, '\n')
|
innerHTML: this.innerHTML.replace(/<br>/g, '\n')
|
||||||
})).textContent;
|
})).textContent;
|
||||||
};
|
};
|
||||||
_results = [];
|
|
||||||
for (key in config.filter) {
|
for (key in config.filter) {
|
||||||
if (!(m = conf[key].match(/(.+)/g))) {
|
if (!(m = conf[key].match(/(.+)/g))) {
|
||||||
continue;
|
continue;
|
||||||
@ -549,9 +550,35 @@
|
|||||||
}
|
}
|
||||||
} catch (_e) {}
|
} catch (_e) {}
|
||||||
}
|
}
|
||||||
_results.push(this.regexps[key].length ? g.callbacks.push(this[key]) : void 0);
|
if (this.regexps[key].length) {
|
||||||
|
this.callbacks.push(this[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return g.callbacks.push(this.node);
|
||||||
|
},
|
||||||
|
node: function(root) {
|
||||||
|
var callback, _i, _j, _len, _len2, _ref, _ref2;
|
||||||
|
if (root.className === 'op') {
|
||||||
|
if (!g.REPLY && conf['Filter OPs']) {
|
||||||
|
_ref = filter.callbacks;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
callback = _ref[_i];
|
||||||
|
if (callback(root)) {
|
||||||
|
threadHiding.hideHide(root.parentNode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (!root.classList.contains('inline')) {
|
||||||
|
_ref2 = filter.callbacks;
|
||||||
|
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
||||||
|
callback = _ref2[_j];
|
||||||
|
if (callback(root)) {
|
||||||
|
replyHiding.hideHide($('td:not([nowrap])', root));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return _results;
|
|
||||||
},
|
},
|
||||||
test: function(key, value) {
|
test: function(key, value) {
|
||||||
var regexp, _i, _len, _ref;
|
var regexp, _i, _len, _ref;
|
||||||
@ -565,52 +592,45 @@
|
|||||||
},
|
},
|
||||||
name: function(root) {
|
name: function(root) {
|
||||||
var name;
|
var name;
|
||||||
if (!(name = root.className === 'op' ? $('.postername', root).textContent : $('.commentpostername', root).textContent)) {
|
if ((name = root.className === 'op' ? $('.postername', root).textContent : $('.commentpostername', root).textContent)) {
|
||||||
return;
|
return filter.test('name', name);
|
||||||
}
|
}
|
||||||
return filter.test('name', name);
|
|
||||||
},
|
},
|
||||||
trip: function(root) {
|
trip: function(root) {
|
||||||
var trip;
|
var trip;
|
||||||
if (!(trip = $('.postertrip', root))) {
|
if (trip = $('.postertrip', root)) {
|
||||||
return;
|
return filter.test('trip', trip.textContent);
|
||||||
}
|
}
|
||||||
return filter.test('trip', trip.textContent);
|
|
||||||
},
|
},
|
||||||
mail: function(root) {
|
mail: function(root) {
|
||||||
var mail;
|
var mail;
|
||||||
if (!(mail = $('.linkmail', root))) {
|
if (mail = $('.linkmail', root)) {
|
||||||
return;
|
return filter.test('mail', mail.href);
|
||||||
}
|
}
|
||||||
return filter.test('mail', mail.href);
|
|
||||||
},
|
},
|
||||||
sub: function(root) {
|
sub: function(root) {
|
||||||
var sub;
|
var sub;
|
||||||
if (!(sub = root.className === 'op' ? $('.filetitle', root).textContent : $('.replytitle', root).textContent)) {
|
if ((sub = root.className === 'op' ? $('.filetitle', root).textContent : $('.replytitle', root).textContent)) {
|
||||||
return;
|
return filter.test('sub', sub);
|
||||||
}
|
}
|
||||||
return filter.test('sub', sub);
|
|
||||||
},
|
},
|
||||||
com: function(root) {
|
com: function(root) {
|
||||||
var com;
|
var com;
|
||||||
if (!(com = $('blockquote', root).toString())) {
|
if (com = $('blockquote', root).toString()) {
|
||||||
return;
|
return filter.test('com', com);
|
||||||
}
|
}
|
||||||
return filter.test('com', com);
|
|
||||||
},
|
},
|
||||||
file: function(root) {
|
file: function(root) {
|
||||||
var file;
|
var file;
|
||||||
if (!(file = $('.filesize span', root))) {
|
if (file = $('.filesize span', root)) {
|
||||||
return;
|
return filter.test('file', file.title);
|
||||||
}
|
}
|
||||||
return filter.test('file', file.title);
|
|
||||||
},
|
},
|
||||||
md5: function(root) {
|
md5: function(root) {
|
||||||
var img;
|
var img;
|
||||||
if (!(img = $('img[md5]', root))) {
|
if (img = $('img[md5]', root)) {
|
||||||
return;
|
return filter.test('md5', img.getAttribute('md5'));
|
||||||
}
|
}
|
||||||
return filter.test('md5', img.getAttribute('md5'));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
expandComment = {
|
expandComment = {
|
||||||
@ -818,7 +838,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
hide: function(reply) {
|
hide: function(reply) {
|
||||||
var a, div, id, name, table, trip, _ref;
|
var id;
|
||||||
|
replyHiding.hideHide(reply);
|
||||||
|
id = reply.id;
|
||||||
|
g.hiddenReplies[id] = Date.now();
|
||||||
|
return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
|
||||||
|
},
|
||||||
|
hideHide: function(reply) {
|
||||||
|
var a, div, name, table, trip, _ref;
|
||||||
table = reply.parentNode.parentNode.parentNode;
|
table = reply.parentNode.parentNode.parentNode;
|
||||||
table.hidden = true;
|
table.hidden = true;
|
||||||
if (conf['Show Stubs']) {
|
if (conf['Show Stubs']) {
|
||||||
@ -832,11 +859,8 @@
|
|||||||
className: 'stub'
|
className: 'stub'
|
||||||
});
|
});
|
||||||
$.add(div, a);
|
$.add(div, a);
|
||||||
$.before(table, div);
|
return $.before(table, div);
|
||||||
}
|
}
|
||||||
id = reply.id;
|
|
||||||
g.hiddenReplies[id] = Date.now();
|
|
||||||
return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
|
|
||||||
},
|
},
|
||||||
show: function(table) {
|
show: function(table) {
|
||||||
var id;
|
var id;
|
||||||
|
|||||||
@ -12,6 +12,7 @@ config =
|
|||||||
Filtering:
|
Filtering:
|
||||||
'Anonymize': [false, 'Make everybody anonymous']
|
'Anonymize': [false, 'Make everybody anonymous']
|
||||||
'Filter': [false, 'Self-moderation placebo']
|
'Filter': [false, 'Self-moderation placebo']
|
||||||
|
'Filter OPs': [false, 'Filter OPs along with their threads']
|
||||||
'Reply Hiding': [true, 'Hide single replies']
|
'Reply Hiding': [true, 'Hide single replies']
|
||||||
'Thread Hiding': [true, 'Hide entire threads']
|
'Thread Hiding': [true, 'Hide entire threads']
|
||||||
'Show Stubs': [true, 'Of hidden threads / replies']
|
'Show Stubs': [true, 'Of hidden threads / replies']
|
||||||
@ -385,6 +386,7 @@ $$ = (selector, root=d.body) ->
|
|||||||
|
|
||||||
filter =
|
filter =
|
||||||
regexps: {}
|
regexps: {}
|
||||||
|
callbacks: []
|
||||||
init: ->
|
init: ->
|
||||||
HTMLBlockquoteElement.prototype.toString = ->
|
HTMLBlockquoteElement.prototype.toString = ->
|
||||||
return ($.el 'a', innerHTML: @innerHTML.replace /<br>/g, '\n').textContent
|
return ($.el 'a', innerHTML: @innerHTML.replace /<br>/g, '\n').textContent
|
||||||
@ -397,40 +399,47 @@ filter =
|
|||||||
try if (regx = eval filter).constructor is RegExp
|
try if (regx = eval filter).constructor is RegExp
|
||||||
@regexps[key].push regx
|
@regexps[key].push regx
|
||||||
#only execute what's filterable
|
#only execute what's filterable
|
||||||
g.callbacks.push @[key] if @regexps[key].length
|
@callbacks.push @[key] if @regexps[key].length
|
||||||
|
|
||||||
|
g.callbacks.push @node
|
||||||
|
|
||||||
|
node: (root) ->
|
||||||
|
if root.className is 'op'
|
||||||
|
if !g.REPLY and conf['Filter OPs']
|
||||||
|
for callback in filter.callbacks
|
||||||
|
if callback root
|
||||||
|
threadHiding.hideHide root.parentNode
|
||||||
|
return
|
||||||
|
else unless root.classList.contains('inline')
|
||||||
|
for callback in filter.callbacks
|
||||||
|
if callback root
|
||||||
|
replyHiding.hideHide $('td:not([nowrap])', root)
|
||||||
|
return
|
||||||
test: (key, value) ->
|
test: (key, value) ->
|
||||||
for regexp in filter.regexps[key]
|
for regexp in filter.regexps[key]
|
||||||
return true if regexp.test value
|
return true if regexp.test value
|
||||||
|
|
||||||
name: (root) ->
|
name: (root) ->
|
||||||
unless (name = if root.className is 'op' then $('.postername', root).textContent else $('.commentpostername', root).textContent)
|
if (name = if root.className is 'op' then $('.postername', root).textContent else $('.commentpostername', root).textContent)
|
||||||
return
|
filter.test 'name', name
|
||||||
filter.test 'name', name
|
|
||||||
trip: (root) ->
|
trip: (root) ->
|
||||||
unless trip = $('.postertrip', root)
|
if trip = $('.postertrip', root)
|
||||||
return
|
filter.test 'trip', trip.textContent
|
||||||
filter.test 'trip', trip.textContent
|
|
||||||
mail: (root) ->
|
mail: (root) ->
|
||||||
unless mail = $('.linkmail', root)
|
if mail = $('.linkmail', root)
|
||||||
return
|
filter.test 'mail', mail.href
|
||||||
filter.test 'mail', mail.href
|
|
||||||
sub: (root) ->
|
sub: (root) ->
|
||||||
unless(sub = if root.className is 'op' then $('.filetitle', root).textContent else $('.replytitle', root).textContent)
|
if (sub = if root.className is 'op' then $('.filetitle', root).textContent else $('.replytitle', root).textContent)
|
||||||
return
|
filter.test 'sub', sub
|
||||||
filter.test 'sub', sub
|
|
||||||
com: (root) ->
|
com: (root) ->
|
||||||
unless com = $('blockquote', root).toString()
|
if com = $('blockquote', root).toString()
|
||||||
return
|
filter.test 'com', com
|
||||||
filter.test 'com', com
|
|
||||||
file: (root) ->
|
file: (root) ->
|
||||||
unless file = $ '.filesize span', root
|
if file = $ '.filesize span', root
|
||||||
return
|
filter.test 'file', file.title
|
||||||
filter.test 'file', file.title
|
|
||||||
md5: (root) ->
|
md5: (root) ->
|
||||||
unless img = $ 'img[md5]', root
|
if img = $ 'img[md5]', root
|
||||||
return
|
filter.test 'md5', img.getAttribute('md5')
|
||||||
filter.test 'md5', img.getAttribute('md5')
|
|
||||||
|
|
||||||
expandComment =
|
expandComment =
|
||||||
init: ->
|
init: ->
|
||||||
@ -575,6 +584,13 @@ replyHiding =
|
|||||||
$.rm div
|
$.rm div
|
||||||
|
|
||||||
hide: (reply) ->
|
hide: (reply) ->
|
||||||
|
replyHiding.hideHide reply
|
||||||
|
|
||||||
|
id = reply.id
|
||||||
|
g.hiddenReplies[id] = Date.now()
|
||||||
|
$.set "hiddenReplies/#{g.BOARD}/", g.hiddenReplies
|
||||||
|
|
||||||
|
hideHide: (reply) ->
|
||||||
table = reply.parentNode.parentNode.parentNode
|
table = reply.parentNode.parentNode.parentNode
|
||||||
table.hidden = true
|
table.hidden = true
|
||||||
|
|
||||||
@ -590,10 +606,6 @@ replyHiding =
|
|||||||
$.add div, a
|
$.add div, a
|
||||||
$.before table, div
|
$.before table, div
|
||||||
|
|
||||||
id = reply.id
|
|
||||||
g.hiddenReplies[id] = Date.now()
|
|
||||||
$.set "hiddenReplies/#{g.BOARD}/", g.hiddenReplies
|
|
||||||
|
|
||||||
show: (table) ->
|
show: (table) ->
|
||||||
table.hidden = false
|
table.hidden = false
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user