Blacklist functionality incorporated into settings menu

This commit is contained in:
00Fjongl 2024-07-25 17:35:18 -05:00
parent a5b5f189b5
commit be372c55f3
7 changed files with 125 additions and 81 deletions

View file

@ -136,7 +136,7 @@ This will be our nonexhaustive todo list for Holy Unblocker LTS v6.x.x and above
- [x] XSS and fingerprinting protection (may need updates) - done - [x] XSS and fingerprinting protection (may need updates) - done
- [x] Update games navigation JS and page/change to JSON object system - done - [x] Update games navigation JS and page/change to JSON object system - done
- [ ] Ensure all the original submodules get added back to HU-Archive - [ ] Ensure all the original submodules get added back to HU-Archive
- [ ] Mobile support - [x] Mobile support - (welcome screen only, partial/needs work)
- [ ] SEO overhaul adapted from the v2 SEO Guide format - [ ] SEO overhaul adapted from the v2 SEO Guide format
## Proxy/Site Functionality ## Proxy/Site Functionality
@ -146,15 +146,18 @@ This will be our nonexhaustive todo list for Holy Unblocker LTS v6.x.x and above
- [x] Fix Ultraviolet on Firefox - (partial/needs work) - [x] Fix Ultraviolet on Firefox - (partial/needs work)
- [ ] Adapt Applications page to use either Rammerhead or UV (for Reddit, YouTube, Discord) - [ ] Adapt Applications page to use either Rammerhead or UV (for Reddit, YouTube, Discord)
- [x] libcurl, epoxy and all that fun stuff - done - [x] libcurl, epoxy and all that fun stuff - done
- [ ] socks5/tor routing option that can be configured (enabled) via either a cookie or pathname as a settings meny option - [x] socks5/tor routing option that can be configured (enabled) via either a cookie or pathname as a settings meny option - done
- [ ] Update games page content - [ ] Update games page content
- [ ] Update csel.js (after Setting menu redesign) to support custom transports, icon swap, routing - [ ] Update settings menu again to make more room for more features
- [x] Update csel.js (after Setting menu redesign) to support custom transports, icon swap, routing - done
- [x] Update csel.js to support network based adblocking (partial/needs work)
- [ ] Update sw.js to support workerware (https://github.com/MercuryWorkshop/workerware)
- [ ] Omnibox autoupdate script (for the Google/Bing style auto suggest feature) - [ ] Omnibox autoupdate script (for the Google/Bing style auto suggest feature)
- [ ] Games library will feature 10000 items; 5000 flash games and 5000 other game types - [ ] Games library will feature 10000 items; 5000 flash games and 5000 other game types
## Site Redesign ## Site Redesign
- [x] Landing Cards - done - [x] Landing Cards - done
- [ ] Change fonts to cleaner look - [x] Change fonts to cleaner look
- [ ] Add more AOS interactions on scroll or hover - [ ] Add more AOS interactions on scroll or hover
- [ ] Add subtle noise to background elements - [ ] Add subtle noise to background elements
- [ ] Update colors + add themes - [ ] Update colors + add themes
@ -196,12 +199,14 @@ This will be our nonexhaustive todo list for Holy Unblocker LTS v6.x.x and above
- Improved component handling via templates.mjs along with deletion of obsolete files that previously handled this standard in a poor format - Improved component handling via templates.mjs along with deletion of obsolete files that previously handled this standard in a poor format
- Fixed oddly slow speeds with Ultraviolet (as well as a general version bump to support epoxy-tls and bare-mux) - Fixed oddly slow speeds with Ultraviolet (as well as a general version bump to support epoxy-tls and bare-mux)
- Implemented testing scripts for an improved GitHub actions workflow by doing a quick test on proxy + site functionality - Implemented testing scripts for an improved GitHub actions workflow by doing a quick test on proxy + site functionality
- Greatly optimized client-side scripts across the site with a new standard - Greatly optimized client-side scripts across the site with a new standard, and generally reworked to no longer leave global variables
- Changes to server.mjs with path logic and error handling - Changes to server.mjs with path logic and error handling
- Updated standards for common scripts - Updated standards for common scripts
- libcurl and bare-as-module support added - libcurl and bare-as-module support added
- Deleted 5 JS scripts and moved lots of data into JSON files. Big reorganization. Games menu core scripts now nested inside of common.js utilizing a JSON system - Deleted 5 JS scripts and moved lots of data into JSON files. Big reorganization. Games menu core scripts now nested inside of common.js utilizing a JSON system
- Massive updates to the Settings menu visually and functionality wise; added Bare-Mux support for swapping transports to work with Ultraviolet, default icons and selective adblocking + Tor on any proxy instances - Massive updates to the Settings menu visually and functionality wise; added Bare-Mux support for swapping transports to work with Ultraviolet, default icons and selective adblocking + Tor on any proxy instances
- CSS Has been partially restructured for mobile support, and is now properly arranged into clearly labeled sections (for the most part)
- Incorporated makeshift domain blacklisting functionality into Ultraviolet, currently used for blocking ads if ads are disabled in settings
## Vague Explanation for Beginners With External Proxies and Hosting ## Vague Explanation for Beginners With External Proxies and Hosting
You will first want to host your proxies locally or externally. OUTDATED You will first want to host your proxies locally or externally. OUTDATED

View file

@ -24,8 +24,10 @@ This will be our nonexhaustive todo list for Holy Unblocker LTS v6.x.x and above
- [x] libcurl, epoxy and all that fun stuff - done - [x] libcurl, epoxy and all that fun stuff - done
- [x] socks5/tor routing option that can be configured (enabled) via either a cookie or pathname as a settings meny option - done - [x] socks5/tor routing option that can be configured (enabled) via either a cookie or pathname as a settings meny option - done
- [ ] Update games page content - [ ] Update games page content
- [ ] Update settings menu again to make more room for more features
- [x] Update csel.js (after Setting menu redesign) to support custom transports, icon swap, routing - done - [x] Update csel.js (after Setting menu redesign) to support custom transports, icon swap, routing - done
- [x] Update csel.js to support network based adblocking and workerware (https://github.com/MercuryWorkshop/workerware) - [x] Update csel.js to support network based adblocking (partial/needs work)
- [ ] Update sw.js to support workerware (https://github.com/MercuryWorkshop/workerware)
- [ ] Omnibox autoupdate script (for the Google/Bing style auto suggest feature) - [ ] Omnibox autoupdate script (for the Google/Bing style auto suggest feature)
- [ ] Games library will feature 10000 items; 5000 flash games and 5000 other game types - [ ] Games library will feature 10000 items; 5000 flash games and 5000 other game types
@ -80,3 +82,4 @@ This will be our nonexhaustive todo list for Holy Unblocker LTS v6.x.x and above
- Deleted 5 JS scripts and moved lots of data into JSON files. Big reorganization. Games menu core scripts now nested inside of common.js utilizing a JSON system - Deleted 5 JS scripts and moved lots of data into JSON files. Big reorganization. Games menu core scripts now nested inside of common.js utilizing a JSON system
- Massive updates to the Settings menu visually and functionality wise; added Bare-Mux support for swapping transports to work with Ultraviolet, default icons and selective adblocking + Tor on any proxy instances - Massive updates to the Settings menu visually and functionality wise; added Bare-Mux support for swapping transports to work with Ultraviolet, default icons and selective adblocking + Tor on any proxy instances
- CSS Has been partially restructured for mobile support, and is now properly arranged into clearly labeled sections (for the most part) - CSS Has been partially restructured for mobile support, and is now properly arranged into clearly labeled sections (for the most part)
- Incorporated makeshift domain blacklisting functionality into Ultraviolet, currently used for blocking ads if ads are disabled in settings

View file

@ -47,10 +47,14 @@ const testServerResponse = async () => {
"http://localhost:8080/?fg", "http://localhost:8080/?fg",
"http://localhost:8080/?eg", "http://localhost:8080/?eg",
"http://localhost:8080/?vos", "http://localhost:8080/?vos",
"http://localhost:8080/assets/js/particlesjs/particles.js",
"http://localhost:8080/assets/js/bareTransport.js",
"http://localhost:8080/assets/js/card.js",
"http://localhost:8080/assets/js/common-16451543478.js", "http://localhost:8080/assets/js/common-16451543478.js",
"http://localhost:8080/assets/js/csel.js", "http://localhost:8080/assets/js/csel.js",
"http://localhost:8080/assets/js/particlesjs/particles.js", "http://localhost:8080/assets/js/register-sw.js",
"http://localhost:8080/assets/json/emu-nav.json", "http://localhost:8080/assets/json/emu-nav.json",
"http://localhost:8080/assets/json/blacklist.json",
"http://localhost:8080/assets/json/emulib-nav.json", "http://localhost:8080/assets/json/emulib-nav.json",
"http://localhost:8080/assets/json/flash-nav.json", "http://localhost:8080/assets/json/flash-nav.json",
"http://localhost:8080/assets/json/h5-nav.json", "http://localhost:8080/assets/json/h5-nav.json",
@ -59,11 +63,10 @@ const testServerResponse = async () => {
"http://localhost:8080/baremux/worker.js", "http://localhost:8080/baremux/worker.js",
"http://localhost:8080/epoxy/index.mjs", "http://localhost:8080/epoxy/index.mjs",
"http://localhost:8080/uv/uv.bundle.js", "http://localhost:8080/uv/uv.bundle.js",
"http://localhost:8080/uv/uv.config.js",
"http://localhost:8080/assets/js/register-sw.js",
"http://localhost:8080/assets/js/card.js",
"http://localhost:8080/uv/sw.js", "http://localhost:8080/uv/sw.js",
"http://localhost:8080/uv/uv.config.js" "http://localhost:8080/uv/uv.config.js",
"http://localhost:8080/uv/workerware.js",
"http://localhost:8080/uv/WWError.js"
]; ];
const results = await Promise.all(endpoints.map(testEndpoint)); const results = await Promise.all(endpoints.map(testEndpoint));

View file

@ -3,6 +3,7 @@
(() => { (() => {
const stockSW = "/uv/sw.js", const stockSW = "/uv/sw.js",
blacklistSW = "/uv/sw-blacklist.js",
swAllowedHostnames = ["localhost", "127.0.0.1"], swAllowedHostnames = ["localhost", "127.0.0.1"],
connection = new BareMux.BareMuxConnection("/baremux/worker.js"), connection = new BareMux.BareMuxConnection("/baremux/worker.js"),
wispUrl = (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/", wispUrl = (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/",
@ -56,7 +57,22 @@ const registerSW = async () => {
transportOptions.proxy = proxyUrl; transportOptions.proxy = proxyUrl;
await connection.setTransport(transportMode, [transportOptions]); await connection.setTransport(transportMode, [transportOptions]);
await navigator.serviceWorker.register(stockSW);
// Choose a service worker to register based on whether or not the user
// has ads enabled. If the user changes this setting, this script needs
// to be reloaded for this to update, such as by refreshing the page.
const registrations = await navigator.serviceWorker.getRegistrations(),
usedSW = await readCookie("HBHideAds") !== "false"
? blacklistSW
: stockSW;
// Unregister a service worker if it isn't the one being used.
for (const registration of registrations)
if (registration.active &&
new URL(registration.active.scriptURL).pathname !== usedSW)
await registration.unregister();
await navigator.serviceWorker.register(usedSW);
} }
/* /*

View file

@ -1,4 +1,5 @@
[ [
"*.google.com",
"*.1-1ads.com", "*.1-1ads.com",
"*.101com.com", "*.101com.com",
"*.101order.com", "*.101order.com",

84
views/uv/sw-blacklist.js Normal file
View file

@ -0,0 +1,84 @@
importScripts("uv.bundle.js");
importScripts("uv.config.js");
importScripts(__uv$config.sw || "uv.sw.js");
/*
Workerware does not work yet due to one of the following possibilities:
1. UV or the bare client is not updated to support workerware yet.
2. Workerware is unfinished.
3. We are doofuses and do not know how to use workerware properly.
Going to implement a ghetto domain blacklist for now.
importScripts("./workerware.js");
const ww = new WorkerWare({
debug: true,
randomNames: true,
timing: true
});
ww.use({
function: event => console.log(event),
events: ["fetch", "message"]
});
*/
const uv = new UVServiceWorker();
// Get list of blacklisted domains.
const blacklist = {};
fetch("/assets/json/blacklist.json").then(request => {
request.json().then(jsonData => {
// Organize each domain by their tld (top level domain) ending.
jsonData.forEach(domain => {
const domainTld = domain.replace(/.+(?=\.\w)/, "");
if (!blacklist.hasOwnProperty(domainTld))
blacklist[domainTld] = [];
// Store each entry in an array. Each tld has its own array, which will
// later be concatenated into a regular expression.
blacklist[domainTld].push(
encodeURIComponent(domain.slice(0, -domainTld.length))
.replace(/([()])/g, "\\$1")
.replace(/(\*\.)|\./g, (match, firstExpression) =>
firstExpression ? "(?:.+\\.)?" : "\\" + match)
);
});
// Turn each domain list into a regular expression and prevent this
// from being accidentally modified afterward.
for (let [domainTld, domainList] of Object.entries(blacklist))
blacklist[domainTld] = new RegExp(`^(?:${domainList.join("|")})$`);
Object.freeze(blacklist);
});
});
self.addEventListener("fetch", (event) => {
event.respondWith(
(async () => {
if (uv.route(event)) {
// The one and only ghetto domain blacklist.
const domain = new URL(uv.config.decodeUrl(
new URL(event.request.url).pathname
.replace(uv.config.prefix, "")
)).hostname,
domainTld = domain.replace(/.+(?=\.\w)/, "");
// If the domain is in the blacklist, return a 406 response code.
if (blacklist.hasOwnProperty(domainTld) &&
blacklist[domainTld].test(domain.slice(0, -domainTld.length)))
return new Response(new Blob(), {status: 406});
return await uv.fetch(event);
}
return await fetch(event.request);
})()
);
});

View file

@ -2,82 +2,14 @@ importScripts("uv.bundle.js");
importScripts("uv.config.js"); importScripts("uv.config.js");
importScripts(__uv$config.sw || "uv.sw.js"); importScripts(__uv$config.sw || "uv.sw.js");
/*
Workerware does not work yet due to one of the following possibilities:
1. UV or the bare client is not updated to support workerware yet.
2. Workerware is unfinished.
3. We are doofuses and do not know how to use workerware properly.
Going to implement a ghetto domain blacklist for now.
importScripts("./workerware.js");
const ww = new WorkerWare({
debug: true,
randomNames: true,
timing: true
});
ww.use({
function: event => console.log(event),
events: ["fetch", "message"]
});
*/
const uv = new UVServiceWorker(); const uv = new UVServiceWorker();
// Get list of blacklisted domains.
const blacklist = {};
fetch("/assets/json/blacklist.json").then(request => {
request.json().then(jsonData => {
// Organize each domain by their tld (top level domain) ending.
jsonData.forEach(domain => {
const domainTld = domain.replace(/.+(?=\.\w)/, "");
if (!blacklist.hasOwnProperty(domainTld))
blacklist[domainTld] = [];
// Store each entry in an array. Each tld has its own array, which will
// later be concatenated into a regular expression.
blacklist[domainTld].push(
encodeURIComponent(domain.slice(0, -domainTld.length))
.replace(/([()])/g, "\\$1")
.replace(/(\*\.)|\./g, (match, firstExpression) =>
firstExpression ? "(?:.+\\.)?" : "\\" + match)
);
});
// Turn each domain list into a regular expression and prevent this
// from being accidentally modified afterward.
for (let [domainTld, domainList] of Object.entries(blacklist))
blacklist[domainTld] = new RegExp(`^(?:${domainList.join("|")})$`);
Object.freeze(blacklist);
});
});
self.addEventListener("fetch", (event) => { self.addEventListener("fetch", (event) => {
event.respondWith( event.respondWith(
(async () => { (async () => {
if (uv.route(event)) { if (uv.route(event)) return await uv.fetch(event);
// The one and only ghetto domain blacklist.
const domain = new URL(uv.config.decodeUrl(
new URL(event.request.url).pathname
.replace(uv.config.prefix, "")
)).hostname,
domainTld = domain.replace(/.+(?=\.\w)/, "");
// If the domain is in the blacklist, return a 406 response code.
if (blacklist.hasOwnProperty(domainTld) &&
blacklist[domainTld].test(domain.slice(0, -domainTld.length))
) return new Response(new Blob(), {status: 406});
return await uv.fetch(event);
}
return await fetch(event.request); return await fetch(event.request);
})() })()
); );