mogultv/constants-27e12ede.js

94 lines
2.9 KiB
JavaScript

async function e(e) {
const t = await async function(e, t) {
const n = t.cookies.SAPISID || t.cookies["__Secure-3PAPISID"];
if (!n) return {
success: !1,
code: 400,
message: "Missing cookie"
};
const o = new URL(t.href).origin,
a = Math.floor(Date.now() / 1e3),
c = await async function(e) {
const t = await crypto.subtle.digest("SHA-1", (new TextEncoder).encode(e));
return Array.from(new Uint8Array(t)).map((e => e.toString(16).padStart(2, "0"))).join("")
}(`${a} ${n} ${o}`), s = {
"x-origin": o,
authorization: `SAPISIDHASH ${a}_${c}`,
"x-goog-authuser": t.authUser,
cookie: Object.entries(t.cookies).map((([e, t]) => `${e}=${t}`)).join(";")
};
t.pageId && (s["x-goog-pageid"] = t.pageId);
const i = await fetch(`https://www.youtube.com${e}?key=${t.key}`, {
method: "POST",
headers: s,
body: JSON.stringify({
context: t.context
})
});
return {
success: !0,
data: await i.json()
}
}("/youtubei/v1/account/account_menu", e);
if (!t.success) return t;
const n = t.data;
try {
const e = n.actions[0].openPopupAction.popup.multiPageMenuRenderer,
t = e.header.activeAccountHeaderRenderer,
o = e.sections[0].multiPageMenuSectionRenderer.items[0].compactLinkRenderer.navigationEndpoint.browseEndpoint.browseId.trim().replace(/\n/g, ""),
a = n.responseContext.mainAppWebResponseContext.datasyncId.split("||")[0];
return /^UC.{22}$/.test(o) ? {
success: !0,
data: {
id: o,
googleUserId: a,
profile: t.accountPhoto.thumbnails[0].url,
username: t.accountName.simpleText
}
} : {
success: !1,
code: 400,
message: "Failed to authenticate"
}
} catch (e) {
return {
success: !1,
code: 400,
message: "Failed to authenticate"
}
}
}
function t(e) {
let t = 0;
if (0 === e.length) return 0;
for (let n = 0; n < e.length; n++) {
t = (t << 5) - t + e.charCodeAt(n), t |= 0;
}
return t
}
function n(e) {
return `hsl(${(t(e)%60+60)%60*6}deg, 100%, 70%)`
}
const o = ["#ff0000", "#009000", "#b22222", "#ff7f50", "#9acd32", "#ff4500", "#2e8b57", "#daa520", "#d2691e", "#5f9ea0", "#1e90ff", "#ff69b4", "#00ff7f", "#a244f9"];
function a(e) {
const n = t(e);
return o[(n % o.length + o.length) % o.length]
}
const c = {
ONE_SECOND_MS: 1e3,
ONE_MINUTE_SECONDS: 60,
ONE_MINUTE_MS: 6e4,
FIVE_MINUTE_MS: 3e4,
FIVE_MINUTE_SECONDS: 300,
DEFAULT_EXTENSION_MAPPING_IFRAME_STYLES: "\n\t\twidth: 0;\n\t\theight: 0;\n\t"
};
export {
a,
c,
e,
n
};