Created
March 30, 2021 19:00
-
-
Save dasl-/7228c997e5afe0aba62ef826cbb1c6e8 to your computer and use it in GitHub Desktop.
intercept xhr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeId(length) { | |
var result = ''; | |
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | |
var charactersLength = characters.length; | |
for ( var i = 0; i < length; i++ ) { | |
result += characters.charAt(Math.floor(Math.random() * charactersLength)); | |
} | |
return result; | |
} | |
function logURL(requestDetails) { | |
console.log("Redirecting: " + requestDetails.url); | |
var parts; | |
if (requestDetails.url.startsWith('https://www.riteaid.com/services/ext/v2/vaccine/checkSlots')) { | |
parts = requestDetails.url.split('='); | |
var storeNumber = parts[parts.length - 1]; | |
var id = makeId(20); | |
return { | |
redirectUrl: 'https://www.riteaid.com/services/ext/v2/vaccine/checkSlots?foo=' + id + '&storeNumber=' + storeNumber | |
}; | |
} else { | |
parts = requestDetails.url.split('?'); | |
var new_url = parts[0] + '?foo=' + makeId(20) + '&' + parts[1]; | |
return { | |
redirectUrl: new_url | |
}; | |
} | |
} | |
browser.webRequest.onBeforeRequest.addListener( | |
logURL, | |
{urls: [ | |
"https://www.riteaid.com/services/ext/v2/vaccine/checkSlots?storeNumber=*", | |
'https://www.riteaid.com/content/riteaid-web/en.ragetavailableappointmentslots.json?storeNumber=*' | |
]}, | |
["blocking"] | |
); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"description": "Demonstrating webRequests", | |
"manifest_version": 2, | |
"name": "webRequest-demo", | |
"version": "1.0", | |
"permissions": [ | |
"webRequest", | |
"<all_urls>", | |
"webRequestBlocking" | |
], | |
"background": { | |
"scripts": ["background.js"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment