mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-12 11:30:01 -04:00
v5 update from OlyB released (major changes)
- New UI - Backend changes - Optimizations and more
This commit is contained in:
parent
006d887b1c
commit
d4379dbc7c
4322 changed files with 2969 additions and 97299 deletions
102
backend.js
102
backend.js
|
@ -1,6 +1,6 @@
|
|||
/* -----------------------------------------------
|
||||
* Authors: QuiteAFancyEmerald, BinBashBanana (OlyB), YÖCTDÖNALD'S and the lime
|
||||
* Additional help from Divide and SexyDuceDuce >:D test aaaa
|
||||
* Additional help from Divide and SexyDuceDuce >:D
|
||||
* ----------------------------------------------- */
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
@ -12,7 +12,7 @@ const config = require('./config.json');
|
|||
const insert = require('./randomization.json');
|
||||
const app = express();
|
||||
const port = process.env.PORT || config.port;
|
||||
const server = config.ssl ? https.createServer({ key: fs.readFileSync('./ssl/ssl.key'), cert: fs.readFileSync('./ssl/ssl.cert') }, app) : http.createServer(app);
|
||||
const server = http.createServer(app);
|
||||
|
||||
btoa = (str) => {
|
||||
return new Buffer.from(str).toString('base64');
|
||||
|
@ -22,80 +22,83 @@ atob = (str) => {
|
|||
return new Buffer.from(str, 'base64').toString('utf-8');
|
||||
}
|
||||
|
||||
const text404 = fs.readFileSync(path.normalize(__dirname + '/views/404.html'), 'utf8'),
|
||||
pages = {
|
||||
'index': 'index.html',
|
||||
/* Main */
|
||||
'in': 'info.html',
|
||||
'faq': 'faq.html',
|
||||
'j': 'hidden.html',
|
||||
's': 'pages/frame.html',
|
||||
'z': 'pages/surf.html',
|
||||
'c': 'pages/nav/credits.html',
|
||||
'x': 'pages/nav/bookmarklets.html',
|
||||
'i': 'pages/nav/icons.html',
|
||||
't': 'pages/nav/terms.html',
|
||||
/* Games */
|
||||
'g': 'pages/nav/gtools.html',
|
||||
'h': 'pages/nav/games5.html',
|
||||
'el': 'pages/nav/emulators.html',
|
||||
'f': 'pages/nav/flash.html',
|
||||
'm': 'pages/nav/emulibrary.html',
|
||||
/* Proxies */
|
||||
'q': 'pages/proxnav/corrosion.html',
|
||||
'w': 'pages/proxnav/womginx.html',
|
||||
'y': 'pages/proxnav/youtube.html',
|
||||
'd': 'pages/proxnav/discordhub.html',
|
||||
/* Ruffle and Webretro */
|
||||
'fg': 'archive/gfiles/flash/index.html',
|
||||
'eg': 'archive/gfiles/rarch/index.html'
|
||||
};
|
||||
const text404 = fs.readFileSync(path.normalize(__dirname + '/views/404.html'), 'utf8');
|
||||
const pages = {
|
||||
'index': 'index.html',
|
||||
/* Main */
|
||||
'in': 'docs.html',
|
||||
'faq': 'faq.html',
|
||||
'j': 'hidden.html',
|
||||
's': 'pages/frame.html',
|
||||
'z': 'pages/surf.html',
|
||||
'c': 'pages/nav/credits.html',
|
||||
'x': 'pages/nav/bookmarklets.html',
|
||||
'i': 'pages/nav/icons.html',
|
||||
't': 'pages/nav/terms.html',
|
||||
/* Games */
|
||||
'g': 'pages/nav/gtools.html',
|
||||
'h': 'pages/nav/games5.html',
|
||||
'el': 'pages/nav/emulators.html',
|
||||
'f': 'pages/nav/flash.html',
|
||||
'm': 'pages/nav/emulibrary.html',
|
||||
/* Proxies */
|
||||
'q': 'pages/proxnav/corrosion.html',
|
||||
'w': 'pages/proxnav/womginx.html',
|
||||
/* Proxy Presets */
|
||||
'y': 'pages/proxnav/preset/youtube.html',
|
||||
'd': 'pages/proxnav/preset/discord.html',
|
||||
'r': 'pages/proxnav/preset/reddit.html',
|
||||
/* Misc */
|
||||
'fg': 'archive/gfiles/flash/index.html',
|
||||
'eg': 'archive/gfiles/rarch/index.html',
|
||||
'vos': 'archive/vibeOS/index.html'
|
||||
};
|
||||
|
||||
const cookingInserts = insert.content;
|
||||
const vegetables = insert.keywords;
|
||||
const charRandom = insert.chars;
|
||||
const cacheBustList = {
|
||||
// "styles.css": "styles-1642900360.min.css",
|
||||
"common.js": "common-1643838852.js",
|
||||
"links.js": "links-1642900360.js"
|
||||
};
|
||||
|
||||
function randomListItem(lis) {
|
||||
return lis[Math.floor(Math.random() * lis.length)];
|
||||
}
|
||||
|
||||
function redditFix(str) {
|
||||
return str.replace(/Ch­a­tbo­x/g, 'Re­dd­it');
|
||||
}
|
||||
|
||||
function insertCharset(str) {
|
||||
return str.replace(/­|​|<wbr>/g, function() { return randomListItem(charRandom); });
|
||||
return str.replace(/­|​|­|<wbr>/g, function() { return randomListItem(charRandom); }); // this needs to be inside a function, so that not every string is the same
|
||||
}
|
||||
|
||||
function insertCooking(str) {
|
||||
return str.replace(/<!-- IMPORTANT-HUCOOKINGINSERT-DONOTDELETE -->/g, function() { return '<span style="display: none;" data-fact="' + randomListItem(vegetables) + '" data-type="' + randomListItem(vegetables) + '">' + randomListItem(cookingInserts) + '</span>'; });
|
||||
return str.replace(/<!-- IMPORTANT-HUCOOKINGINSERT-DONOTDELETE -->/g, function() { return '<span style="display: none;" data-fact="' + randomListItem(vegetables) + '" data-type="' + randomListItem(vegetables) + '">' + randomListItem(cookingInserts) + '</span>'; }); // this needs to be inside a function, so that not every string is the same
|
||||
}
|
||||
|
||||
function splashPublic(str) {
|
||||
return str.replace(/<!-- ######## -->/g, function() { return '<p class="text-center">Jo­in the <a id="tnlink" target="_blank">T­N Dis­co­rd</a> for more pr­iva️te site lin­ks. Note that this is the public version of HU which is not official. Things may not work or are unsecure.</p>'; }); // this needs to be inside a function, so that not every string is the same
|
||||
}
|
||||
|
||||
function cacheBusting(str) {
|
||||
return str.replace(/styles.min.css/g, 'styles-1636936688.min.css');
|
||||
}
|
||||
|
||||
function cacheBusting2(str) {
|
||||
return str.replace(/common.js/g, 'common-1628457888.js');
|
||||
}
|
||||
|
||||
function cacheBusting3(str) {
|
||||
return str.replace(/surf.js/g, 'surf-1628130462.js');
|
||||
for (var item of Object.entries(cacheBustList)) {
|
||||
str = str.replace(new RegExp(item[0], "g"), item[1]);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function insertAll(str) {
|
||||
return insertCharset(insertCooking(redditFix(cacheBusting(cacheBusting2(cacheBusting3(str))))));
|
||||
return insertCharset(insertCooking(splashPublic(cacheBusting(str))));
|
||||
}
|
||||
|
||||
function tryReadFile(file) {
|
||||
return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : text404;
|
||||
}
|
||||
|
||||
let blacklist;
|
||||
|
||||
const fetch = (...args) =>
|
||||
import ('node-fetch').then(({ default: fetch }) => fetch(...args));
|
||||
|
||||
let blacklist;
|
||||
|
||||
fetch("https://blocklistproject.github.io/Lists/alt-version/everything-nl.txt").then(response => response.text()).then(data => {
|
||||
blacklist = data.split("\n") && config.blacklist;
|
||||
});
|
||||
|
@ -103,7 +106,6 @@ fetch("https://blocklistproject.github.io/Lists/alt-version/everything-nl.txt").
|
|||
const proxy = new corrosion({
|
||||
title: config.title,
|
||||
prefix: config.prefix || '/search/',
|
||||
forceHttps: true,
|
||||
codec: config.codec || 'xor',
|
||||
ws: config.ws,
|
||||
requestMiddleware: [
|
||||
|
@ -120,7 +122,7 @@ app.get('/', async(req, res) => res.send(insertAll(tryReadFile(path.normalize(__
|
|||
app.use(express.static(path.normalize(__dirname + '/views')));
|
||||
app.use((req, res) => {
|
||||
if (req.url.startsWith(proxy.prefix)) return proxy.request(req, res);
|
||||
res.status(404, res.send(insertAll(text404)))
|
||||
res.status(404).send(insertAll(text404));
|
||||
});
|
||||
|
||||
server.listen(port);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue