Skip to content

第40期-屏蔽特定国家或地区访问店铺

{% if request.design_mode == false %}
<script>
rbBlockCountries = function($){
$('body').hide();
$.get('//www.cloudflare.com/cdn-cgi/trace').done(function(data) {
var country_code = data.replace(/(\r\n|\n|\r)/gm,"").split('loc=');
country_code = country_code[1].split('tls=');
country_code = country_code[0];
if( country_code == 'CN' || country_code == 'HK' ){
alert('You are not allowed to access this store!');
window.location.replace("https://lfei.life/pages/login-page");
}else{
$('body').show();
}
});
}
var rainbowShopifyScript = document.createElement('script');
rainbowShopifyScript.setAttribute("src", "https://cdn.shopify.com/s/files/1/0445/1699/9329/files/jquery.min.js");
rainbowShopifyScript.setAttribute("type", "text/javascript");
if (rainbowShopifyScript.readyState) {
rainbowShopifyScript.onreadystatechange = function () {
if (this.readyState == 'loaded' || this.readyState == 'complete') rbBlockCountries(jQuery.noConflict(true));
};
} else {
rainbowShopifyScript.onload = function () {rbBlockCountries(jQuery.noConflict(true));};
}
var d = document.getElementsByTagName("head")[0] || document.documentElement;
d.appendChild(rainbowShopifyScript);
</script>
{% endif %}
上一篇文稿 第6期-Shopify 店铺屏蔽中文浏览器