Last active
December 1, 2021 02:28
-
-
Save abhisekp/1b1cbd166a343f5dc46a78d9b740e391 to your computer and use it in GitHub Desktop.
Cashkaro
This file contains 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
/* 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