Files
discord-decomp/_bundle/Module6376.js
T
2026-11-01 12:12:55 +02:00

139 lines
3.8 KiB
JavaScript

// Metro module 6376 (f6377).
import { GLOBAL_OBJ } from "./Module6369";
import { isString } from "./isInstanceOf_6375";
const _htmlElementAsString = function _htmlElementAsString(a0, a1) {
const r4 = [];
let c15693_1 = r4;
if (a0 && a0.tagName) {
if (GLOBAL_OBJ.HTMLElement && a0 instanceof HTMLElement && a0.dataset) {
const sentryComponent = a0.dataset.sentryComponent;
const dataset = a0.dataset;
if (sentryComponent) {
return dataset.sentryComponent;
}
if (dataset.sentryElement) {
return a0.dataset.sentryElement;
}
}
r4.push(a0.tagName.toLowerCase());
const r47 = a1 ? a1.length ? a1.filter((item) => a0.getAttribute(item)).map((item) => [item, a0.getAttribute(item)]) : null : null;
if (r47 && r47.length) {
r47.forEach((item) => {
c15693_1.push(`[${item[0]}="${item[1]}"]`);
});
} else {
if (a0.id) {
r4.push(`#${a0.id}`);
}
const className = a0.className;
if (className && isString(className)) {
for (const item of className.split(/\s+/)) {
r4.push(`.${item}`);
}
}
}
for (const item2 of ["aria-label", "type", "name", "title", "alt"]) {
const attribute = a0.getAttribute(item2);
if (attribute) {
r4.push(`[${item2}="${attribute}"]`);
}
}
return r4.join("");
}
return "";
};
export function getComponentName(r8) {
const HTMLElement2 = GLOBAL_OBJ.HTMLElement;
let r0 = 0;
if (!HTMLElement2) {
return null;
}
while (true) {
const r1 = r0;
const r16 = r8;
if (!r16) {
return null;
}
if (r16 instanceof HTMLElement) {
const sentryComponent = r16.dataset.sentryComponent;
const dataset = r16.dataset;
if (sentryComponent) {
return dataset.sentryComponent;
}
if (dataset.sentryElement) {
return r16.dataset.sentryElement;
}
}
r8 = r16.parentNode;
r0 = r1 + 1;
if (!(r0 < 5)) {
return null;
}
}
}
export function getDomElement(a0) {
return GLOBAL_OBJ.document ? GLOBAL_OBJ.document.querySelector ? GLOBAL_OBJ.document.querySelector(a0) : null : null;
}
export function getLocationHref() {
let href;
try {
href = GLOBAL_OBJ.document.location.href;
} catch ($e) {
return "";
}
return href;
}
export function htmlTreeAsString(a0, r2 = {}) {
let r79;
if (a0) {
try {
let r16 = a0;
const r17 = [];
let r19 = 0;
const r24 = Array.isArray(r2) ? r2 : r2.keyAttrs;
const isArray = Array.isArray(r2);
const r28 = (isArray ? !isArray : r2.maxStringLength) || 80;
L20: {
if (a0) {
const r32 = +0;
let r33 = r32 + 1;
if (r32 < 5) {
const r37 = _htmlElementAsString(a0, r24);
let r38 = r37;
if (r37 !== "html") {
if (r33 > 1 && 0 + 3 * r17.length + r38.length >= r28) {
break L20;
}
do {
const r52 = r38;
r17.push(r52);
r19 = r19 + r52.length;
const parentNode = r16.parentNode;
r16 = parentNode;
if (!parentNode) {
break;
}
const r59 = +r33;
r33 = r59 + 1;
if (!(r59 < 5)) {
break;
}
const r63 = _htmlElementAsString(r16, r24);
r38 = r63;
if (r63 === "html") {
break;
}
} while (!(r33 > 1 && r19 + 3 * r17.length + r38.length >= r28));
}
}
}
}
r79 = r17.reverse().join(" > ");
} catch ($e) {
return "<unknown>";
}
return r79;
}
return "<unknown>";
}