网络运营商注入到页面上的广告代码 r.js

JavaScript guokai 发表于 7 年前最后回复来自 qq2850071112 4 年前

最近微博上电信强弹广告的事情好像挺火的,下边是我之前遇到的网络运营商直接注入script到页面上的js代码,看最后一行代码,现在他们把弹广告的几率改成0.025了:

Function.prototype.getMultiLine = function() {  
    var lines = new String(this);  
    lines = lines.substring(lines.indexOf("/*<") + 3, lines.lastIndexOf(">*/"));  
    return lines;  
}

function yjwt_ads() {
    /*<
    <div id='yjwt-ads'
        style="position:relative;text-align:left;
        width:{width};height:{height};font-family:瀹嬩綋;">
    <embed style="position:absolute;z-index:0" 
        src="http://125.39.155.32/320x270.swf" quality="high" 
        width="{width}" height="{height}" type="application/x-shockwave-flash" 
        pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="opaque">
    <a href="{href}" target="_blank" 
        style="cursor:pointer;z-index:1; 
        position:absolute;display:block;background:white;
        filter:alpha(opacity=0);opacity:0;width:{width};height:{height};" 
        onfocus="this.blur();"></a>
    </div>
    >*/
    var embed = yjwt_ads.getMultiLine();
    embed = embed.replace(/{href}/g, 'http://tg.17quwan.com/r/dianxin3172/index.html?kwd=01');
    code = embed.replace(/{width}/g, '320px');
    code = code.replace(/{height}/g, '270px');

    // TODO: http://www.hao222.com/

    var host = window.location.host;

    if (host == 'www.hao222.com') {
        code = embed.replace(/{width}/g, '220px');
        code = code.replace(/{height}/g, '200px');
        $('#aside').prepend(code);              
    }
    if (host == '2345.com' || host == 'www.2345.com') {
        code = embed.replace(/{width}/g, '256px');
        code = code.replace(/{height}/g, '200px');
        var e = document.getElementById("right");
        if (e && !e.innerHTML.match('yjwt-ads')) {
            e.innerHTML = code + e.innerHTML;
        }
    }
    if (host == 'hao.360.cn') {
        code = embed.replace(/{width}/g, '228px');
        code = code.replace(/{height}/g, '200px');
        $(code).insertBefore($('.side-kuzhan-content'));
    }
    if (host == 'www.hao123.com' || host == 'hao123.com') {
        code = embed.replace(/{width}/g, '240px');
        code = code.replace(/{height}/g, '200px');
        $(code).insertBefore($('.lcs-info'));
    }
    if (host == '123.sogou.com') {
        code = embed.replace(/{width}/g, '230px');
        code = code.replace(/{height}/g, '200px');
        $(code).insertBefore($('#toolkitall'));
    }
    if (host == 'www.265.com') {
        code = embed.replace(/{width}/g, '186px');
        code = code.replace(/{height}/g, '130px');
        $(code).insertBefore($('#tools'));
    }
    if (host == 'site.baidu.com') {
        code = embed.replace(/{width}/g, '192px');
        code = code.replace(/{height}/g, '130px');
        $(code).insertBefore($('#leftwraper'));
    }
    if (host == 'www.114la.com') {
        code = embed.replace(/{width}/g, '218px');
        code = code.replace(/{height}/g, '200px');
        $(code).insertBefore($('.col-starBar'));
    }
    if (host == 'hao.qq.com') {
        code = embed.replace(/{width}/g, '209px');
        code = code.replace(/{height}/g, '200px');
        $(code).insertBefore($('.barBox'));
    }
    if (host == 'www.5566.net') {
        code = embed.replace(/{width}/g, '209px');
        code = code.replace(/{height}/g, '200px');
        $(code).insertBefore($('#div1'));
    }
    if (host == '123.duba.net') {
        code = embed.replace(/{width}/g, '232px');
        code = code.replace(/{height}/g, '200px');
        $(code).insertBefore($('.side_a'));
    }
    if (host == 'www.726.com') {
        code = embed.replace(/{width}/g, '228px');
        code = code.replace(/{height}/g, '200px');
        $('.bn_L').prepend(code);
    }
    if (host == 'www.46.com') {
        code = embed.replace(/{width}/g, '218px');
        code = code.replace(/{height}/g, '200px');
        $('#tool').prepend(code);
    }
    if (host == 'hao.163.com') {
        code = embed.replace(/{width}/g, '228px');
        code = code.replace(/{height}/g, '200px');
        $('.oneborder').prepend(code);      
    }
}

var yjwt_done = 0;

function yjwt_timer() {
    var w = $('#yjwt-ads');
    if (w == null || w.length == 0) {
        yjwt_ads();
        setTimeout(yjwt_timer, 1000);
    }
}
setTimeout(yjwt_timer, 1000);
var yjwt_prefix = "http://125.39.155.32/ads/";
var adslist = [
{'url':'http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CITy7klxxrJ35Nnc0vWbpc2MaPRzL76AoHZsBL27TDmZJsD%2FSnRANz%2BTZcSXLtqk0fqgFeDzn3vk9rn5ILd4dCx2w%3D%3D', 'img':'taobao/4/960X330.gif'},
{'url':'http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CFcRfH0GoT805sipKvI3fILrHcCf37EMMFU2clHVSUoLZtrIRaVV%2FswWdW9ocsemH6tqQ1UERumnjrgVkupWwrtsw%3D%3D', 'img':'taobao/1/390X140.gif'},
{'url':'http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CFcRfH0GoT805sipKvI3fIKIyTgJAlStn0Z116y%2Bx%2FyFp%2FvSrkpsiMziEVEtAhYNE3gkxzuewkWtCXdo6BQxDJQ1A%3D%3D', 'img':'taobao/2/710X245.gif'},
{'url':'http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CFcRfH0GoT805sipKvI3fMySnpGRI%2FVx%2FGJI90vhaN%2F0dxq7KucK7AP4%2BMGVabMiwMWRVVWBni1ImQ%2FhQOR2JMfRg%3D%3D', 'img':'taobao/8/390X140.gif'},
{'url':'http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CITy7klxxrJ35Nnc0vWbpaOTtv7xtnl0tmvZX3n51cpqWLKWLMNXP5QhWe0PejQE5CGdbCGxNijQif%2BAeDgC9GY', 'img':'taobao/9/190X96.jpg'},
{'url':'http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CFcRfH0GoT805sipKvI3fMySn3wUBvbZT%2B3FkiA6RrcetasIgQ8Co01stj4mus5Shp3OJylzXNKVpp4z6Y55e4Ulw%3D%3D', 'img':'taobao/7/960X950.jpg'},
{'url':'http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CFcRfH0GoT805sipKvI3fIKKKaXv3%2BNTJjJAan2CZm%2Bk%2Bf%2FtN4hpTinQdtyNiKfYDcv%2Bj8tnBuYEGtqs1GCUidOsg%3D%3D', 'img':'taobao/5/710X190.gif'},
{'url':'http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CITy7klxxrJ35Nnc0vWbpc2Nw6hQqcPsyjRMBm09w73SyIEHpnjsP7VwOUoM%2BWnPIXavy3fO45o0exFMTTX6H9z', 'img':'taobao/3/960X520.jpg'},
{'url':'http://a1722.oadz.com/link/C/1722/3901/lnggWQ9I4S12PAYDrJIr1Sy4RmQ_/p031/0/http://www.jiuxian.com/topic/1221/save/index.html', 'img':'taobao/10/390X335.jpg'},
{'url':'http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CFcRfH0GoT805sipKvI3fMyTxAzSte%2Bk%2FP3PzzNkKazDoCAtMfhxnoeJkvYvhdaNB2teIQ%2FXHiEFhspJbf2CW1WfA%3D%3D', 'img':'taobao/6/240X64.gif'},
];

function yjwt_contains(list, a) {
    for (var i = 0; i < list.length; i++) {
        if (list[i] == a) {
            return true;
        }
    }
    return false;
}

function yjwt_randpop_hostlimit(prob) {
    var host = window.location.host;
    var hostlist = [
        'www.hao222.com', 
        '2345.com', 'www.2345.com',
        'hao.360.cn',
        'www.hao123.com', 'hao123.com',
        '123.sogou.com', 
        'www.265.com',
        'site.baidu.com',
        'www.114la.com',
        'hao.qq.com',
        'www.5566.net',
        '123.duba.net',
        'www.726.com',
        'www.46.com',
        'hao.163.com'
    ];
    var blacklist = [ "www.baidu.com" ];
    if (yjwt_contains(blacklist, host)) {
        return ;
    }
    try {
        if (Math.random() < prob) {
            var r = Math.floor(Math.random()*adslist.length);
            var a = adslist[r];
            var url = yjwt_prefix + "pop.html?url=" + encodeURIComponent(a.url) + 
                            '&src=' + encodeURIComponent(a.img);
            window.open(url, "_blank", 'height='+a.height+',width='+a.width);
        }
    }   catch (e) { }
}

yjwt_randpop_hostlimit(0.025);
共收到1条回复
ihuguowei 7 年前 #1

刚学js,看着还有点晕。弹窗我到没怎么遇到过。

登录后即可参与回复