cleanup and ads

Co-authored-by: Cobalt-60 <plastics-eater@users.noreply.github.com>
This commit is contained in:
Russell2259
2024-02-29 21:29:20 -07:00
parent 30628b3b82
commit 6e38da7dbb
8 changed files with 69 additions and 53 deletions
+15 -10
View File
@@ -33,20 +33,25 @@ app.get('/cdn/*', cors({
}), async (req, res, next) => {
const reqTarget = req.path.startsWith('/cdn/3kh0/') ? `https://player.work/${req.path.replace('/cdn/3kh0/', '')}` : `https://raw.githubusercontent.com/Skoolgq/Polaris-Assets/main/${req.path.replace('/cdn/', '')}`;
const asset = await fetch(reqTarget);
try {
const asset = await fetch(reqTarget);
if (asset.status == 200) {
var data = Buffer.from(await asset.arrayBuffer());
if (asset.status == 200) {
var data = Buffer.from(await asset.arrayBuffer());
const noRewrite = ['.unityweb'];
if (!noRewrite.includes(mime.getExtension(reqTarget))) res.writeHead(200, {
'content-type': mime.getType(reqTarget)
});
const noRewrite = ['.unityweb'];
if (!noRewrite.includes(mime.getExtension(reqTarget))) res.writeHead(200, {
'content-type': mime.getType(reqTarget)
});
if (mime.getType(reqTarget) === 'text/html') data = data + '<script src=\'/assets/js/cdn.inject.js\' preload=\'true\'></script>';
if (mime.getType(reqTarget) === 'text/html') data = data + '<script src=\'/assets/js/cdn.inject.js\' preload=\'true\'></script>';
res.end(data);
} else next();
res.end(data);
} else next();
} catch {
res.setHeader('content-type', 'text/html');
res.status(404).end(await rewriter.html(fs.readFileSync(path.join(__dirname, '../pages/404.html'))));
}
});
app.get('*', (req, res, next) => {
+4 -5
View File
@@ -103,10 +103,10 @@ const hyperlinkHandler = (hyperlink, e) => {
document.querySelectorAll('a').forEach(hyperlink => hyperlink.addEventListener('click', (e) => hyperlinkHandler(hyperlink, e)));
window.onhashchange = () => {
window.addEventListener('hashchange', () => {
if (location.hash === '#settings') document.querySelector('.sidebar').classList.add('active');
else document.querySelector('.sidebar').classList.remove('active');
};
});
if (window.self === window.top && location.pathname !== '/view') setTimeout(async () => {
loadSettings();
@@ -114,7 +114,6 @@ if (window.self === window.top && location.pathname !== '/view') setTimeout(asyn
if (location.pathname === '/games') Games.load();
if (location.pathname === '/apps') Apps.load();
if (location.pathname === '/search') Search.load();
if (location.pathname === '/') Search.load();
if (location.pathname === '/cheats') Cheats.load();
}, 500);
@@ -221,9 +220,9 @@ if (window.self === window.top && location.pathname !== '/view') {
else document.querySelector('.navbar').classList.remove('scrolling');
}
if (window.self === window.top && location.pathname !== '/view') window.onscroll = () => {
if (window.self === window.top && location.pathname !== '/view') window.addEventListener('scroll', () => {
if (window.scrollY !== 0) document.querySelector('.navbar').classList.add('scrolling');
else document.querySelector('.navbar').classList.remove('scrolling');
}
});
if (window.self !== window.top && document.querySelector('.navbar')) document.querySelector('.navbar').remove();
+4 -5
View File
@@ -278,12 +278,12 @@ const loadSidebarInterface = () => {
document.querySelector('#panic_url').addEventListener('input', (e) => settingsStorage.set('panic_url', document.querySelector('#panic_url').value));
window.onkeydown = (e) => {
window.addEventListener('keydown', (e) => {
if (document.querySelector('#panic_key') == document.activeElement) {
document.querySelector('#panic_key').value = e.key;
settingsStorage.set('panic_key', document.querySelector('#panic_key').value);
}
}
});
document.querySelector('#themes').querySelectorAll('button').forEach(el => el.onclick = () => Theme.set(el.innerText.toLocaleLowerCase()));
@@ -349,12 +349,11 @@ const loadSettings = () => {
});
}
window.onkeydown = (e) => {
window.addEventListener('keydown', (e) => {
if (e.key === settingsStorage.get('panic_key')) {
if (settingsStorage.get('panic_url')) window.location.href = settingsStorage.get('panic_url');
else new PolarisError('A panic key was used but no url was found.');
}
}
});
/*if (new URLSearchParams(location.search).get('clickoff')) {
+16 -20
View File
@@ -8,7 +8,7 @@ import ctc from './utils/ctc.js';
* The storage interface for polaris
* @param {string} containerName
*/
const storage = (containerName) => {
export const storage = (containerName) => {
return {
/**
* Get a value from the storage container
@@ -54,13 +54,13 @@ const storage = (containerName) => {
/**
* @returns {string}
*/
const uuid = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16));
export const uuid = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16));
/**
* Register a proxy service worker
* @param {'uv' | 'dynamic'} proxy
*/
const loadProxyWorker = async (proxy) => await navigator.serviceWorker.register(`/${proxy}/sw.js`, {
export const loadProxyWorker = async (proxy) => await navigator.serviceWorker.register(`/${proxy}/sw.js`, {
scope: `/${proxy}/service/`
});
@@ -102,7 +102,7 @@ const loadPageScript = () => {
}
};
const encoder = {
export const encoder = {
b64: {
encode: (data) => btoa(data),
decode: (data) => atob(data)
@@ -118,7 +118,7 @@ const encoder = {
* @param {string} target
* @param {{ trusted: boolean }} options
*/
const redirect = (target, options) => location.href = `/view?load=${btoa(JSON.stringify({
export const redirect = (target, options) => location.href = `/view?load=${btoa(JSON.stringify({
target,
redirect: true,
trusted: options.trusted
@@ -128,7 +128,7 @@ const redirect = (target, options) => location.href = `/view?load=${btoa(JSON.st
* Load a url into the view page
* @param {{ target: string, title: string, return: string, proxied: boolean }} options
*/
const createViewPage = (options) => location.href = `/view?load=${btoa(JSON.stringify({
export const createViewPage = (options) => location.href = `/view?load=${btoa(JSON.stringify({
return: options.return || location.href,
proxied: options.proxied,
target: options.target,
@@ -140,15 +140,21 @@ const createViewPage = (options) => location.href = `/view?load=${btoa(JSON.stri
* @param {string} url
* @returns {boolean}
*/
const isValidURL = (url) => /^(http(s)?:\/\/)?([\w-]+\.)+[\w]{2,}(\/.*)?$/.test(url);
export const isValidURL = (url) => /^(http(s)?:\/\/)?([\w-]+\.)+[\w]{2,}(\/.*)?$/.test(url);
/**
* Get the css vh value
* @param {*} value
* @returns {number}
*/
const getVH = (value) => (value * Math.max(document.documentElement.clientHeight, window.innerHeight || 0)) / 100;
const getVW = (value) => (value * Math.max(document.documentElement.clientWidth, window.innerWidth || 0)) / 100;
const isScrollable = (element) => element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight;
export const getVH = (value) => (value * Math.max(document.documentElement.clientHeight, window.innerHeight || 0)) / 100;
export const getVW = (value) => (value * Math.max(document.documentElement.clientWidth, window.innerWidth || 0)) / 100;
export const isScrollable = (element) => element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight;
/**
* @param {() => {}} code
* @returns {string}
*/
export const evalify = (code) => '(' + String(code) + ')()';
/**
* @type {import('./utils/ctc.js').CrossTabCommunication}
@@ -178,19 +184,9 @@ export default {
};
export {
storage,
loadProxyWorker,
encoder,
redirect,
createViewPage,
isValidURL,
getVH,
getVW,
isScrollable,
indexedDBExporter,
EventEmitter,
cookie,
uuid,
CrossTabCommunication,
PolarisError
};
-9
View File
@@ -39,15 +39,6 @@
<a href="/tos" class="blue">Terms of Service</a>
</p>
<!--
Making this an experiment. Don't touch.
<hr>
<form id="wpf">
<input class="proxyinput-index" type="text" id="query" placeholder="Search without restrictions..." />
</form>-->
<hr>
<h2 style="margin-bottom: 0px;">Changelog</h2>
+28 -1
View File
@@ -1,4 +1,4 @@
<div id="bannerad728"></div>
<!--<div id="bannerad728"></div>
<script>
window['nitroAds'].createAd('bannerad728', {
@@ -17,4 +17,31 @@
"position": "top-right"
}
});
</script>
-->
<script type="module">
import { evalify } from '/assets/js/utils.js';
eval(evalify(() => {
const window = {
...self,
location: {
...self.location,
replace: () => {
throw new Error('Failed to redirect')
}
}
};
const location = {
...self.location,
replace: () => {
throw new Error('Failed to redirect')
}
};
location.replace('https://google.com')
{{ ad_src }}
}).replace('{{ ad_src }}', await (await fetch('//outrightsham.com/ae1638b56336895e2ecf7d1adc3492a4/invoke.js')).text()));
</script>
+2 -2
View File
@@ -1,2 +1,2 @@
<script data-cfasync="false">window.nitroAds=window.nitroAds||{createAd:function(){return new Promise(e=>{window.nitroAds.queue.push(["createAd",arguments,e])})},addUserToken:function(){window.nitroAds.queue.push(["addUserToken",arguments])},queue:[]};</script>
<script data-cfasync="false" async src="https://s.nitropay.com/ads-1751.js"></script>
<script data-cfasync="false">window.nitroAds = window.nitroAds || { createAd: function () { return new Promise(e => { window.nitroAds.queue.push(["createAd", arguments, e]) }) }, addUserToken: function () { window.nitroAds.queue.push(["addUserToken", arguments]) }, queue: [] };</script>
<script data-cfasync="false" async src="https://s.nitropay.com/ads-1751.js"></script>
-1
View File
@@ -1,4 +1,3 @@
<script src="https://polaris4.statuspage.io/embed/script.js"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-KZRKZE212Q"></script>
<script>