SHOW:
|
|
- or go back to the newest paste.
| 1 | // ==UserScript== | |
| 2 | // @id foolz-filter | |
| 3 | // @name foolz-filter | |
| 4 | // @version 1.0 | |
| 5 | // @namespace foolz | |
| 6 | // @author foolz | |
| 7 | // @description this script hides posts that are posted by users in the filter list | |
| 8 | // @run-at document-end | |
| 9 | // @include *.foolz.us/* | |
| 10 | // @include *loveisover.me* | |
| 11 | // @include *.thedarkcave.org* | |
| 12 | // @grant none | |
| 13 | // ==/UserScript== | |
| 14 | ||
| 15 | (function() {
| |
| 16 | - | var filterName = ['S']; |
| 16 | + | var filterName = ['']; |
| 17 | - | var filterTrip = []; |
| 17 | + | var filterTrip = ['']; |
| 18 | ||
| 19 | function isFiltered(filter, data) | |
| 20 | {
| |
| 21 | if (data !== '') | |
| 22 | {
| |
| 23 | switch (filter) | |
| 24 | {
| |
| 25 | case 'trip': | |
| 26 | return (filterTrip.indexOf(data) == 0); | |
| 27 | default: | |
| 28 | return (filterName.indexOf(data) == 0); | |
| 29 | } | |
| 30 | } | |
| 31 | ||
| 32 | return false; | |
| 33 | } | |
| 34 | ||
| 35 | ||
| 36 | function filterPosts() | |
| 37 | {
| |
| 38 | // get the <aside class="posts"> for each thread shown | |
| 39 | var threads = document.getElementsByClassName('posts');
| |
| 40 | ||
| 41 | // process each <aside class="posts"> | |
| 42 | for (t = 0; t < threads.length; t++) | |
| 43 | {
| |
| 44 | var replies = threads[t].getElementsByTagName('article');
| |
| 45 | ||
| 46 | // process all replies | |
| 47 | for (p = replies.length - 1; p >= 0; p--) | |
| 48 | {
| |
| 49 | var post = replies[p]; | |
| 50 | var name = post.getElementsByClassName('post_author');
| |
| 51 | var trip = post.getElementsByClassName('post_tripcode');
| |
| 52 | ||
| 53 | // does name or trip match ones listed in filtered lists | |
| 54 | if ((name && isFiltered('name', name[0].textContent)) || (typeof trip[0] !== 'undefined' && isFiltered('trip', trip[0].textContent)))
| |
| 55 | {
| |
| 56 | // the post should be hidden so 'quoted by' doesn't glitch | |
| 57 | post.style.display = 'none'; | |
| 58 | } | |
| 59 | } | |
| 60 | } | |
| 61 | } | |
| 62 | ||
| 63 | // filter upon loading dom content | |
| 64 | window.addEventListener("DOMContentLoaded", filterPosts, false);
| |
| 65 | ||
| 66 | // filter ajax requests on dom node inserts | |
| 67 | window.addEventListener("DOMNodeInserted", filterPosts, false);
| |
| 68 | })(); | |
| 69 | ||
| 70 | // jQuery Alternative | |
| 71 | // jQuery('aside.posts span.post_author').filter(function() { return $(this).text() == '??'; }).closest('article').remove();
| |
| 72 | // jQuery('aside.posts span.post_tripcode').filter(function() { return $(this).text() == '??'; }).closest('article').remove(); |