-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurl-search-blocker.user.js
57 lines (50 loc) · 1.58 KB
/
url-search-blocker.user.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
// ==UserScript==
// @name URL and Search Blocker
// @namespace https://github.com/ryanbuening/userscripts
// @version 1.0
// @description Blocks specific URLs and redirects them
// @match *://*/*
// @run-at document-start
// @grant none
// ==/UserScript==
(function () {
'use strict';
// List of URLs to block (can be full or partial URLs)
const blockedUrls = [
"reddit.com/r/politics",
"reddit.com/r/moderatepolitics",
"reddit.com/r/conservative",
"reddit.com/r/ohio",
"reddit.com/r/wallstreetbets"
];
// List of Google search queries to block
const blockedSearchQueries = [
"sp500",
];
// URL to redirect to when blocked content is detected
const redirectUrl = "https://oneminutefocus.com";
// Get the current URL
const currentUrl = window.location.href.toLowerCase();
// Check if current URL contains any of the blocked URLs
for (const url of blockedUrls) {
if (currentUrl.includes(url.toLowerCase())) {
window.location.href = redirectUrl;
return;
}
}
// Check if this is a Google search
if (currentUrl.includes("google.") && currentUrl.includes("/search?")) {
// Extract the search query parameter
const urlParams = new URLSearchParams(window.location.search);
const searchQuery = urlParams.get('q');
if (searchQuery) {
// Check if the search query contains any blocked terms
for (const term of blockedSearchQueries) {
if (searchQuery.toLowerCase().includes(term.toLowerCase())) {
window.location.href = redirectUrl;
return;
}
}
}
}
})();