diff --git a/src/background.ts b/src/background.ts index 9d5d10eb..dfe855d6 100644 --- a/src/background.ts +++ b/src/background.ts @@ -11,6 +11,7 @@ import { closeWindow as closeSettings } from './main/SettingsWindow' import { logger } from './main/logger' import { checkForUpdates } from './main/updates' import os from 'os' +import { setupCfProtection } from './main/cf-protection' import { createOverlayWindow } from './main/overlay-window' import { setupAltVisibility } from './main/alt-visibility' import { setupBuiltinBrowser } from './main/builtin-browser' @@ -58,6 +59,7 @@ app.on('ready', async () => { setTimeout( async () => { await createOverlayWindow() + setupCfProtection() setupShortcuts() setupAltVisibility() }, diff --git a/src/main/cf-protection.ts b/src/main/cf-protection.ts new file mode 100644 index 00000000..06c5dc1f --- /dev/null +++ b/src/main/cf-protection.ts @@ -0,0 +1,23 @@ +import { overlayWindow } from './overlay-window' + +export function setupCfProtection () { + overlayWindow!.webContents.session.webRequest.onHeadersReceived({ + urls: ['https://*.pathofexile.com/*'] + }, (details, next) => { + if (details.responseHeaders?.['set-cookie']) { + const cookies = details.responseHeaders['set-cookie'] + const cfduid = cookies.find(c => c.startsWith('__cfduid')) + + if (cfduid) { + // console.log(cfduid) + // @TODO will break with next Chromium update? + details.responseHeaders['set-cookie'] = [ + ...cookies.filter(c => !c.startsWith('__cfduid')), + cfduid.split(';').filter(_ => _.trim() !== 'SameSite=Lax').join(';') + ] + } + } + + next({ responseHeaders: details.responseHeaders }) + }) +} diff --git a/src/web/price-check/AppBootstrap.vue b/src/web/price-check/AppBootstrap.vue index c4d9f0ec..ce8ce781 100644 --- a/src/web/price-check/AppBootstrap.vue +++ b/src/web/price-check/AppBootstrap.vue @@ -17,8 +17,9 @@
Failed to load leagues +
-
Error: {{ leaguesService.loadingError }}
+
Verify that the realm is not under maintenance and pathofexile.com is loading.
@@ -40,6 +41,7 @@ export default { this.updateInfo = updateInfo }) }, + inject: ['wm', 'widget'], data () { return { updateInfo: null @@ -54,6 +56,9 @@ export default { if (Leagues.isLoaded) { Prices.load() } + }, + openCaptcha () { + this.wm.showBrowser(this.widget.config.wmId, 'https://api.pathofexile.com/leagues?type=main&realm=pc&compact=1') } } }