欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

去掉广告的代码

程序员文章站 2024-02-17 08:44:16
...
 public void removeSmartTAOBAOad()
    {
        uiwebview.loadUrl("javascript:"+
        "var evt = document.createEvent('MouseEvents');"+
        "evt.initEvent('click', true, true);"+
        "var i=0;"+
        "setTimeout(function(){check_click()}, 300);"+
        "function check_click(){"+
            "var close = document.getElementById('smartAd-close');"+
            "if(typeof close != 'undefined')"+
                "close.dispatchEvent(evt);"+
            "else if(i <= 10)"+
                "setTimeout(function(){check_click();}, 300);"+
            "i+=1;"+
        "};");


    }

 @Override
        public void onPageFinished(WebView view, String url) {
            progressBar.setVisibility(View.INVISIBLE);
            removeSmartTAOBAOad();
        }