79572639

Date: 2025-04-14 08:07:38
Score: 1.5
Natty:
Report link
document.addEventListener("DOMContentLoaded", function () {
  const links = document.querySelectorAll('.linksblock a');
  links.forEach(link => {
    const href = link.getAttribute('href');
    if (href) {
      if (!href.includes('?=PAT')) {
        // Check if URL already has a query string
        const separator = href.includes('?') ? '&' : '?';
        link.setAttribute('href', href + separator + '=PAT');
      }
    }
  });
});

Just add above java script code to your html.

const links = document.querySelectorAll('.linksblock a');

will get all the elements inside with class linksblock,

links.forEach(link => {}

Above code Loops through each element found

if (href) {

Above code Checks that the href isn't null or empty

if (!href.includes('?=PAT')) {

** Above code Ensures ?=PAT is not already present, this is to avoid duplicating.**

const separator = href.includes('?') ? '&' : '?';
link.setAttribute('href', href + separator + '=PAT');

Above code Updates the link’s href by adding ?=PAT or &=PAT at the end

Let me know if you need further explination to the code? or any other issues if your having?

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: Omprakash S