I'm using vitalsource as a redirect source but the issue is that it cant be customized, and can only redirect to a main website. the redirect URL is "https://bc.vitalsource.com/books/9781119493440R150?bc_token=f9984a30-8eae-013c-8d06-0e40f9c629f8&relaunch_vbid=9781119493440R150&course_dash_relaunch=true&dash_student_pay=true", where "9781119493440" is the code I am trying to extract. Right now, it redirects me to a website I am hosting on github at www.bahaa-aea.github.com/aafaq, but the target https://gust.aafaqeducation.com/ (the numbers i typed)
The number in the redirect link does change based on product, and I would like to know if theres any way to extract it before it redirects me to the github link so I can run custom code to input itinto the website I want.
When It redirects me, the console simply says "ISBN not found in the URL." which is an error code i programmed into it, I think its just trying to read the url that it sends me to rather than the redirect link.
Here is my current JS code:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ISBN Redirect</title>
</head>
<body>
<script>
// Get the URL of the previous page
var referrerUrl = document.referrer;
// Extract ISBN from the previous page URL
var isbnMatch = referrerUrl.match(/books\/(\d+)/);
if (isbnMatch && isbnMatch[1]) {
var isbn = isbnMatch[1];
// Construct the new redirected link
var redirectedLink = "https://gust.aafaqeducation.com/" + isbn;
// Redirect to the new link
window.location.href = redirectedLink;
} else {
console.error("ISBN not found in the previous page URL.");
}
</script>
</body>
</html>```