Skip to content

Instantly share code, notes, and snippets.

@abhisekp
Last active December 1, 2021 02:28
Show Gist options
  • Save abhisekp/1b1cbd166a343f5dc46a78d9b740e391 to your computer and use it in GitHub Desktop.
Save abhisekp/1b1cbd166a343f5dc46a78d9b740e391 to your computer and use it in GitHub Desktop.
Cashkaro
/* eslint-disable no-unused-expressions */
// !function cashkaro007() {
if (String(window.location).includes('.amazon.')) {
var isProductURL = String(window.location).includes('product');
console.log({ isProductURL });
var productURL = isProductURL ? String(window.location) : sessionStorage.getItem('productURL');
if (isProductURL) {
sessionStorage.setItem('productURL', productURL);
isProductURL = !!productURL;
} else {
console.log('Redirecting', productURL);
setTimeout(() => {
window.location = productURL;
}, 2000);
}
var ascsubtag = (new URL(productURL).searchParams.get('ascsubtag')) || sessionStorage.getItem('ascsubtag');
if (ascsubtag) {
sessionStorage.setItem('ascsubtag', ascsubtag);
var newURLSuffix = (String(productURL).indexOf('?') !== -1 ? '&' : '?') + 'tag=cashkacom-21&ascsubtag='+ascsubtag;
console.log('Contains Fragment? ', String(productURL).indexOf('?') !== -1);
console.log('New URL Suffix:', newURLSuffix);
console.log('Redirecting', window.location + newURLSuffix)
setTimeout(() => {
window.location += newURLSuffix;
}, 5000);
} else {
// == Amazon Redirect via Cashkaro == //
console.log('Redirecting', 'https://tracking.cashkaro.com/visitretailer/1999?id=1467251');
setTimeout(() => {
window.location = 'https://tracking.cashkaro.com/visitretailer/1999?id=1467251'
}, 5000);
}
}
// }();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment