diff --git a/content.js b/content.js index 396e9a4..07f6f1e 100644 --- a/content.js +++ b/content.js @@ -2,11 +2,22 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { if (request.action === "getDestinations") { setTimeout(() => { const routePattern = /"routes":\[(.*?)\].*?"isOneWayFlightsOnly"/gms; + const bodyPattern = /window\.CVO\.routes\s*=\s*(\[.*?\]);/s; const pageContent = document.head.innerHTML; - const match = pageContent.match(routePattern); - if (match && match[0]) { + const bodyContent = document.body.innerHTML; + + let routesJson; + let headMatch = pageContent.match(routePattern); + let bodyMatch = bodyContent.match(bodyPattern); + + if (headMatch && headMatch[0]) { + routesJson = `{"routes":${headMatch[0].split('"routes":')[1].split(',"isOneWayFlightsOnly"')[0]}}`; + } else if (bodyMatch && bodyMatch[1]) { + routesJson = `{"routes":${bodyMatch[1]}}`; + } + + if (routesJson) { try { - const routesJson = `{"routes":${match[0].split('"routes":')[1].split(',"isOneWayFlightsOnly"')[0]}}`; const routesData = JSON.parse(routesJson); const originAirport = request.origin; @@ -36,14 +47,21 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { if (request.action === "getDynamicUrl") { setTimeout(() => { const pageContent = document.head.innerHTML; - const match = pageContent.match(/"searchFlight":"https:\/\/multipass\.wizzair\.com[^"]+\/([^"]+)"/); - if (match && match[1]) { - const uuid = match[1]; + const bodyContent = document.body.innerHTML; + + const headMatch = pageContent.match(/"searchFlight":"https:\/\/multipass\.wizzair\.com[^"]+\/([^"]+)"/); + const bodyMatch = bodyContent.match(/window\.CVO\.flightSearchUrlJson\s*=\s*"(https:\/\/multipass\.wizzair\.com[^"]+)"/); + + if (headMatch && headMatch[1]) { + const uuid = headMatch[1]; const dynamicUrl = `https://multipass.wizzair.com/w6/subscriptions/json/availability/${uuid}`; sendResponse({dynamicUrl: dynamicUrl}); + } else if (bodyMatch && bodyMatch[1]) { + const dynamicUrl = bodyMatch[1]; + sendResponse({dynamicUrl: dynamicUrl}); } else { - console.log('Dynamic ID not found in page content'); - sendResponse({error: "Dynamic ID not found"}); + console.log('Dynamic URL not found in page content'); + sendResponse({error: "Dynamic URL not found"}); } }, 1000); return true; diff --git a/popup.html b/popup.html index e697cbb..582b1ee 100644 --- a/popup.html +++ b/popup.html @@ -50,7 +50,7 @@

Wizz AYCF Route Finder

Disclaimer: This extension is not affiliated with Wizz Air or its partners in any way. It is a personal project to help Multipass users like me find available routes.

Please use responsibly and at your own risk. Doing too many searches in a short period of time will result in temporary rate limiting.

-

Version 1.1

+

Version 1.1.2