From de99ec1ab3d53644114216cde54565be399622d2 Mon Sep 17 00:00:00 2001 From: godnight10061 Date: Tue, 27 Jan 2026 16:00:00 +0800 Subject: [PATCH 1/3] feat: expand redemption assist default whitelist Refs: issue 281 --- services/userPreferences.ts | 2 +- tests/services/redemptionAssist.test.ts | 51 +++++++++++++++++++++++++ tests/services/userPreferences.test.ts | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/services/userPreferences.ts b/services/userPreferences.ts index e79ac5c7dc..d615a1b358 100644 --- a/services/userPreferences.ts +++ b/services/userPreferences.ts @@ -359,7 +359,7 @@ export const DEFAULT_PREFERENCES: UserPreferences = { relaxedCodeValidation: true, urlWhitelist: { enabled: true, - patterns: ["cdk.linux.do"], + patterns: ["cdk.linux.do", "cdk.hybgzs.com", "qd.x666.me"], includeAccountSiteUrls: true, includeCheckInAndRedeemUrls: true, }, diff --git a/tests/services/redemptionAssist.test.ts b/tests/services/redemptionAssist.test.ts index 0a33b8805b..2aa2b9156b 100644 --- a/tests/services/redemptionAssist.test.ts +++ b/tests/services/redemptionAssist.test.ts @@ -7,6 +7,13 @@ vi.mock("i18next", () => ({ t: (key: string) => key, })) +vi.mock("~/services/accountStorage", () => ({ + accountStorage: { + getEnabledAccounts: vi.fn().mockResolvedValue([]), + convertToDisplayData: vi.fn(() => []), + }, +})) + vi.mock("~/services/userPreferences", async (importOriginal) => { const actual = await importOriginal() @@ -64,4 +71,48 @@ describe("redemptionAssist shouldPrompt batch filtering", () => { promptableCodes: [validHex], }) }) + + it("allows prompt on common redemption sites by default", async () => { + vi.resetModules() + const { userPreferences } = await import("~/services/userPreferences") + const getPreferencesMock = vi.mocked(userPreferences.getPreferences) + + getPreferencesMock.mockResolvedValue(DEFAULT_PREFERENCES) + + const { handleRedemptionAssistMessage } = await import( + "~/services/redemptionAssist" + ) + + const validHex = "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" + const sendResponse = vi.fn() + + await handleRedemptionAssistMessage( + { + action: RuntimeActionIds.RedemptionAssistShouldPrompt, + url: "https://cdk.hybgzs.com/entertainment/wheel", + codes: [validHex], + }, + { tab: { id: 99 } } as any, + sendResponse, + ) + + await handleRedemptionAssistMessage( + { + action: RuntimeActionIds.RedemptionAssistShouldPrompt, + url: "https://qd.x666.me", + codes: [validHex], + }, + { tab: { id: 99 } } as any, + sendResponse, + ) + + expect(sendResponse).toHaveBeenNthCalledWith(1, { + success: true, + promptableCodes: [validHex], + }) + expect(sendResponse).toHaveBeenNthCalledWith(2, { + success: true, + promptableCodes: [validHex], + }) + }) }) diff --git a/tests/services/userPreferences.test.ts b/tests/services/userPreferences.test.ts index 12ddc3d1d2..69a9a3d599 100644 --- a/tests/services/userPreferences.test.ts +++ b/tests/services/userPreferences.test.ts @@ -30,7 +30,7 @@ describe("userPreferences", () => { ).toBe(true) expect( DEFAULT_PREFERENCES.redemptionAssist?.urlWhitelist.patterns, - ).toEqual(["cdk.linux.do"]) + ).toEqual(["cdk.linux.do", "cdk.hybgzs.com", "qd.x666.me"]) expect(DEFAULT_PREFERENCES.tempWindowFallbackReminder?.dismissed).toBe( false, ) From 14eb9326ad54eba2a063f2f5bfe80857fd607a25 Mon Sep 17 00:00:00 2001 From: godnight10061 Date: Tue, 27 Jan 2026 16:33:04 +0800 Subject: [PATCH 2/3] test: dedupe redemption assist whitelist cases --- tests/services/redemptionAssist.test.ts | 48 +++++++++++-------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/tests/services/redemptionAssist.test.ts b/tests/services/redemptionAssist.test.ts index 2aa2b9156b..291f4f89c1 100644 --- a/tests/services/redemptionAssist.test.ts +++ b/tests/services/redemptionAssist.test.ts @@ -84,35 +84,29 @@ describe("redemptionAssist shouldPrompt batch filtering", () => { ) const validHex = "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" - const sendResponse = vi.fn() - await handleRedemptionAssistMessage( - { - action: RuntimeActionIds.RedemptionAssistShouldPrompt, - url: "https://cdk.hybgzs.com/entertainment/wheel", - codes: [validHex], - }, - { tab: { id: 99 } } as any, - sendResponse, - ) + const testUrls = [ + "https://cdk.hybgzs.com/entertainment/wheel", + "https://qd.x666.me", + ] - await handleRedemptionAssistMessage( - { - action: RuntimeActionIds.RedemptionAssistShouldPrompt, - url: "https://qd.x666.me", - codes: [validHex], - }, - { tab: { id: 99 } } as any, - sendResponse, - ) + for (const url of testUrls) { + const sendResponse = vi.fn() - expect(sendResponse).toHaveBeenNthCalledWith(1, { - success: true, - promptableCodes: [validHex], - }) - expect(sendResponse).toHaveBeenNthCalledWith(2, { - success: true, - promptableCodes: [validHex], - }) + await handleRedemptionAssistMessage( + { + action: RuntimeActionIds.RedemptionAssistShouldPrompt, + url, + codes: [validHex], + }, + { tab: { id: 99 } } as any, + sendResponse, + ) + + expect(sendResponse).toHaveBeenCalledWith({ + success: true, + promptableCodes: [validHex], + }) + } }) }) From 0b6d568db504ff9960deb1c156764f2e0c0ca0bb Mon Sep 17 00:00:00 2001 From: godnight10061 Date: Tue, 27 Jan 2026 16:42:58 +0800 Subject: [PATCH 3/3] fix: escape default redemption whitelist patterns --- services/userPreferences.ts | 2 +- tests/services/userPreferences.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/userPreferences.ts b/services/userPreferences.ts index d615a1b358..8b23a8f467 100644 --- a/services/userPreferences.ts +++ b/services/userPreferences.ts @@ -359,7 +359,7 @@ export const DEFAULT_PREFERENCES: UserPreferences = { relaxedCodeValidation: true, urlWhitelist: { enabled: true, - patterns: ["cdk.linux.do", "cdk.hybgzs.com", "qd.x666.me"], + patterns: ["cdk\\.linux\\.do", "cdk\\.hybgzs\\.com", "qd\\.x666\\.me"], includeAccountSiteUrls: true, includeCheckInAndRedeemUrls: true, }, diff --git a/tests/services/userPreferences.test.ts b/tests/services/userPreferences.test.ts index 69a9a3d599..558ee4712b 100644 --- a/tests/services/userPreferences.test.ts +++ b/tests/services/userPreferences.test.ts @@ -30,7 +30,7 @@ describe("userPreferences", () => { ).toBe(true) expect( DEFAULT_PREFERENCES.redemptionAssist?.urlWhitelist.patterns, - ).toEqual(["cdk.linux.do", "cdk.hybgzs.com", "qd.x666.me"]) + ).toEqual(["cdk\\.linux\\.do", "cdk\\.hybgzs\\.com", "qd\\.x666\\.me"]) expect(DEFAULT_PREFERENCES.tempWindowFallbackReminder?.dismissed).toBe( false, )