added discord functionality to extension and polished some of downloader process.
This commit is contained in:
@@ -86,13 +86,17 @@ function createPlatformCard(key, platform, status) {
|
||||
card.className = 'platform-card';
|
||||
card.dataset.platform = key;
|
||||
|
||||
const isDisabled = platform.authType === 'token';
|
||||
if (isDisabled) {
|
||||
// Discord is clickable if we have a token captured
|
||||
// Other token-based platforms are disabled
|
||||
const isDisabled = platform.authType === 'token' && key !== 'discord';
|
||||
const isDiscordWithoutToken = key === 'discord' && !status.hasToken;
|
||||
|
||||
if (isDisabled || isDiscordWithoutToken) {
|
||||
card.classList.add('disabled');
|
||||
}
|
||||
|
||||
const statusText = getStatusText(status, platform);
|
||||
const statusClass = getStatusClass(status, platform);
|
||||
const statusText = getStatusText(status, platform, key);
|
||||
const statusClass = getStatusClass(status, platform, key);
|
||||
|
||||
card.innerHTML = `
|
||||
<div class="platform-icon" style="background-color: ${platform.color}">
|
||||
@@ -109,7 +113,7 @@ function createPlatformCard(key, platform, status) {
|
||||
</span>
|
||||
`;
|
||||
|
||||
if (!isDisabled) {
|
||||
if (!isDisabled && !isDiscordWithoutToken) {
|
||||
card.addEventListener('click', () => exportPlatformCookies(key, card));
|
||||
}
|
||||
|
||||
@@ -120,9 +124,18 @@ function createPlatformCard(key, platform, status) {
|
||||
* Get status text for display
|
||||
* @param {object} status - Platform status
|
||||
* @param {object} platform - Platform definition
|
||||
* @param {string} key - Platform key
|
||||
* @returns {string}
|
||||
*/
|
||||
function getStatusText(status, platform) {
|
||||
function getStatusText(status, platform, key) {
|
||||
// Special handling for Discord token-based auth
|
||||
if (key === 'discord') {
|
||||
if (status.hasToken) {
|
||||
return 'Token captured - ready to export';
|
||||
}
|
||||
return 'Open Discord in browser to capture token';
|
||||
}
|
||||
|
||||
if (platform.authType === 'token') {
|
||||
return 'Manual token entry required';
|
||||
}
|
||||
@@ -139,9 +152,15 @@ function getStatusText(status, platform) {
|
||||
* Get status CSS class
|
||||
* @param {object} status - Platform status
|
||||
* @param {object} platform - Platform definition
|
||||
* @param {string} key - Platform key
|
||||
* @returns {string}
|
||||
*/
|
||||
function getStatusClass(status, platform) {
|
||||
function getStatusClass(status, platform, key) {
|
||||
// Special handling for Discord
|
||||
if (key === 'discord') {
|
||||
return status.hasToken ? 'ready' : 'no-cookies';
|
||||
}
|
||||
|
||||
if (platform.authType === 'token') {
|
||||
return 'no-cookies';
|
||||
}
|
||||
@@ -172,7 +191,11 @@ async function exportPlatformCookies(platformKey, cardElement) {
|
||||
if (result.error) {
|
||||
showError(result.error);
|
||||
} else {
|
||||
showSuccess(`${PLATFORMS[platformKey].name}: ${result.cookieCount} cookies exported!`);
|
||||
// Handle different response types (cookies vs token)
|
||||
const successMsg = result.cookieCount !== undefined
|
||||
? `${PLATFORMS[platformKey].name}: ${result.cookieCount} cookies exported!`
|
||||
: `${PLATFORMS[platformKey].name}: Token exported successfully!`;
|
||||
showSuccess(successMsg);
|
||||
// Refresh status
|
||||
await loadPlatformStatus();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user