diff options
author | Ajay <[email protected]> | 2024-09-08 01:20:25 -0400 |
---|---|---|
committer | Ajay <[email protected]> | 2024-09-08 01:20:25 -0400 |
commit | 12e8c7aad8392039b641c0eb414cd22e6b80ecb7 (patch) | |
tree | 2079562548e820de18cc5db85f827b7e510205a8 /src/options.ts | |
parent | 2a2896786cba795aa2f5b83b8cfcd75842fc2c02 (diff) | |
download | SponsorBlock-12e8c7aad8392039b641c0eb414cd22e6b80ecb7.tar.gz SponsorBlock-12e8c7aad8392039b641c0eb414cd22e6b80ecb7.zip |
Add way to copy debug logs from popup
Diffstat (limited to 'src/options.ts')
-rw-r--r-- | src/options.ts | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/options.ts b/src/options.ts index e983498f..f6ba2663 100644 --- a/src/options.ts +++ b/src/options.ts @@ -1,7 +1,7 @@ import * as React from "react"; import { createRoot } from 'react-dom/client'; -import Config from "./config"; +import Config, { generateDebugDetails } from "./config"; import * as CompileConfig from "../config.json"; import * as invidiousList from "../ci/invidiouslist.json"; @@ -698,32 +698,14 @@ function validateServerAddress(input: string): string { } function copyDebugOutputToClipboard() { - // Build output debug information object - const output = { - debug: { - userAgent: navigator.userAgent, - platform: navigator.platform, - language: navigator.language, - extensionVersion: chrome.runtime.getManifest().version - }, - config: JSON.parse(JSON.stringify(Config.cachedSyncConfig)) // Deep clone config object - }; - - // Sanitise sensitive user config values - delete output.config.userID; - output.config.serverAddress = (output.config.serverAddress === CompileConfig.serverAddress) - ? "Default server address" : "Custom server address"; - output.config.invidiousInstances = output.config.invidiousInstances.length; - output.config.whitelistedChannels = output.config.whitelistedChannels.length; - // Copy object to clipboard - navigator.clipboard.writeText(JSON.stringify(output, null, 4)) - .then(() => { + navigator.clipboard.writeText(generateDebugDetails()) + .then(() => { alert(chrome.i18n.getMessage("copyDebugInformationComplete")); - }) - .catch(() => { + }) + .catch(() => { alert(chrome.i18n.getMessage("copyDebugInformationFailed")); - }); + }); } function isIncognitoAllowed(): Promise<boolean> { |