As an example, I have this code that is able to add the title of a page as a parameter to a link that is identified as an ID. I would like to be able to do the same for the language of the page. Thanks for your help!
<script>
const linkIds = [
'Your_link_id'
];
linkIds.forEach(id => {
const interval = setInterval(() => {
const link = document.querySelector('#' + id);
if (link) {
clearInterval(interval);
const href = link.getAttribute('href');
const pageTitle =
document
.title
.replace(/\s+/g, '_')
.replace(/&/g, '')
.toLowerCase()
const newHref = `${href}?your_parameter_name=${pageTitle}`;
link.setAttribute('href', newHref);
}
}, 20);
});
</script>