Refactor code :3

This commit is contained in:
Ashley 2023-05-21 20:19:50 +00:00
parent 42927355aa
commit 18bb13b18e

View file

@ -62,17 +62,11 @@ module.exports = function (app, config, renderTemplate) {
}); });
}); });
app.get("/:v*?", async function (req, res) { app.get("/:v*?", async function (req, res) {
var uaos = req.useragent.os; const uaos = req.useragent.os;
var IsOldWindows; const browser = req.useragent.browser;
const isOldWindows =
if (uaos == "Windows 7" && req.useragent.browser == "Firefox") { (uaos === "Windows 7" || uaos === "Windows 8") && browser === "Firefox";
IsOldWindows = true;
} else if (uaos == "Windows 8" && req.useragent.browser == "Firefox") {
IsOldWindows = true;
} else {
IsOldWindows = false;
}
const rendermainpage = () => { const rendermainpage = () => {
if (req.useragent.isMobile) { if (req.useragent.isMobile) {
@ -80,11 +74,11 @@ module.exports = function (app, config, renderTemplate) {
} }
return renderTemplate(res, req, "landing.ejs", { return renderTemplate(res, req, "landing.ejs", {
IsOldWindows isOldWindows,
}); });
}; };
if (req.params.v && /[a-zA-Z0-9]+/.test(req.param.v)) { if (req.params.v && /[a-zA-Z0-9]+/.test(req.params.v)) {
const isvld = await core.isvalidvideo(req.params.v); const isvld = await core.isvalidvideo(req.params.v);
if (isvld) { if (isvld) {
return res.redirect(`/watch?v=${req.params.v}`); return res.redirect(`/watch?v=${req.params.v}`);
@ -92,5 +86,6 @@ module.exports = function (app, config, renderTemplate) {
} }
return rendermainpage(); return rendermainpage();
}); });
}; };