Created
August 20, 2024 14:40
-
-
Save icantrank/e28943d23d752e0c4453c40777d89ea2 to your computer and use it in GitHub Desktop.
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
<script> | |
(function () { | |
// return false if the query string does not contain a camp parameter | |
if (window.location.search.indexOf('camp=') === -1) return | |
// get the camp parameter value | |
let camp = window.location.search.split('camp=')[1].split('&')[0] | |
// get all links containing get.verisure | |
let links = document.querySelectorAll('a[href*="get.verisure"]') | |
// loop through all links | |
Array.from(links).forEach(link => { | |
// get the href value | |
let href = link.getAttribute('href') | |
// remove the old camp parameter from the href value | |
href = href.replace(/[?&]camp=[^&]*/, '') | |
// add the camp parameter to the href value if it's not already present | |
if (!href.includes('?')) href += `?camp=${camp}` | |
else if (!href.includes('camp=')) href += `&camp=${camp}` | |
// set the new href value | |
link.setAttribute('href', href) | |
}) | |
})() | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment