Skip to content

Commit 7fd4cb3

Browse files
Update pornolab_filters.user.js
1 parent 364ad30 commit 7fd4cb3

1 file changed

Lines changed: 55 additions & 43 deletions

File tree

NSFW/pornolab_filters.user.js

Lines changed: 55 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// ==UserScript==
22
// @name Pornolab Filters
33
// @namespace pornolab-filters
4-
// @version 1.0
4+
// @version 1.1
55
// @author masterofobzene
6-
// @description Persistent client-side blacklist to filter 'topics' (post names) and 'forum' (category) in pornolab
6+
// @description Persistent client-side blacklist to filter topics (titles) and forums (categories) separately in pornolab
77
// @match *://pornolab.net/forum/tracker.php*
88
// @icon https://pornolab.net/favicon.ico
99
// @grant none
1010
// @run-at document-end
1111
// @downloadURL https://github.com/masterofobzene/UserScriptRepo/raw/main/NSFW/pornolab_filters.user.js
1212
// @updateURL https://github.com/masterofobzene/UserScriptRepo/raw/main/NSFW/pornolab_filters.user.js
13-
1413
// ==/UserScript==
1514

1615
(function () {
1716
'use strict';
1817

19-
const STORAGE_KEY = 'pornolab_blacklist_words';
18+
const STORAGE_KEY_TITLES = 'pornolab_blacklist_titles';
19+
const STORAGE_KEY_FORUMS = 'pornolab_blacklist_forums';
2020

2121
function waitForTable(cb) {
2222
const t = document.querySelector('#tor-tbl');
@@ -32,19 +32,18 @@
3232
obs.observe(document.body, { childList: true, subtree: true });
3333
}
3434

35-
function getWords() {
36-
return (localStorage.getItem(STORAGE_KEY) || '')
35+
function getWords(key) {
36+
return (localStorage.getItem(key) || '')
3737
.toLowerCase()
3838
.split(/[\s,]+/)
3939
.filter(Boolean);
4040
}
4141

42-
function saveWords(val) {
43-
localStorage.setItem(STORAGE_KEY, val.trim());
42+
function saveWords(key, val) {
43+
localStorage.setItem(key, val.trim());
4444
}
4545

4646
function createUI(table) {
47-
// Prevent duplicate UI
4847
if (document.getElementById('pl-blacklist-box')) return;
4948

5049
const box = document.createElement('div');
@@ -56,55 +55,68 @@
5655
background: #1b1b1b;
5756
`;
5857

59-
box.innerHTML = `
60-
<div style="font-weight:bold; margin-bottom:6px;">
61-
Client-side blacklist (persistent):
62-
</div>
63-
`;
58+
box.innerHTML = `<div style="font-weight:bold; margin-bottom:10px;">Client-side blacklist (persistent):</div>`;
6459

65-
const input = document.createElement('input');
66-
input.type = 'text';
67-
input.style.cssText = `
68-
width: 100%;
69-
max-width: 700px;
70-
padding: 8px;
71-
font-size: 14px;
72-
`;
73-
input.placeholder = 'word1 word2 word3';
60+
// Title input
61+
const titleLabel = document.createElement('div');
62+
titleLabel.textContent = 'Hide titles containing:';
63+
titleLabel.style.marginTop = '8px';
64+
box.appendChild(titleLabel);
7465

75-
input.value = localStorage.getItem(STORAGE_KEY) || '';
66+
const titleInput = document.createElement('input');
67+
titleInput.type = 'text';
68+
titleInput.style.cssText = `width: 100%; max-width: 700px; padding: 8px; font-size: 14px;`;
69+
titleInput.placeholder = 'word1 word2 word3';
70+
titleInput.value = localStorage.getItem(STORAGE_KEY_TITLES) || '';
7671

77-
input.addEventListener('input', () => {
78-
saveWords(input.value);
72+
titleInput.addEventListener('input', () => {
73+
saveWords(STORAGE_KEY_TITLES, titleInput.value);
74+
applyFilter(table);
75+
});
76+
box.appendChild(titleInput);
77+
78+
// Forum input
79+
const forumLabel = document.createElement('div');
80+
forumLabel.textContent = 'Hide forums containing:';
81+
forumLabel.style.marginTop = '12px';
82+
box.appendChild(forumLabel);
83+
84+
const forumInput = document.createElement('input');
85+
forumInput.type = 'text';
86+
forumInput.style.cssText = `width: 100%; max-width: 700px; padding: 8px; font-size: 14px;`;
87+
forumInput.placeholder = 'word1 word2 word3';
88+
forumInput.value = localStorage.getItem(STORAGE_KEY_FORUMS) || '';
89+
90+
forumInput.addEventListener('input', () => {
91+
saveWords(STORAGE_KEY_FORUMS, forumInput.value);
7992
applyFilter(table);
8093
});
94+
box.appendChild(forumInput);
8195

82-
box.appendChild(input);
8396
table.parentNode.insertBefore(box, table);
8497
}
8598

8699
function applyFilter(table) {
87-
const words = getWords();
100+
const titleWords = getWords(STORAGE_KEY_TITLES);
101+
const forumWords = getWords(STORAGE_KEY_FORUMS);
88102

89-
table.querySelectorAll('tbody > tr').forEach(row => {
90-
if (!row.cells || row.cells.length < 4) {
91-
row.style.display = '';
92-
return;
93-
}
103+
table.querySelectorAll('tbody > tr').forEach(row => {
104+
if (!row.cells || row.cells.length < 4) {
105+
row.style.display = '';
106+
return;
107+
}
94108

95-
// CORRECT columns
96-
const forumCell = row.cells[2];
97-
const topicCell = row.cells[3];
109+
const forumCell = row.cells[2];
110+
const topicCell = row.cells[3];
98111

99-
const forumText = forumCell.textContent || '';
100-
const topicText = topicCell.textContent || '';
112+
const forumText = (forumCell.textContent || '').toLowerCase();
113+
const topicText = (topicCell.textContent || '').toLowerCase();
101114

102-
const combined = (forumText + ' ' + topicText).toLowerCase();
115+
const hideByForum = forumWords.some(w => forumText.includes(w));
116+
const hideByTitle = titleWords.some(w => topicText.includes(w));
103117

104-
row.style.display = words.some(w => combined.includes(w))
105-
? 'none'
106-
: '';
107-
});
118+
row.style.display = (hideByForum || hideByTitle) ? 'none' : '';
119+
});
108120
}
109121

110122
function attachTableObserver(table) {

0 commit comments

Comments
 (0)