Skip to content

Commit

Permalink
Fix destinations bug
Browse files Browse the repository at this point in the history
  • Loading branch information
vloss3 committed Sep 29, 2024
1 parent 8f20fb6 commit 433df57
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
34 changes: 26 additions & 8 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h1 class="is-size-5">Wizz AYCF Route Finder</h1>
</div>
<p class="is-size-6 mt-3"><b>Disclaimer:</b> 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.</p>
<p class="is-size-6 mt-3">Please use responsibly and at your own risk. Doing too many searches in a short period of time will result in temporary rate limiting.</p>
<p class="is-size-6 mt-3">Version 1.1</p>
<p class="is-size-6 mt-3">Version 1.1.2</p>
</section>
<script src="popup.js"></script>
</body>
Expand Down

0 comments on commit 433df57

Please sign in to comment.