Skip to content

Commit

Permalink
Fix issue with other links breaking (NEEDS TESTING?)
Browse files Browse the repository at this point in the history
  • Loading branch information
NiceygyLive committed Oct 15, 2024
1 parent 081b255 commit 6707901
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions js/WDR.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,27 @@ document.addEventListener("DOMContentLoaded", function () {

downloadButtons.forEach((button) => {
button.addEventListener("click", function (event) {
event.preventDefault(); // Prevent the default action (navigation)

console.log(this.dataset.redirectUrl);
console.log(this);

const url = new URL(this.dataset.redirectUrl);

// Optionally, log the modified URL
fetch(this.dataset.redirectUrl, { cache: "no-cache" })
.then((response) => response.text())
.then((data) => {
// console.log(data);
})
.catch((error) => {
console.error("Error making the request:", error);
});

// Navigate to the modified URL
window.location.href = url.toString();
if (this.dataset.redirectUrl == null) {
//normal href, ignore
return;
} else {
event.preventDefault(); // Prevent the default action (navigation)

const url = new URL(this.dataset.redirectUrl);

// Optionally, log the modified URL
fetch(this.dataset.redirectUrl, { cache: "no-cache" })
.then((response) => response.text())
.then((data) => {
// console.log(data);
})
.catch((error) => {
console.error("Error making the request:", error);
});

// Navigate to the modified URL
window.location.href = url.toString();
}
});
});
});

0 comments on commit 6707901

Please sign in to comment.