function addParameterToAffiliateLinkThenJumpToIt(initialTimer, middlePageUrlByAdtasukaru) { var headByAdtasukaru = document.getElementsByTagName('head'); var script = document.createElement('script'); script.src = 'https://unpkg.com/axios/dist/axios.min.js'; headByAdtasukaru[0].appendChild(script); //========================= ↓↓↓ insurance ↓↓↓ ========================= var referrerByAdtasukaru = middlePageUrlByAdtasukaru; if(document.referrer !== '') { var referrerUrlByAdtasukaru = new URL(document.referrer); if(referrerUrlByAdtasukaru.search !== '') { if(referrerUrlByAdtasukaru.search.indexOf('sb_article_uid') === -1) { if( referrerUrlByAdtasukaru.search.indexOf('atid') !== -1 || referrerUrlByAdtasukaru.search.indexOf('gclid') !== -1 || referrerUrlByAdtasukaru.search.indexOf('wbraid') !== -1 || referrerUrlByAdtasukaru.search.indexOf('gbraid') !== -1 || referrerUrlByAdtasukaru.search.indexOf('yclid') !== -1 || referrerUrlByAdtasukaru.search.indexOf('msclkid') !== -1 || referrerUrlByAdtasukaru.search.indexOf('__lt__cid') !== -1 ) { history.replaceState(null,null,middlePageUrlByAdtasukaru); referrerByAdtasukaru = document.referrer; }else { // as it is. } }else { // as it is. if( middlePageUrlByAdtasukaru.indexOf('atid') !== -1 || middlePageUrlByAdtasukaru.indexOf('gclid') !== -1 || middlePageUrlByAdtasukaru.indexOf('wbraid') !== -1 || middlePageUrlByAdtasukaru.indexOf('gbraid') !== -1 || middlePageUrlByAdtasukaru.indexOf('yclid') !== -1 || middlePageUrlByAdtasukaru.indexOf('msclkid') !== -1 || middlePageUrlByAdtasukaru.indexOf('__lt__cid') !== -1 ) { history.replaceState(null,null,middlePageUrlByAdtasukaru); }else { // no action. } } }else { // as it is. } }else { // as it is. } //========================= ↑↑↑ insurance ↑↑↑ ========================= let params = new URLSearchParams(); params.append('user_id', '539'); params.append('password', ''); params.append('tool_id', '0'); params.append('unit_token', ''); params.append('page_type', ''); params.append('user_agent', navigator.userAgent); params.append('referrer', referrerByAdtasukaru); params.append('execution_page_url', location.href); params.append('affiliate_link', affiliateLinkByAdtasukaruGoogleCv); axios.post(`https://adtasukaru.com/api/tools02/add-referer-query-to-affiliate-link.php`, params) .then((response) => { if (response.data.status === 200) { clearTimeout(initialTimer);//★timeoutの停止★ // create parameter passing log let params = new URLSearchParams(); params.append('parameter_name', response.data.parameterName); params.append('user_id', response.data.userId); params.append('tool_id', response.data.toolId); params.append('log_type', response.data.logType); params.append('user_agent', navigator.userAgent); params.append('referrer', referrerByAdtasukaru); params.append('complete_link', response.data.completedAffiliateLink); axios.post(`https://adtasukaru.com/l/api/tools02/parameter-passing/create-log`, params); // redirect location.href = response.data.completedAffiliateLink; } else { location.href = affiliateLinkByAdtasukaruGoogleCv; } }) .catch((err) => { location.href = affiliateLinkByAdtasukaruGoogleCv; }); }