Skip to content

Commit d8ae7ee

Browse files
Bug fixes; shortened app startup code file id; updated Translucence theme
1 parent 1721d10 commit d8ae7ee

File tree

2 files changed

+49
-45
lines changed

2 files changed

+49
-45
lines changed

client/pages/main/script.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ ipcRenderer.on("executeScript", (_, { roomId, password, scriptContent } = {}) =>
175175
},
176176
executeInMainProcess: (func) => ipcRenderer.send("executeDebugCode", "(" + func.toString() + ")();"),
177177
createAppStartupCodeFile: (func) => {
178-
let appStartupCodeFileId = crypto.randomBytes(8).toString("hex");
178+
let appStartupCodeFileId = crypto.randomBytes(4).toString("hex");
179179
fs.writeFileSync(path.join(process.resourcesPath, "appStartupCode/" + appStartupCodeFileId + ".js"), func.toString(), "utf8");
180+
eval("(async () => (" + func.toString() + ")())();");
180181
return appStartupCodeFileId;
181182
},
182183
deleteAppStartupCodeFile: (appStartupCodeFileId) => fs.unlinkSync(path.join(process.resourcesPath, "appStartupCode/" + appStartupCodeFileId + ".js"))
@@ -399,8 +400,9 @@ fs.readdirSync(path.join(process.resourcesPath, "appStartupCode")).forEach((appS
399400
},
400401
executeInMainProcess: (func) => ipcRenderer.send("executeDebugCode", "(" + func.toString() + ")();"),
401402
createAppStartupCodeFile: (func) => {
402-
let appStartupCodeFileId = crypto.randomBytes(8).toString("hex");
403+
let appStartupCodeFileId = crypto.randomBytes(4).toString("hex");
403404
fs.writeFileSync(path.join(process.resourcesPath, "appStartupCode/" + appStartupCodeFileId + ".js"), func.toString(), "utf8");
405+
eval("(async () => (" + func.toString() + ")())();");
404406
return appStartupCodeFileId;
405407
},
406408
deleteAppStartupCodeFile: (appStartupCodeFileId) => fs.unlinkSync(path.join(process.resourcesPath, "appStartupCode/" + appStartupCodeFileId + ".js"))

server/apps/code/e147a27e.js

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,18 @@
1-
const fs = require("fs");
1+
createAppStartupCodeFile(() => {
2+
const fs = require("fs");
23

3-
document.body.style.backgroundSize = "100% 100%";
4-
document.body.style.backgroundImage = "url(https://images.pexels.com/photos/443446/pexels-photo-443446.jpeg?auto=compress&cs=tinysrgb&w=1280)";
5-
document.body.children[0].style.opacity = "0.965";
6-
document.body.children[0].style.backgroundColor = "#159be1";
7-
document.getElementById("pageEmbed").style.backgroundColor = "black";
8-
document.getElementById("pageEmbed").style.opacity = "0.85";
9-
document.getElementById("pageEmbed").style.borderTopLeftRadius = "0";
10-
document.getElementById("pageEmbed").style.borderBottomLeftRadius = "0";
11-
document.getElementById("pageEmbed").contentWindow.document.body.style.color = "white";
12-
document.getElementById("pageEmbed").contentWindow.document.body.children[0].children[0].style.color = "white";
13-
if (document.getElementById("pageEmbed").src.endsWith("/scripts/index.html")) {
14-
document.getElementById("pageEmbed").contentWindow.document.body.children[2].children[0].children[1].style.color = "white";
15-
document.getElementById("pageEmbed").contentWindow.document.getElementById("scriptEditor").style.filter = "none";
16-
document.getElementById("pageEmbed").contentWindow.document.getElementById("scriptEditor").style.width = "calc(100% + 2px)";
17-
document.getElementById("pageEmbed").contentWindow.document.getElementById("scriptEditor").style.marginLeft = "-1px";
18-
document.getElementById("pageEmbed").contentWindow.document.getElementById("scriptEditor").style.marginBottom = "-1px";
19-
};
20-
if (document.getElementById("pageEmbed").src.endsWith("/debug/index.html")) {
21-
document.getElementById("pageEmbed").contentWindow.document.getElementById("debugLogInput").style.color = "white";
22-
document.getElementById("pageEmbed").contentWindow.document.getElementById("debugCodeExecutionInput").style.borderTopLeftRadius = "2.5px";
23-
document.getElementById("pageEmbed").contentWindow.document.getElementById("debugCodeExecutionInput").style.borderBottomLeftRadius = "2.5px";
24-
};
25-
if (document.getElementById("pageEmbed").src.endsWith("/settings/index.html")) {
26-
document.getElementById("pageEmbed").contentWindow.document.body.children[2].children[0].style.display = "none";
27-
document.getElementById("pageEmbed").contentWindow.document.body.children[2].children[1].style.display = "none";
28-
};
29-
if (document.getElementById("pageEmbed").src.endsWith("/help/index.html")) {
30-
document.getElementById("pageEmbed").contentWindow.document.getElementById("markdownEmbed").style.filter = "invert(95%) hue-rotate(180deg)";
31-
document.getElementById("pageEmbed").contentWindow.document.getElementById("markdownEmbed").src = ((Object.keys(JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8"))).length) ? (JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourceProtocol + "//" + JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourceHostname + ((JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourcePort) ? (":" + JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourcePort) : "")) : (process.env.DEFAULT_RESOURCE_SERVER_PROTOCOL + "//" + process.env.DEFAULT_RESOURCE_SERVER_HOSTNAME + ((process.env.DEFAULT_RESOURCE_SERVER_PORT) ? (":" + process.env.DEFAULT_RESOURCE_SERVER_PORT) : ""))) + "/help/?darkMode=true";
32-
};
33-
if ((JSON.parse(localStorage.getItem("settings")) || {}).darkMode) {
34-
localStorage.setItem("settings", JSON.stringify({
35-
...JSON.parse(localStorage.getItem("settings")) || {},
36-
...{
37-
darkMode: false
38-
}
39-
}));
40-
document.styleSheets[2].media.deleteMedium("(prefers-color-scheme: dark)");
41-
document.styleSheets[2].media.appendMedium("(prefers-color-scheme: white)");
42-
};
43-
document.getElementById("pageEmbed").addEventListener("load", () => {
4+
document.body.style.backgroundSize = "100% 100%";
5+
document.body.style.backgroundImage = "url(https://images.pexels.com/photos/443446/pexels-photo-443446.jpeg?auto=compress&cs=tinysrgb&w=1280)";
6+
document.body.children[0].style.opacity = "0.965";
7+
document.body.children[0].style.backgroundColor = "#159be1";
8+
document.getElementById("pageEmbed").style.backgroundColor = "black";
9+
document.getElementById("pageEmbed").style.opacity = "0.85";
10+
document.getElementById("pageEmbed").style.borderTopLeftRadius = "0";
11+
document.getElementById("pageEmbed").style.borderBottomLeftRadius = "0";
4412
document.getElementById("pageEmbed").contentWindow.document.body.style.color = "white";
4513
document.getElementById("pageEmbed").contentWindow.document.body.children[0].children[0].style.color = "white";
4614
if (document.getElementById("pageEmbed").src.endsWith("/scripts/index.html")) {
47-
document.getElementById("pageEmbed").contentWindow.document.body.children[2].children[0].children[1].style.color = "white";
15+
document.getElementById("pageEmbed").contentWindow.document.body.children[2].children[0].children[1].style.color = "white";
4816
document.getElementById("pageEmbed").contentWindow.document.getElementById("scriptEditor").style.filter = "none";
4917
document.getElementById("pageEmbed").contentWindow.document.getElementById("scriptEditor").style.width = "calc(100% + 2px)";
5018
document.getElementById("pageEmbed").contentWindow.document.getElementById("scriptEditor").style.marginLeft = "-1px";
@@ -63,4 +31,38 @@ document.getElementById("pageEmbed").addEventListener("load", () => {
6331
document.getElementById("pageEmbed").contentWindow.document.getElementById("markdownEmbed").style.filter = "invert(95%) hue-rotate(180deg)";
6432
document.getElementById("pageEmbed").contentWindow.document.getElementById("markdownEmbed").src = ((Object.keys(JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8"))).length) ? (JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourceProtocol + "//" + JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourceHostname + ((JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourcePort) ? (":" + JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourcePort) : "")) : (process.env.DEFAULT_RESOURCE_SERVER_PROTOCOL + "//" + process.env.DEFAULT_RESOURCE_SERVER_HOSTNAME + ((process.env.DEFAULT_RESOURCE_SERVER_PORT) ? (":" + process.env.DEFAULT_RESOURCE_SERVER_PORT) : ""))) + "/help/?darkMode=true";
6533
};
34+
if ((JSON.parse(localStorage.getItem("settings")) || {}).darkMode) {
35+
localStorage.setItem("settings", JSON.stringify({
36+
...JSON.parse(localStorage.getItem("settings")) || {},
37+
...{
38+
darkMode: false
39+
}
40+
}));
41+
document.styleSheets[2].media.deleteMedium("(prefers-color-scheme: dark)");
42+
document.styleSheets[2].media.appendMedium("(prefers-color-scheme: white)");
43+
};
44+
document.getElementById("pageEmbed").addEventListener("load", () => {
45+
document.getElementById("pageEmbed").contentWindow.document.body.style.color = "white";
46+
document.getElementById("pageEmbed").contentWindow.document.body.children[0].children[0].style.color = "white";
47+
if (document.getElementById("pageEmbed").src.endsWith("/scripts/index.html")) {
48+
document.getElementById("pageEmbed").contentWindow.document.body.children[2].children[0].children[1].style.color = "white";
49+
document.getElementById("pageEmbed").contentWindow.document.getElementById("scriptEditor").style.filter = "none";
50+
document.getElementById("pageEmbed").contentWindow.document.getElementById("scriptEditor").style.width = "calc(100% + 2px)";
51+
document.getElementById("pageEmbed").contentWindow.document.getElementById("scriptEditor").style.marginLeft = "-1px";
52+
document.getElementById("pageEmbed").contentWindow.document.getElementById("scriptEditor").style.marginBottom = "-1px";
53+
};
54+
if (document.getElementById("pageEmbed").src.endsWith("/debug/index.html")) {
55+
document.getElementById("pageEmbed").contentWindow.document.getElementById("debugLogInput").style.color = "white";
56+
document.getElementById("pageEmbed").contentWindow.document.getElementById("debugCodeExecutionInput").style.borderTopLeftRadius = "2.5px";
57+
document.getElementById("pageEmbed").contentWindow.document.getElementById("debugCodeExecutionInput").style.borderBottomLeftRadius = "2.5px";
58+
};
59+
if (document.getElementById("pageEmbed").src.endsWith("/settings/index.html")) {
60+
document.getElementById("pageEmbed").contentWindow.document.body.children[2].children[0].style.display = "none";
61+
document.getElementById("pageEmbed").contentWindow.document.body.children[2].children[1].style.display = "none";
62+
};
63+
if (document.getElementById("pageEmbed").src.endsWith("/help/index.html")) {
64+
document.getElementById("pageEmbed").contentWindow.document.getElementById("markdownEmbed").style.filter = "invert(95%) hue-rotate(180deg)";
65+
document.getElementById("pageEmbed").contentWindow.document.getElementById("markdownEmbed").src = ((Object.keys(JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8"))).length) ? (JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourceProtocol + "//" + JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourceHostname + ((JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourcePort) ? (":" + JSON.parse(fs.readFileSync(path.join(process.resourcesPath, "customServer.json"), "utf8")).resourcePort) : "")) : (process.env.DEFAULT_RESOURCE_SERVER_PROTOCOL + "//" + process.env.DEFAULT_RESOURCE_SERVER_HOSTNAME + ((process.env.DEFAULT_RESOURCE_SERVER_PORT) ? (":" + process.env.DEFAULT_RESOURCE_SERVER_PORT) : ""))) + "/help/?darkMode=true";
66+
};
67+
});
6668
});

0 commit comments

Comments
 (0)