Skip to content

Instantly share code, notes, and snippets.

@ZeldOcarina
Created January 15, 2021 22:23
Show Gist options
  • Save ZeldOcarina/5de2ba6d446767ef9a89fc1fbf3c3226 to your computer and use it in GitHub Desktop.
Save ZeldOcarina/5de2ba6d446767ef9a89fc1fbf3c3226 to your computer and use it in GitHub Desktop.
Sales Jet Affiliate Codes
function queryOrganizer(queries) {
return queries
.replace("?", "")
.split("&")
.reduce(function (acc, query) {
return [...acc, { [query.split("=")[0]]: query.split("=")[1] }];
}, []);
}
queries = queryOrganizer(window.location.search);
(function () {
for (let query of queries) {
if (!query.affCode) return;
div = document.createElement("div");
div.textContent = `Your Promo Code ${query.affCode.toUpperCase()} has been applied!`;
div.classList.add("affiliate-code-alert");
document.body.insertBefore(div, document.body.firstChild);
const img = document.querySelector(
'[data-element-name="special-image"] > img'
);
img.src = query.affCode.endsWith("60")
? "https://cdn.salesjet.io/757/images/0929ecd0-7515-4f5d-8fbf-7ef813c84281.png"
: "https://cdn.salesjet.io/757/images/5a83b088-dd41-4092-9250-0281c62ae695.png?d=w340";
img.style.width = "340px";
img.style.height = "auto";
const discountPercentage = document.getElementById(
"discount-percentage"
);
discountPercentage.textContent = query.affCode.endsWith("60")
? "60"
: "50";
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment