(function(){ var config=JSON.parse('{"rules":[{"default":true,"target":"https:\/\/www.dailybreak.co\/147224"},{"urlPart":"\/de","target":"https:\/\/www.dailybreak.co\/de\/152893"},{"urlPart":"\/es","target":"https:\/\/www.dailybreak.co\/es\/163337"},{"urlPart":"\/ja","target":"https:\/\/www.dailybreak.co\/ja\/endgallery"},{"urlPart":"\/nl","target":"https:\/\/www.dailybreak.co\/nl\/endgallery"},{"urlPart":"\/pt-br","target":"https:\/\/www.dailybreak.co\/pt-br\/endgallery"},{"urlPart":"\/pl","target":"https:\/\/www.dailybreak.co\/pl\/endgallery"},{"urlPart":"\/en","target":"https:\/\/www.dailybreak.co\/en\/endgallery"},{"urlPart":"\/it","target":"https:\/\/www.dailybreak.co\/it\/endgallery"},{"locales":"fr","cookieRegex":{"utm_sc":"tb|tbr|aff_\\\\d+_tb|af\\\\d+tb|ad\\\\d+tb"},"target":"https:\/\/www.dailybreak.co\/endgallery"}],"site":"dailybreak.co"}'); var cget=function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return false; } var locale=function(){ var l="fr"; var lMatch=location.href.match(new RegExp(config.site+"/(\\w{2}|\\w{2}-\\w{2})[\\?$]")); if(lMatch!==null){ l=lMatch[1]; } return l; } var post_id=function(url){ if(url===undefined){ return false; } var id=url.match(/https*:\/\/.*?\/(\d+)/); if(id!==null && id[1]!==undefined){ return id[1]; } return false; }; var debug_lpr=function(obj){ if(localStorage.debug_lpr===undefined){ return; } console.log('[DEBUG LPR]',obj); } last_page_redirections_dest=false; /*define dest*/ for (var i = 0; i < config.rules.length; i++) { var rule=config.rules[i]; var valid=true; if(rule.urlPart && window.location.href.indexOf(rule.urlPart)===-1){ valid=false; } if(rule.urlRegex && window.location.href.match(rule.urlRegex)===null){ valid=false; } if(rule.cookieRegex){ for(var cName in rule.cookieRegex){ var cRegex=rule.cookieRegex[cName]; var cVal=cget(cName); if(cVal===false || cVal.match(new RegExp(cRegex))===null){ valid=false; } } } if(rule.locales){ if(rule.locales.indexOf(locale())===-1){ valid=false; } } if(valid){ last_page_redirections_dest=rule.target; } } if(!last_page_redirections_dest){ return; } var destination=last_page_redirections_dest; var $action=document.querySelector(".g1-pagination-item-next .g1-arrow-disabled"); debug_lpr(destination); debug_lpr($action); debug_lpr(locale()); if($action===null){ return; } var nextPostUrl=$action.querySelector("a"); if(nextPostUrl!==null){ nextPostUrl=nextPostUrl.getAttribute("href"); }else{ nextPostUrl=undefined; } var ovveride=post_id(location.href)!==post_id(nextPostUrl); if(!ovveride){ return; } $action.className=$action.className.replace("g1-arrow-disabled",""); $action.style.cursor="pointer"; $action.addEventListener('click',function(e){ e.preventDefault(); window.location.href=destination; window.dataLayer = window.dataLayer || []; window.dataLayer.push({'event': 'lastPage'}); }); })();