Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function() {
- try {
- function getData(sourceUrl, lsKey) {
- var xhr = new XMLHttpRequest();
- xhr.withCredentials = true;
- xhr.addEventListener("readystatechange", function() {
- if (this.readyState === 4) {
- var json = JSON.parse(this.responseText);
- if (json && json.products && json.products.length > 0) {
- window.localStorage.setItem(lsKey, JSON.stringify(json));
- }
- }
- });
- xhr.open("GET", sourceUrl);
- xhr.send();
- }
- var domain = location.hostname;
- var dataSourceUrl = '';
- var lsKey = '';
- switch (domain) {
- case 'sodastream.com':
- dataSourceUrl = 'https://feeds.datafeedwatch.com/61736/81fd097f63e9bf0edef631a72f6ca2f3a2872709.json';
- lsKey = 'upsell_Vertical_Carousel';
- getData(dataSourceUrl, lsKey);
- break;
- case 'sodastream.ca':
- dataSourceUrl = 'https://feeds.datafeedwatch.com/64282/0d1f540754be235a47254aa8a146099f77e67a21.json';
- lsKey = 'upsell_Vertical_Carousel';
- getData(dataSourceUrl, lsKey);
- break;
- case 'sodastream.fr':
- dataSourceUrl = 'https://feeds.datafeedwatch.com/66229/9e5f8b240f61a3155d6bbc3494ee9e7139135578.json';
- lsKey = 'upsell_Vertical_Carousel';
- getData(dataSourceUrl, lsKey);
- break;
- case 'sodastream.se':
- dataSourceUrl = 'https://feeds.datafeedwatch.com/64397/ef779f79ebf13838f3e7f3f2ac33c9e4cf4589c8.json';
- lsKey = 'upsell_Vertical_Carousel';
- getData(dataSourceUrl, lsKey);
- break;
- case 'sodastream.de':
- dataSourceUrl = 'https://feeds.datafeedwatch.com/64183/52bb0f7cc9cb9bbc6e9589624d3e5fb5c5465ed7.json';
- lsKey = 'upsell_Vertical_Carousel';
- getData(dataSourceUrl, lsKey);
- break;
- default:
- return;
- }
- } catch(requestError) {console.log(requestError)}
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement