mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-12 19:40:02 -04:00
Slightly debloated blacklist domain testing
This commit is contained in:
parent
a829af651d
commit
e19dc1d2ee
1 changed files with 4 additions and 5 deletions
|
@ -35,14 +35,13 @@ const uv = new UVServiceWorker();
|
|||
let blacklist;
|
||||
fetch("/assets/json/blacklist.json").then(request => {
|
||||
request.json().then(jsonData => {
|
||||
blacklist = jsonData.map(
|
||||
domain => new RegExp(
|
||||
blacklist = new RegExp(jsonData.map(
|
||||
domain =>
|
||||
encodeURIComponent(domain)
|
||||
.replace(/([()])/g, "\\$1")
|
||||
.replaceAll("*.", "(?:.+\\.)?")
|
||||
.replaceAll(".", "\\.")
|
||||
)
|
||||
);
|
||||
).join("|"));
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -52,7 +51,7 @@ self.addEventListener("fetch", (event) => {
|
|||
// The one and only ghetto domain blacklist.
|
||||
if (!new URL(event.request.url).pathname.indexOf("/uv/service/")) {
|
||||
const url = new URL(uv.config.decodeUrl(new URL(event.request.url).pathname.replace(/^\/uv\/service\//, "")));
|
||||
if (blacklist.some(domain => domain.test(url.hostname)))
|
||||
if (blacklist.test(url.hostname))
|
||||
return new Response(new Blob(), {status: 406});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue