mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-17 13:30:00 -04:00
SiteSupport.json for automatic mode
This commit is contained in:
parent
2b1e62c830
commit
c771252e78
2 changed files with 27 additions and 3 deletions
|
@ -4,6 +4,8 @@ import { useEffect, useState } from "preact/hooks";
|
|||
//import our Iframe component
|
||||
import { Iframe } from "../components/iframe/Iframe";
|
||||
|
||||
import SiteSupport from "../util/SiteSupport.json";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__uv$config: any;
|
||||
|
@ -38,9 +40,25 @@ export function ProxyFrame(props: { url: string }) {
|
|||
result =
|
||||
window.__dynamic$config.prefix + encodeURIComponent(decodedUrl);
|
||||
} else {
|
||||
result =
|
||||
window.__uv$config.prefix +
|
||||
window.__uv$config.encodeUrl(decodedUrl);
|
||||
// automatic. use SiteSupport.json to determine proxy support
|
||||
const matchingKey = Object.keys(SiteSupport).find((key) =>
|
||||
decodedUrl.includes(key)
|
||||
);
|
||||
|
||||
if (SiteSupport[matchingKey] === "ultraviolet") {
|
||||
result =
|
||||
window.__uv$config.prefix +
|
||||
window.__uv$config.encodeUrl(decodedUrl);
|
||||
} else if (SiteSupport[matchingKey] === "dynamic") {
|
||||
result =
|
||||
window.__dynamic$config.prefix + encodeURIComponent(decodedUrl);
|
||||
} else if (SiteSupport[matchingKey] === "rammerhead") {
|
||||
result = await RammerheadEncode(decodedUrl);
|
||||
} else {
|
||||
result =
|
||||
window.__uv$config.prefix +
|
||||
window.__uv$config.encodeUrl(decodedUrl); // uv as backup
|
||||
}
|
||||
}
|
||||
setProxiedUrl(result);
|
||||
} catch (error) {
|
||||
|
|
6
src/util/SiteSupport.json
Normal file
6
src/util/SiteSupport.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"youtube.com": "dynamic",
|
||||
"youtu.be": "dynamic",
|
||||
"example.org": "rammerhead",
|
||||
"example.com": "ultraviolet"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue