-
Notifications
You must be signed in to change notification settings - Fork 0
/
sc-abtest.min.js
5 lines (5 loc) · 2.16 KB
/
sc-abtest.min.js
1
2
3
4
5
(function(){var a={getCookie:function(a){var b,f,d,e,g;if(document.cookie&&""!==document.cookie){f=document.cookie.split("; ");for(e=0,g=f.length;e<g;e++)if(d=f[e],d.substring(0,a.length+1)===a+"="){b=decodeURIComponent(d.substring(a.length+1));break}}return b}};a.getCookieRemainder=function(){var c;c=a.getCookie("Rp");if(!c)return-1;c=c.substr(c.length-3);return parseInt(c,16)%100};a.doAutoRedirect=function(c){var c=a.urlArray[c],b;b=location.search;location.href=b?c+b+"&l2-id=WB":c+"?l2-id=WB"};
a.replaceContents=function(c,b){a.replaceFlag=!0;var f=a.selectorArray.length;try{a.urlArray[c*f+b]&&function(a,c){var b;if(window.XMLHttpRequest)b=new XMLHttpRequest;else try{b=new ActiveXObject("Microsoft.XMLHTTP")}catch(d){return}b.onreadystatechange=function(){if(4===b.readyState&&200===b.status){var a=document.getElementById(c);if(a&&b.responseText)a.innerHTML=b.responseText}};b.open("GET",a,!1);b.setRequestHeader("X-Requested-With","XMLHttpRequest");b.send()}(a.urlArray[c*f+b],a.selectorArray[b]||
"wb_testarea",!0)}catch(d){a.setProp34("WB_error")}};a.setProp34=function(a){var b=document.createElement("input");b.setAttribute("type","hidden");b.setAttribute("id","scABTest");b.setAttribute("value",a);document.body.appendChild(b)};a.checkPattern=function(c){for(var b=a.targetArray.length,f=a.selectorArray.length,d=0,e=0;d<b;d++)if(0>(a.abTestCheckValue-(a.targetArray[d-1]||0))*(a.abTestCheckValue-a.targetArray[d+1]||100)){if(0<f)for(;e<f;e++)c(d,e);else c(d,d);a.setProp34("WB_testpattern"+(d+
1));break}};a.getDataAttributes=function(c){a.targetArray=[];a.urlArray=[];a.selectorArray=[];var b=function(a,b){var e,g=1;do(e=c.getAttribute(a+g))&&b.push(e),g++;while(e)};b("data-target",a.targetArray);b("data-url",a.urlArray);b("data-selector",a.selectorArray)};a.getABMethod=function(){var c;c=document.getElementsByTagName("script");c=c[c.length-1];a.dataReplace=c.getAttribute("data-replace");window.abTestCheckValue=a.abTestCheckValue=a.getCookieRemainder();a.getDataAttributes(c);a.targetArray[0]&&
a.urlArray[0]&&-1<a.abTestCheckValue&&(a.dataReplace?(a.checkPattern(a.replaceContents),a.replaceFlag||a.setProp34("WB_default")):a.checkPattern(a.doAutoRedirect))};a.getABMethod()})();