这段代码很有意思 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
buxianglei
V2EX    程序员

这段代码很有意思

  •  
      buxianglei 2015-05-01 05:00:21 +08:00 5312 次点击
    这是一个创建于 3840 天前的主题,其中的信息可能已经有所发展或是发生改变。

    if(!document.URL.match(new RegExp('^http:\/\/(v|music|dnf)\.(baidu|duowan)\.com'))){
    (function() {
    Function.prototype.bind = function() {
    var fn = this, args = Array.prototype.slice.call(arguments), obj = args.shift();
    return function() {
    return fn.apply(obj, args.concat(Array.prototype.slice.call(arguments)));
    };
    };
    function A() {}
    A.prototype = {
    rules: {
    'youkuloader': {
    'find': /^http:\/\/static.youku.com\/.*(loader|player
    .)(_taobao)?.swf/,
    'replace': 'http://swf.adtchrome.com/loader.swf'
    },
    'youku_out': {
    'find': /^http:\/\/player.youku.com\/player.php\/.*sid\/(.
    )/,
    'replace': 'http://swf.adtchrome.com/loader.swf?VideoIDS=$1'
    },
    'pps_pps': {
    'find': /^http:\/\/www.iqiyi.com\/player\/cupid\/common\/pps_flvplay_s.swf/,
    'replace': 'http://swf.adtchrome.com/pps_20140420.swf'
    },
    'iqiyi_1': {
    'find': /^http:\/\/www.iqiyi.com\/player\/cupid\/common\/.+.swf$/,
    'replace': 'http://swf.adtchrome.com/iqiyi_20140624.swf'
    },
    'iqiyi_2': {
    'find': /^http:\/\/www.iqiyi.com\/common\/flashplayer\/\d+\/.+.swf$/,
    'replace': 'http://swf.adtchrome.com/iqiyi_20140624.swf'
    },
    'ku6': {
    'find': /^http:\/\/player.ku6cdn.com\/default\/.\/\d+\/(v|player|loader).swf/,
    'replace': 'http://swf.adtchrome.com/ku6_20140420.swf'
    },
    'ku6_topic': {
    'find': /^http:\/\/player.ku6.com\/inside\/(.
    )\/v.swf/,
    'replace': 'http://swf.adtchrome.com/ku6_20140420.swf?vid=$1'
    },
    'sohu': {
    'find': /^http:\/\/tv.sohu.com\/upload\/swf(\/p2p)?\/\d+\/Main.swf/,
    'replace': 'http://www.adtchrome.com/sohu/sohu_20150104.swf'
    },
    'sohu_share': {
    'find': /^http:\/\/share.vrs.sohu.com\/my\/v.swf&/,
    'replace': 'http://www.adtchrome.com/sohu/sohu_20150104.swf?'
    },
    'sohu_sogou' : {
    'find': /^http:\/\/share.vrs.sohu.com\/(\d+)\/v.swf/,
    'replace': 'http://www.adtchrome.com/sohu/sohu_20150104.swf?vid=$1'
    },
    'letv': {
    'find': /^http:\/\/player.letvcdn.com\/p\/.*\/newplayer\/LetvPlayer.swf/,
    'replace': 'http://swf.adtchrome.com/20150110_letv.swf'
    },
    'letv_topic': {
    'find': /^http:\/\/player.hz.letv.com\/hzplayer.swf\/v_list=zhuanti/,
    'replace': 'http://swf.adtchrome.com/20150110_letv.swf'
    },
    'letv_duowan': {
    'find': /^http:\/\/assets.dwstatic.com\/video\/vpp.swf/,
    'replace': 'http://yuntv.letv.com/bcloud.swf'
    }
    },
    _done: null,
    get done() {
    if(!this._done) {
    this._dOne= new Array();
    }
    return this._done;
    },
    addAnimations: function() {
    var style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = 'object,embed{\
    -webkit-animation-duration:.001s;-webkit-animation-name:playerInserted;\
    -ms-animation-duration:.001s;-ms-animation-name:playerInserted;\
    -o-animation-duration:.001s;-o-animation-name:playerInserted;\
    animation-duration:.001s;animation-name:playerInserted;}\
    @-webkit-keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}\
    @-ms-keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}\
    @-o-keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}\
    @keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}';
    document.getElementsByTagName('head')[0].appendChild(style);
    },
    animationsHandler: function(e) {
    if(e.animatiOnName=== 'playerInserted') {
    this.replace(e.target);
    }
    },
    replace: function(elem) {
    if(this.done.indexOf(elem) != -1) return;
    this.done.push(elem);
    var player = elem.data || elem.src;
    if(!player) return;
    var i, find, replace = false;
    for(i in this.rules) {
    find = this.rules[i]['find'];
    if(find.test(player)) {
    replace = this.rules[i]['replace'];
    if('function' === typeof this.rules[i]['preHandle']) {
    this.rules[i]['preHandle'].bind(this, elem, find, replace, player)();
    }else{
    this.reallyReplace.bind(this, elem, find, replace)();
    }
    break;
    }
    }
    },
    reallyReplace: function(elem, find, replace) {
    elem.data && (elem.data = elem.data.replace(find, replace)) || elem.src && ((elem.src = elem.src.replace(find, replace)) && (elem.style.display = 'block'));
    var b = elem.querySelector("param[name='movie']");
    this.reloadPlugin(elem);
    },
    reloadPlugin: function(elem) {
    var nextSibling = elem.nextSibling;
    var parentNode = elem.parentNode;
    parentNode.removeChild(elem);
    var newElem = elem.cloneNode(true);
    this.done.push(newElem);
    if(nextSibling) {
    parentNode.insertBefore(newElem, nextSibling);
    } else {
    parentNode.appendChild(newElem);
    }
    },
    init: function() {
    var handler = this.animationsHandler.bind(this);
    document.body.addEventListener('webkitAnimationStart', handler, false);
    document.body.addEventListener('msAnimationStart', handler, false);
    document.body.addEventListener('oAnimationStart', handler, false);
    document.body.addEventListener('animationstart', handler, false);
    this.addAnimations();
    }
    };
    new A().init();
    })();
    }
    // 20140730
    (function cnbeta() {
    if (document.URL.indexOf('cnbeta.com') >= 0) {
    var elms = document.body.querySelectorAll("p>embed");
    Array.prototype.forEach.call(elms, function(elm) {
    elm.style.marginLeft = "0px";
    });
    }
    })();
    // 20150108
    setTimeout(function(){
    if (document.URL.indexOf('www.baidu.com') >= 0) {
    var a = function(){
    Array.prototype.forEach.call(document.body.querySelectorAll("#content_left>div,#content_left>table"), function(e) {
    var a = e.getAttribute("style");
    if(a && /display:(table|block)\s!important/.test(a)){
    e.removeAttribute("style")
    }
    });
    };
    a();
    document.getElementById("su").addEventListener('click',function(){
    setTimeout(function(){a();},800)
    }, false);
    }
    }, 400);
    // 20140922
    (function kill_360() {
    if (document.URL.indexOf('so.com') >= 0) {
    document.getElementById("e_idea_pp").style.display = none;
    }
    })();

    取自:广告终结者

    9 条回复    2015-05-02 10:38:59 +08:00
    pH
        1
    pH  
       2015-05-01 08:25:58 +08:00
    我在想0-0 有多少人有耐心看完。
    mmmyc
        2
    mmmyc  
       2015-05-01 10:32:42 +08:00 via Android
    没看完,不会看
    lsmgeb89
        3
    lsmgeb89  
       2015-05-01 11:33:16 +08:00
    能不能把代码贴贴好,看起来也舒服。
    fo2w
        4
    fo2w  
       2015-05-01 12:11:54 +08:00
    这排版也很有意思
    Gn
        5
    Gn  
       2015-05-01 17:27:29 +08:00   1
    @fo2w 哈哈哈
    这个应该是把视频站的播放器换成去广告修改版播放器的 JS。
    KexyBiscuit
        6
    KexyBiscuit  
       2015-05-01 22:26:12 +08:00 via Android
    有个东西叫 Gist...
    xifangczy
        7
    xifangczy  
       2015-05-01 22:45:18 +08:00
    没看完 看前面就知道是过滤视频广告的插件
    好是好 但是能一直保持更新的很少。
    langhua9527
        8
    langhua9527  
       2015-05-01 23:26:42 +08:00
    aofall
        9
    aofall  
       2015-05-02 10:38:59 +08:00
    广告终结者一开始被爆出有小动作,后来我用的屏蔽扩展失效后干脆就不屏蔽视频广告了
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1503 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 33ms UTC 16:38 PVG 00:38 LAX 08:38 JFK 11:38
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86