mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-12 11:30:01 -04:00
Formatting and workflow organization changes
This commit is contained in:
parent
461c89212f
commit
8c9f79d3e7
13 changed files with 1010 additions and 979 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -26,7 +26,7 @@ jobs:
|
|||
run: npm run build
|
||||
|
||||
- name: Start server
|
||||
run: npm run manual-start
|
||||
run: npm run workflow-test
|
||||
|
||||
- name: Test server response
|
||||
run: npm test
|
||||
|
@ -53,7 +53,7 @@ jobs:
|
|||
run: npm run build
|
||||
|
||||
- name: Start server
|
||||
run: npm run manual-start
|
||||
run: npm run workflow-test
|
||||
|
||||
- name: Test server response
|
||||
run: npm test
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
/lib
|
||||
/views/assets/js/*.js
|
|
@ -12,7 +12,8 @@
|
|||
"manual-start": "node run-command.mjs start",
|
||||
"kill": "node run-command.mjs stop kill",
|
||||
"build": "node run-command.mjs build && cd lib/rammerhead && npm install && npm run build",
|
||||
"proxy-validator": "node proxyServiceValidator.js"
|
||||
"proxy-validator": "node proxyServiceValidator.js",
|
||||
"workflow-test": "node run-command.mjs workflow"
|
||||
},
|
||||
"keywords": [
|
||||
"proxy",
|
||||
|
|
|
@ -311,7 +311,7 @@ xx xx
|
|||
}
|
||||
};
|
||||
|
||||
// Run tests for Rammerhead and Ultraviolet
|
||||
// Run tests for Rammerhead and Ultraviolet.
|
||||
const rammerheadPassed = await testRammerhead();
|
||||
const ultravioletPassed = await testUltraviolet();
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ commands: for (let i = 2; i < process.argv.length; i++)
|
|||
console.log(stdout);
|
||||
}
|
||||
);
|
||||
// Handle setup on Windows differently from platforms with POSIX-compliant shells.
|
||||
// This should run the server as a background process.
|
||||
// Handle setup on Windows differently from platforms with POSIX-compliant
|
||||
// shells. This should run the server as a background process.
|
||||
else if (process.platform === 'win32')
|
||||
exec('START /MIN "" node backend.js', (error, stdout) => {
|
||||
if (error) {
|
||||
|
@ -56,29 +56,9 @@ commands: for (let i = 2; i < process.argv.length; i++)
|
|||
// because exiting this program will also terminate backend.js on Windows.
|
||||
else {
|
||||
const server = fork(
|
||||
fileURLToPath(new URL('./backend.js', import.meta.url)),
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
|
||||
detached: true
|
||||
}
|
||||
);
|
||||
server.stderr.on("data", stderr => {
|
||||
console.error(stderr.toString());
|
||||
if (stderr.toString().indexOf("DeprecationWarning") + 1)
|
||||
return;
|
||||
server.stderr.destroy();
|
||||
process.exitCode = 1;
|
||||
});
|
||||
server.stdout.on("data", () => {
|
||||
server.kill();
|
||||
const server2 = fork(
|
||||
fileURLToPath(new URL('./backend.js', import.meta.url)),
|
||||
{ cwd: process.cwd(), detached: true }
|
||||
);
|
||||
server2.unref();
|
||||
server2.disconnect();
|
||||
});
|
||||
server.unref();
|
||||
server.disconnect();
|
||||
}
|
||||
|
@ -91,9 +71,10 @@ commands: for (let i = 2; i < process.argv.length; i++)
|
|||
let timeoutId,
|
||||
hasErrored = false;
|
||||
try {
|
||||
// Give the server 5 seconds to respond, otherwise cancel this and throw an
|
||||
// error to the console. The fetch request will also throw an error immediately
|
||||
// if checking the server on localhost and the port is unused.
|
||||
/* Give the server 5 seconds to respond, otherwise cancel this and throw an
|
||||
* error to the console. The fetch request will also throw an error
|
||||
* immediately if checking the server on localhost and the port is unused.
|
||||
*/
|
||||
const response = await Promise.race([
|
||||
fetch(new URL('/test-shutdown', serverUrl)),
|
||||
new Promise((resolve) => {
|
||||
|
@ -154,9 +135,10 @@ commands: for (let i = 2; i < process.argv.length; i++)
|
|||
break;
|
||||
}
|
||||
|
||||
// Kill all node processes and fully reset PM2. To be used for debugging.
|
||||
// Using npx pm2 monit, or npx pm2 list in the terminal will also bring up
|
||||
// more PM2 debugging tools.
|
||||
/* Kill all node processes and fully reset PM2. To be used for debugging.
|
||||
* Using npx pm2 monit, or npx pm2 list in the terminal will also bring up
|
||||
* more PM2 debugging tools.
|
||||
*/
|
||||
case 'kill':
|
||||
if (process.platform === 'win32')
|
||||
exec(
|
||||
|
@ -174,6 +156,56 @@ commands: for (let i = 2; i < process.argv.length; i++)
|
|||
);
|
||||
break;
|
||||
|
||||
case 'workflow':
|
||||
if (config.production)
|
||||
exec(
|
||||
'npx pm2 start ecosystem.config.js --env production',
|
||||
(error, stdout) => {
|
||||
if (error) throw error;
|
||||
console.log(stdout);
|
||||
}
|
||||
);
|
||||
// Handle setup on Windows differently from platforms with POSIX-compliant
|
||||
// shells. This should run the server as a background process.
|
||||
else if (process.platform === 'win32')
|
||||
exec('START /MIN "" node backend.js', (error, stdout) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
console.log(stdout);
|
||||
});
|
||||
// The following approach (and similar approaches) will not work on Windows,
|
||||
// because exiting this program will also terminate backend.js on Windows.
|
||||
else {
|
||||
const server = fork(
|
||||
fileURLToPath(new URL('./backend.js', import.meta.url)),
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
|
||||
detached: true,
|
||||
}
|
||||
);
|
||||
server.stderr.on('data', (stderr) => {
|
||||
console.error(stderr.toString());
|
||||
if (stderr.toString().indexOf('DeprecationWarning') + 1) return;
|
||||
server.stderr.destroy();
|
||||
process.exitCode = 1;
|
||||
});
|
||||
server.stdout.on('data', () => {
|
||||
server.kill();
|
||||
const server2 = fork(
|
||||
fileURLToPath(new URL('./backend.js', import.meta.url)),
|
||||
{ cwd: process.cwd(), detached: true }
|
||||
);
|
||||
server2.unref();
|
||||
server2.disconnect();
|
||||
});
|
||||
server.unref();
|
||||
server.disconnect();
|
||||
}
|
||||
break;
|
||||
|
||||
// No default case.
|
||||
}
|
||||
|
||||
|
|
|
@ -84,17 +84,18 @@ server.on('upgrade', (req, socket, head) => {
|
|||
}
|
||||
});
|
||||
|
||||
// Apply Helmet middleware for security
|
||||
// Apply Helmet middleware for security.
|
||||
app.use(
|
||||
helmet({
|
||||
contentSecurityPolicy: false, // Disable CSP
|
||||
})
|
||||
);
|
||||
|
||||
// All website files are stored in the /views directory.
|
||||
// This takes one of those files and displays it for a site visitor.
|
||||
// Query strings like /?j are converted into paths like /views/hidden.html
|
||||
// back here. Which query string converts to what is defined in routes.mjs.
|
||||
/* All website files are stored in the /views directory.
|
||||
* This takes one of those files and displays it for a site visitor.
|
||||
* Query strings like /?j are converted into paths like /views/hidden.html
|
||||
* back here. Which query string converts to what is defined in routes.mjs.
|
||||
*/
|
||||
router.get('/', async (req, res) =>
|
||||
res.send(
|
||||
paintSource(
|
||||
|
|
|
@ -11,9 +11,10 @@ const {
|
|||
text404,
|
||||
} = pkg;
|
||||
|
||||
// Below are lots of function definitions used to obfuscate the website.
|
||||
// This makes the website harder to properly categorize, as its source code
|
||||
// changes with each time it is loaded.
|
||||
/* Below are lots of function definitions used to obfuscate the website.
|
||||
* This makes the website harder to properly categorize, as its source code
|
||||
* changes with each time it is loaded.
|
||||
*/
|
||||
const randomListItem = (lis) => () => lis[(Math.random() * lis.length) | 0],
|
||||
charset = /­|​|­|<wbr>/gi,
|
||||
getRandomChar = randomListItem(charRandom),
|
||||
|
@ -44,10 +45,9 @@ const randomListItem = (lis) => () => lis[(Math.random() * lis.length) | 0],
|
|||
existsSync(file + '') ? readFileSync(file + '', 'utf8') : preloaded404;
|
||||
|
||||
/*
|
||||
// All of this is now old code.
|
||||
// The newer versions of these functions are directly above.
|
||||
*/
|
||||
/*
|
||||
|
||||
All of this is now old code.
|
||||
The newer versions of these functions are directly above.
|
||||
|
||||
function randomListItem(lis) {
|
||||
return lis[Math.floor(Math.random() * lis.length)];
|
||||
|
|
|
@ -27,9 +27,10 @@ const config = Object.freeze(
|
|||
{ pages, externalPages } = pageRoutes,
|
||||
__dirname = path.resolve();
|
||||
|
||||
// Record the server's location as a URL object, including its host and port.
|
||||
// The host can be modified at /src/config.json, whereas the ports can be modified
|
||||
// at /ecosystem.config.js.
|
||||
/* Record the server's location as a URL object, including its host and port.
|
||||
* The host can be modified at /src/config.json, whereas the ports can be modified
|
||||
* at /ecosystem.config.js.
|
||||
*/
|
||||
const serverUrl = ((base) => {
|
||||
try {
|
||||
base = new URL(config.host);
|
||||
|
@ -98,7 +99,7 @@ const serverFactory = (handler) => {
|
|||
});
|
||||
};
|
||||
|
||||
// Set logger to true for logs
|
||||
// Set logger to true for logs.
|
||||
const app = Fastify({
|
||||
ignoreDuplicateSlashes: true,
|
||||
ignoreTrailingSlash: true,
|
||||
|
@ -106,7 +107,7 @@ const app = Fastify({
|
|||
serverFactory: serverFactory,
|
||||
});
|
||||
|
||||
// Apply Helmet middleware for security
|
||||
// Apply Helmet middleware for security.
|
||||
app.register(fastifyHelmet, {
|
||||
contentSecurityPolicy: false, // Disable CSP
|
||||
xPoweredBy: false,
|
||||
|
@ -196,10 +197,11 @@ app.register(fastifyStatic, {
|
|||
decorateReply: false,
|
||||
});
|
||||
|
||||
// All website files are stored in the /views directory.
|
||||
// This takes one of those files and displays it for a site visitor.
|
||||
// Paths like /browsing are converted into paths like /views/pages/surf.html
|
||||
// back here. Which path converts to what is defined in routes.mjs.
|
||||
/* All website files are stored in the /views directory.
|
||||
* This takes one of those files and displays it for a site visitor.
|
||||
* Paths like /browsing are converted into paths like /views/pages/surf.html
|
||||
* back here. Which path converts to what is defined in routes.mjs.
|
||||
*/
|
||||
app.get('/:path', (req, reply) => {
|
||||
// Testing for future features that need cookies to deliver alternate source files.
|
||||
if (req.raw.rawHeaders.includes('Cookie'))
|
||||
|
|
|
@ -29,9 +29,10 @@
|
|||
// Get the box card elements and add the event listeners to them.
|
||||
shimmerEffects = document.querySelectorAll('.box-card, .box-hero');
|
||||
|
||||
// Attach CSS variables, mouse-x and mouse-y, to elements that will be
|
||||
// given shimmer effects, by adding or modifying the style attribute.
|
||||
// CSS calculates and renders the actual shimmer effect from there.
|
||||
/* Attach CSS variables, mouse-x and mouse-y, to elements that will be
|
||||
* given shimmer effects, by adding or modifying the style attribute.
|
||||
* CSS calculates and renders the actual shimmer effect from there.
|
||||
*/
|
||||
shimmerEffects.forEach(handleMouseMove);
|
||||
shimmerEffects.forEach(handleMouseLeave);
|
||||
})();
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
localStorage.setItem('huframesrc', url);
|
||||
location.href = '/s';
|
||||
},
|
||||
// Used to set functions for the goProx object at the bottom.
|
||||
// See the goProx object at the bottom for some usage examples
|
||||
// on the URL handlers, omnibox functions, and the uvUrl and
|
||||
// RammerheadEncode functions.
|
||||
/* Used to set functions for the goProx object at the bottom.
|
||||
* See the goProx object at the bottom for some usage examples
|
||||
* on the URL handlers, omnibox functions, and the uvUrl and
|
||||
* RammerheadEncode functions.
|
||||
*/
|
||||
urlHandler = (parser) =>
|
||||
typeof parser === 'function'
|
||||
? // Return different functions based on whether a URL has already been set.
|
||||
|
@ -141,9 +142,10 @@
|
|||
const char = str[i],
|
||||
idx = baseDictionary.indexOf(char);
|
||||
|
||||
// For URL encoded characters and characters not included in the
|
||||
// dictionary, leave untouched. Otherwise, replace with a character
|
||||
// from the dictionary.
|
||||
/* For URL encoded characters and characters not included in the
|
||||
* dictionary, leave untouched. Otherwise, replace with a character
|
||||
* from the dictionary.
|
||||
*/
|
||||
if (char === '%' && str.length - i >= 3)
|
||||
// A % symbol denotes that the next 2 characters are URL encoded.
|
||||
shuffledStr += char + str[++i] + str[++i];
|
||||
|
@ -172,17 +174,17 @@
|
|||
const char = str[i],
|
||||
idx = this.dictionary.indexOf(char);
|
||||
|
||||
// Convert the dictionary entry characters back into their base
|
||||
// characters using the base dictionary. Again, leave URL encoded
|
||||
// characters and unrecognized symbols alone.
|
||||
/* Convert the dictionary entry characters back into their base
|
||||
* characters using the base dictionary. Again, leave URL encoded
|
||||
* characters and unrecognized symbols alone.
|
||||
*/
|
||||
if (char === '%' && str.length - i >= 3)
|
||||
unshuffledStr += char + str[++i] + str[++i];
|
||||
else if (idx == -1) unshuffledStr += char;
|
||||
// Find the corresponding base character entry and use the character
|
||||
// that is i places to the left of it.
|
||||
else
|
||||
unshuffledStr +=
|
||||
baseDictionary[mod(idx - i, baseDictionary.length)];
|
||||
unshuffledStr += baseDictionary[mod(idx - i, baseDictionary.length)];
|
||||
}
|
||||
return unshuffledStr;
|
||||
}
|
||||
|
@ -230,9 +232,10 @@
|
|||
});
|
||||
},
|
||||
},
|
||||
// Organize Rammerhead sessions via the browser's local storage.
|
||||
// Local data consists of session creation timestamps and session IDs.
|
||||
// The rest of the data is stored on the server.
|
||||
/* Organize Rammerhead sessions via the browser's local storage.
|
||||
* Local data consists of session creation timestamps and session IDs.
|
||||
* The rest of the data is stored on the server.
|
||||
*/
|
||||
localStorageKey = 'rammerhead_sessionids',
|
||||
localStorageKeyDefault = 'rammerhead_default_sessionid',
|
||||
sessionIdsStore = {
|
||||
|
@ -368,9 +371,7 @@
|
|||
|
||||
mcnow: urlHandler(uvUrl('https://now.gg/play/a/10010/b')),
|
||||
|
||||
glife: urlHandler(
|
||||
uvUrl('https://now.gg/apps/lunime/5767/gacha-life.html')
|
||||
),
|
||||
glife: urlHandler(uvUrl('https://now.gg/apps/lunime/5767/gacha-life.html')),
|
||||
|
||||
roblox: urlHandler(
|
||||
uvUrl('https://now.gg/apps/roblox-corporation/5349/roblox.html')
|
||||
|
@ -381,9 +382,7 @@
|
|||
),
|
||||
|
||||
pubg: urlHandler(
|
||||
uvUrl(
|
||||
'https://now.gg/apps/proxima-beta/2609/pubg-mobile-resistance.html'
|
||||
)
|
||||
uvUrl('https://now.gg/apps/proxima-beta/2609/pubg-mobile-resistance.html')
|
||||
),
|
||||
|
||||
train: urlHandler(uvUrl('https://hby.itch.io/last-train-home')),
|
||||
|
@ -394,9 +393,7 @@
|
|||
|
||||
rpg: urlHandler(uvUrl('https://alarts.itch.io/die-in-the-dungeon')),
|
||||
|
||||
speed: urlHandler(
|
||||
uvUrl('https://captain4lk.itch.io/what-the-road-brings')
|
||||
),
|
||||
speed: urlHandler(uvUrl('https://captain4lk.itch.io/what-the-road-brings')),
|
||||
|
||||
heli: urlHandler(uvUrl('https://benjames171.itch.io/helo-storm')),
|
||||
|
||||
|
@ -538,8 +535,7 @@
|
|||
// the corresponding location/index in the dirnames object.
|
||||
const functionsList = [
|
||||
() => goFrame(item.path),
|
||||
() =>
|
||||
goFrame('/webretro?core=' + item.core + '&rom=' + item.rom),
|
||||
() => goFrame('/webretro?core=' + item.core + '&rom=' + item.rom),
|
||||
item.custom
|
||||
? () => goProx[item.custom]('stealth')
|
||||
: () => goFrame('/archive/g/' + item.path),
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
},
|
||||
removeCookie = (name) => {
|
||||
document.cookie =
|
||||
name +
|
||||
'=; expires=Thu, 01 Jan 1970 00:00:01 GMT; SameSite=None; Secure;';
|
||||
name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT; SameSite=None; Secure;';
|
||||
},
|
||||
readCookie = async (name) => {
|
||||
// Get the first cookie that has the same name.
|
||||
|
@ -126,13 +125,9 @@
|
|||
.getElementsByClassName('dropdown-settings')[0]
|
||||
.parentElement.querySelector("a[href='#']");
|
||||
|
||||
attachEventListener(
|
||||
'.dropdown-settings .close-settings-btn',
|
||||
'click',
|
||||
() => {
|
||||
attachEventListener('.dropdown-settings .close-settings-btn', 'click', () => {
|
||||
document.activeElement.blur();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Allow users to set a custom title with the UI.
|
||||
attachEventListener('titleform', 'submit', (e) => {
|
||||
|
@ -216,9 +211,10 @@
|
|||
}
|
||||
});
|
||||
|
||||
// Allow users to toggle onion routing in Ultraviolet with the UI. Only
|
||||
// the libcurl transport mode supports Tor at the moment, so ensure that
|
||||
// users are aware that they cannot use Tor with other modes.
|
||||
/* Allow users to toggle onion routing in Ultraviolet with the UI. Only
|
||||
* the libcurl transport mode supports Tor at the moment, so ensure that
|
||||
* users are aware that they cannot use Tor with other modes.
|
||||
*/
|
||||
attachEventListener('useonion', 'change', (e) => {
|
||||
let unselectedModes = document.querySelectorAll(
|
||||
'#uv-transport-list input:not([value=libcurl])'
|
||||
|
|
|
@ -58,9 +58,10 @@
|
|||
|
||||
await connection.setTransport(transportMode, [transportOptions]);
|
||||
|
||||
// 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.
|
||||
/* 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue