Stop mobile network proxy from injecting JavaScript

后端 未结 13 949
鱼传尺愫
鱼传尺愫 2020-11-29 18:50

I am using a mobile network based internet connection and the source code is being rewritten when they present the site to the end user.

In the localhost my website

相关标签:
13条回答
  • 2020-11-29 19:50

    Ok nothing working to me. Then i replace image url every second because when my DOM updates, the problem is here again. Other solution is only use background style auto include in pages. Nothing is clean.

    setInterval(function(){ imageUpdate(); }, 1000);
    
    function imageUpdate() {
        console.log('######imageUpdate');
        var image = document.querySelectorAll("img");
        for (var num = 0; num < image.length; num++) {
            if (stringBeginWith(image[num].src, "http://1.1.1.1/bmi/***yourfoldershere***")) {
                var str=image[num].src;
                var res=str.replace("http://1.1.1.1/bmi/***yourfoldershere***", "");
                image[num].src = res;
                console.log("replace"+str+" by "+res);
                /*
                other solution is to push img src in data-src and push after dom loading all your data-src in your img src
                var data-str=image[num].data-src;
                image[num].src = data-str;
                */
                }
            }
    }
    
    function stringEndsWith(string, suffix) {
        return string.indexOf(suffix, string.length - suffix.length) !== -1
    }
    function stringBeginWith(string, prefix) {
        return string.indexOf(prefix, prefix.length-string.length) !== -1
    }
    
    0 讨论(0)
提交回复
热议问题