-
Notifications
You must be signed in to change notification settings - Fork 0
/
FoolzFilterModified.js
executable file
·74 lines (63 loc) · 2.63 KB
/
FoolzFilterModified.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// ==UserScript==
// @id FoolzFilterModified
// @description Hides filtered users posts on Foolz.
// @warning Like any script, this will slow down your browser. Also my JS is rusty so this might fuck your shit up.
// @license WTFPLv2
// @version 1.1
// @namespace Foolz
// @author Wohlfe
// @downloadURL https://github.com/Wohlfe/scripts/blob/master/FoolzFilterModified.js
// @run-at document-end
// @match *://*.foolz.us/*
// ==/UserScript==
//Fair warning: Like any script, this will slow down your browser. Also my JS is rusty so this might fuck your shit up.
(function() {
//These are arrays, so you can add multiple users/trips, separated by commas and enclosed with quotes.
var filterName = ['Wohlfe'];
var filterTrip = [];
function isFiltered(filter, data)
{
if (data !== undefined)
{
switch (filter)
{
case 'trip':
return (filterTrip.indexOf(data) == 0);
default:
return (filterName.indexOf(data) == 0);
}
}
return false;
}
function filterPosts()
{
// Get the <aside class="posts"> for every thread opened
var threads = document.getElementsByClassName('posts');
// Process all <aside class="posts">
for (t = 0; t < threads.length; t++)
{
var replies = threads[t].getElementsByTagName('article');
// process all replies
for (p = replies.length - 1; p >= 0; p--)
{
var post = replies[p];
var name = post.getElementsByClassName('post_author');
var trip = post.getElementsByClassName('post_tripcode');
//This uses case-insensitive global regex to identify the username anywhere in the post_author field, this is extreme so it's commented out, only use it if necessary.
//var regex = new RegExp('\\{'name'\\}', 'gi');
// Checks name, regex of name, or trip
if ((name && isFiltered('name', name[0].textContent)) || (regex == true && isFiltered('name', name[0].textContent)) || (typeof trip[0] !== 'undefined' && isFiltered('trip', trip[0].textContent)))
{
// If true, hides the post
post.style.display = 'none';
}
}
}
// filter upon loading dom content
window.addEventListener("DOMContentLoaded", filterPosts, false);
// filter ajax requests on dom node inserts
window.addEventListener("DOMNodeInserted", filterPosts, false);
})();
// jQuery Alternative
// jQuery('aside.posts span.post_author').filter(function() { return $(this).text() == '??'; }).closest('article').remove();
// jQuery('aside.posts span.post_tripcode').filter(function() { return $(this).text() == '??'; }).closest('article').remove();