Implement new tab and about:blank opening modes
This commit is contained in:
parent
59515a314e
commit
815f4d5999
4 changed files with 69 additions and 5 deletions
3
index.js
3
index.js
|
|
@ -49,7 +49,6 @@ app.use(
|
|||
);
|
||||
app.use(function (req, res, next) {
|
||||
if (req.originalUrl.includes("/games")) {
|
||||
res.header("Cross-Origin-Embedder-Policy", "require-corp");
|
||||
res.header("Cross-Origin-Opener-Policy", "same-origin");
|
||||
}
|
||||
next();
|
||||
|
|
@ -69,7 +68,7 @@ app.get("/search", async (req, res) => {
|
|||
}
|
||||
});
|
||||
app.get("*", function (req, res) {
|
||||
res.redirect(302, "/404.html");
|
||||
res.sendFile(path.join(process.cwd(), "dist/client/404.html"));
|
||||
});
|
||||
|
||||
let server = createServer();
|
||||
|
|
|
|||
11
public/iframe.css
Normal file
11
public/iframe.css
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/* CSS for about:blank iframes */
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
}
|
||||
|
|
@ -17,12 +17,61 @@
|
|||
form.addEventListener("submit", formEventListener);
|
||||
}
|
||||
|
||||
async function loadContent() {
|
||||
let loadingContent = document.getElementById("loading-content");
|
||||
loadingContent.style.opacity = 1;
|
||||
async function getProxyURL() {
|
||||
let preference = getProxyPreference();
|
||||
let url = input.value.trim();
|
||||
if (!isUrl(url)) url = getSearchEngine() + url;
|
||||
else if (!(url.startsWith("https://") || url.startsWith("http://"))) url = "http://" + url;
|
||||
if (preference === "ultraviolet") {
|
||||
return window.__uv$config.prefix + window.__uv$config.encodeUrl(url);
|
||||
} else if (preference == "rammerhead") {
|
||||
// Check if rammerhead-session exists in cookies
|
||||
let rammerheadSession = getCookie("rammerhead-session");
|
||||
if (!rammerheadSession) {
|
||||
let session = await fetch("/newsession");
|
||||
let sessionID = await session.text();
|
||||
// Disable URL shuffling on rewrite, eventually I'll try and figure out how it works, but for now, it's disabled.
|
||||
await fetch("/editsession?id=" + sessionID + "&enableShuffling=0");
|
||||
// Now save it in a cookie that expires in 72 hours.
|
||||
document.cookie = `rammerhead-session=${sessionID}; max-age=${60 * 60 * 72}; path=/`;
|
||||
// Now add an origin_proxy cookie for our domain
|
||||
document.cookie = `origin_proxy=${window.location.origin}; max-age=${60 * 60 * 72}; path=/`;
|
||||
}
|
||||
return `/${getCookie("rammerhead-session")}/${url}`;
|
||||
} else {
|
||||
// Default to UV
|
||||
return window.__uv$config.prefix + window.__uv$config.encodeUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadContent() {
|
||||
let openWith = localStorage.getItem("alu__selectedOpenWith");
|
||||
let url = input.value.trim();
|
||||
if (!isUrl(url)) url = getSearchEngine() + url;
|
||||
else if (!(url.startsWith("https://") || url.startsWith("http://"))) url = "http://" + url;
|
||||
if (openWith) {
|
||||
let openWithParsed = JSON.parse(openWith);
|
||||
if (openWithParsed.value === "newTab") {
|
||||
window.open(await getProxyURL(), "_blank");
|
||||
return;
|
||||
}
|
||||
if (openWithParsed.value === "about:blank") {
|
||||
// Open about:blank window and inject iframe into it
|
||||
let newWindow = window.open("about:blank", "_blank");
|
||||
let newWindowDocument = newWindow.document;
|
||||
let iframe = newWindowDocument.createElement("iframe");
|
||||
iframe.src = await getProxyURL();
|
||||
// Inject css into the iframe
|
||||
let css = newWindowDocument.createElement("link")
|
||||
css.rel = "stylesheet";
|
||||
css.href = "/iframe.css";
|
||||
newWindowDocument.head.appendChild(css);
|
||||
newWindowDocument.body.appendChild(iframe);
|
||||
return;
|
||||
}
|
||||
}
|
||||
let loadingContent = document.getElementById("loading-content");
|
||||
loadingContent.style.opacity = 1;
|
||||
|
||||
let iframe = document.getElementById("proxy-frame");
|
||||
let topbar = document.getElementById("top-bar");
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ const presetCloaks = [
|
|||
cloakTitle: "Schoology",
|
||||
favicon: "https://asset-cdn.schoology.com/sites/all/themes/schoology_theme/favicon.ico",
|
||||
},
|
||||
{
|
||||
cloakTitle: "YouTube",
|
||||
favicon: "https://www.youtube.com/s/desktop/0f128ffd/img/favicon_144x144.png",
|
||||
}
|
||||
];
|
||||
---
|
||||
|
||||
|
|
@ -70,6 +74,7 @@ const presetCloaks = [
|
|||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.cloak-item {
|
||||
width: 75px;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue