这段代码很有意思

2015-05-01 05:00:21 +08:00
 buxianglei

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;
}
})();

取自:广告终结者

4755 次点击
所在节点    程序员
9 条回复
pH
2015-05-01 08:25:58 +08:00
我在想0-0 有多少人有耐心看完。
mmmyc
2015-05-01 10:32:42 +08:00
没看完,不会看
lsmgeb89
2015-05-01 11:33:16 +08:00
能不能把代码贴贴好,看起来也舒服。
fo2w
2015-05-01 12:11:54 +08:00
这排版也很有意思
Gn
2015-05-01 17:27:29 +08:00
@fo2w 哈哈哈
这个应该是把视频站的播放器换成去广告修改版播放器的 JS。
KexyBiscuit
2015-05-01 22:26:12 +08:00
有个东西叫 Gist...
xifangczy
2015-05-01 22:45:18 +08:00
没看完 看前面就知道是过滤视频广告的插件
好是好 但是能一直保持更新的很少。
langhua9527
2015-05-01 23:26:42 +08:00
aofall
2015-05-02 10:38:59 +08:00
广告终结者一开始被爆出有小动作,后来我用的屏蔽扩展失效后干脆就不屏蔽视频广告了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/187675

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX