diff options
Diffstat (limited to 'src/popup.ts')
-rw-r--r-- | src/popup.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/popup.ts b/src/popup.ts index 27984cee..b20723a2 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -1,4 +1,4 @@ -import Config from "./config"; +import Config, { generateDebugDetails } from "./config"; import Utils from "./utils"; import { @@ -12,6 +12,7 @@ import { GetChannelIDResponse, IsChannelWhitelistedResponse, IsInfoFoundMessageResponse, + LogResponse, Message, MessageResponse, PopupMessage, @@ -184,7 +185,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> { "exportSegmentsButton", "importSegmentsMenu", "importSegmentsText", - "importSegmentsSubmit" + "importSegmentsSubmit", + "debugLogs" ].forEach(id => PageElements[id] = document.getElementById(id)); @@ -255,6 +257,7 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> { PageElements.helpButton.addEventListener("click", openHelp); PageElements.refreshSegmentsButton.addEventListener("click", refreshSegments); PageElements.sbPopupIconCopyUserID.addEventListener("click", async () => copyToClipboard(await getHash(Config.config.userID))); + PageElements.debugLogs.addEventListener("click", copyDebgLogs); // Forward click events if (window !== window.top) { @@ -1143,6 +1146,12 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> { } } + function copyDebgLogs() { + sendTabMessage({ message: "getLogs" }, (logs: LogResponse) => { + copyToClipboard(`${generateDebugDetails()}\n\nWarn:\n${logs.warn.join("\n")}\n\nDebug:\n${logs.debug.join("\n")}`); + }); + } + function onMessage(msg: PopupMessage) { switch (msg.message) { case "time": |