-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rasso1
committed
Nov 20, 2014
1 parent
d3ce4b6
commit 88d08dd
Showing
9 changed files
with
403 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,276 @@ | ||
const Cc = Components.classes; | ||
const Ci = Components.interfaces; | ||
const Cr = Components.results; | ||
const Cu = Components.utils | ||
|
||
var EXPORTED_SYMBOLS = ["AntiChinaVideoAds"]; | ||
|
||
Cu.import("resource://gre/modules/NetUtil.jsm"); | ||
|
||
function AntiChinaVideoAds() {}; | ||
AntiChinaVideoAds.prototype = { | ||
SITES: { | ||
'youku_loader': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/loader.swf', | ||
're': /http:\/\/static\.youku\.com(\/v[\d\.]+)?\/v\/swf\/loaders?\.swf/i | ||
}, | ||
'youku_player': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/player.swf', | ||
're': /http:\/\/static\.youku\.com(\/v[\d\.]+)?\/v\/swf\/q?player[^\.]*\.swf/i | ||
}, | ||
'ku6': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/ku6.swf', | ||
're': /http:\/\/player\.ku6cdn\.com\/default\/common\/player\/\d{12}\/player\.swf/i | ||
}, | ||
'ku6_out': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/ku6_out.swf', | ||
're': /http:\/\/player\.ku6cdn\.com\/default\/out\/\d{12}\/player\.swf/i | ||
}, | ||
'iqiyi': { | ||
'player0': 'chrome://AntiChinaVideoAds/content/swf/iqiyi_out.swf', | ||
'player1': 'chrome://AntiChinaVideoAds/content/swf/iqiyi5.swf', | ||
'player2': 'chrome://AntiChinaVideoAds/content/swf/iqiyi.swf', | ||
're': /https?:\/\/www\.iqiyi\.com\/(player\/\d+\/Player|common\/flashplayer\/\d+\/(Main|Coop|Share)?Player_?.*)\.swf/i | ||
}, | ||
'tudou': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/tudou.swf', | ||
're': /http:\/\/js\.tudouui\.com\/.*portalplayer[^\.]*\.swf/i | ||
}, | ||
'tudou_olc': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/olc_8.swf', | ||
're': /http:\/\/js\.tudouui\.com\/.*olc[^\.]*\.swf/i | ||
}, | ||
'tudou_sp': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/sp.swf', | ||
're': /http:\/\/js\.tudouui\.com\/.*\/socialplayer[^\.]*\.swf/i | ||
}, | ||
'letv': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/letv.swf', | ||
're': /http:\/\/.*letv[\w]*\.com\/(hz|.*\/((?!(Live|seed|Disk))(S[\w]{2,3})?(?!Live)[\w]{4}|swf))Player*\.swf/i | ||
}, | ||
'letv_live': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/letvlive.swf', | ||
're': /http:\/\/.*letv[\w]*\.com\/p\/\d+\/\d+\/\d+\/newplayer\/LivePlayer\.swf/i | ||
}, | ||
'letvskin': { | ||
'player': 'http://player.letvcdn.com/p/201407/24/15/newplayer/1/SSLetvPlayer.swf', | ||
're': /http:\/\/.*letv[\w]*\.com\/p\/\d+\/\d+\/(?!15)\d*\/newplayer\/\d+\/S?SLetvPlayer\.swf/i | ||
}, | ||
'pptv': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/pptv.swf', | ||
're': /http:\/\/player.pplive.cn\/ikan\/.*\/player4player2\.swf/i | ||
}, | ||
'pplive': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/pptvLive.swf', | ||
're': /http:\/\/player.pplive.cn\/live\/.*\/player4live2\.swf/i | ||
}, | ||
'sohu': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/sohu.swf', | ||
're': /http:\/\/tv\.sohu\.com\/upload\/swf\/(?!(live|\d+)).*\d+\/(main|PlayerShell)\.swf/i | ||
}, | ||
'sohu_liv': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/sohulive.swf', | ||
're': /http:\/\/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(:[0-9]{2,5})?(\/test)?\/(player|webplayer)\/(main|playershell)\.swf/i | ||
}, | ||
'sohu_live': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/sohulive.swf', | ||
're': /http:\/\/tv\.sohu\.com\/upload\/swf\/(live\/|)\d+\/(main|PlayerShell)\.swf/i | ||
}, | ||
'pps': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/pps.swf', | ||
're': /http:\/\/www\.iqiyi\.com\/player\/cupid\/.*\/pps[\w]+.swf/i | ||
}, | ||
'ppsiqiyi': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/iqiyi.swf', | ||
're': /http:\/\/www\.iqiyi\.com\/common\/flashplayer\/\d+\/PPSMainPlayer.*\.swf/i | ||
}, | ||
'ppslive': { | ||
'player': 'http://www.iqiyi.com/player/20140613210124/livePlayer.swf', | ||
're': /http:\/\/www\.iqiyi\.com\/common\/flashplayer\/\d+\/am.*\.swf/i | ||
}, | ||
'wanhenda': { | ||
'player': 'http://yuntv.letv.com/bcloud.swf', | ||
're': /http:\/\/assets\.dwstatic\.com\/.*\/vppp\.swf/i | ||
}, | ||
'17173': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/17173_Player_file.swf', | ||
're': /http:\/\/f\.v\.17173cdn\.com\/\d+\/flash\/Player_file\.swf/i | ||
}, | ||
'17173_out': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/17173_Player_file_out.swf', | ||
're': /http:\/\/f\.v\.17173cdn\.com(\/\d+)?\/flash\/Player_file_(custom)?out\.swf/i | ||
}, | ||
'17173_stream_customOut': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/17173_Player_stream_out.swf', | ||
're': /http:\/\/f\.v\.17173cdn\.com(\/\d+)?\/flash\/Player_stream_(custom)?Out\.swf/i | ||
}, | ||
'17173_live': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/17173_Player_stream.swf', | ||
're': /http:\/\/f\.v\.17173cdn\.com\/\d+\/flash\/Player_stream(_firstpage)?\.swf/i | ||
}, | ||
'baiduAD': { | ||
'player': 'chrome://AntiChinaVideoAds/content/swf/baiduAD.swf', | ||
're': /http:\/\/list\.video\.baidu\.com\/swf\/advPlayer\.swf/i | ||
} | ||
}, | ||
os: Cc['@mozilla.org/observer-service;1'] | ||
.getService(Ci.nsIObserverService), | ||
init: function() { | ||
var site = this.SITES['iqiyi']; | ||
site['preHandle'] = function(aSubject) { | ||
var wnd = this.getWindowForRequest(aSubject); | ||
if(wnd) { | ||
site['cond'] = [ | ||
!/(^((?!baidu|61|178).)*\.iqiyi\.com|pps\.tv)/i.test(wnd.self.location.host), | ||
wnd.self.document.querySelector('span[data-flashplayerparam-flashurl]'), | ||
true | ||
]; | ||
if(!site['cond']) return; | ||
|
||
for(var i = 0; i < site['cond'].length; i++) { | ||
if(site['cond'][i]) { | ||
if(site['player'] != site['player' + i]) { | ||
site['player'] = site['player' + i]; | ||
site['storageStream'] = site['storageStream' + i] ? site['storageStream' + i] : null; | ||
site['count'] = site['count' + i] ? site['count' + i] : null; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
site['callback'] = function() { | ||
if(!site['cond']) return; | ||
|
||
for(var i = 0; i < site['cond'].length; i++) { | ||
if(site['player' + i] == site['player']) { | ||
site['storageStream' + i] = site['storageStream']; | ||
site['count' + i] = site['count']; | ||
break; | ||
} | ||
} | ||
}; | ||
}, | ||
// getPlayer, get modified player | ||
getPlayer: function(site, callback) { | ||
NetUtil.asyncFetch(site['player'], function(inputStream, status) { | ||
var binaryOutputStream = Cc['@mozilla.org/binaryoutputstream;1'] | ||
.createInstance(Ci['nsIBinaryOutputStream']); | ||
var storageStream = Cc['@mozilla.org/storagestream;1'] | ||
.createInstance(Ci['nsIStorageStream']); | ||
var count = inputStream.available(); | ||
var data = NetUtil.readInputStreamToString(inputStream, count); | ||
|
||
storageStream.init(512, count, null); | ||
binaryOutputStream.setOutputStream(storageStream.getOutputStream(0)); | ||
binaryOutputStream.writeBytes(data, count); | ||
|
||
site['storageStream'] = storageStream; | ||
site['count'] = count; | ||
|
||
if(typeof callback === 'function') { | ||
callback(); | ||
} | ||
}); | ||
}, | ||
getWindowForRequest: function(request){ | ||
if(request instanceof Ci.nsIRequest){ | ||
try{ | ||
if(request.notificationCallbacks){ | ||
return request.notificationCallbacks | ||
.getInterface(Ci.nsILoadContext) | ||
.associatedWindow; | ||
} | ||
} catch(e) {} | ||
try{ | ||
if(request.loadGroup && request.loadGroup.notificationCallbacks){ | ||
return request.loadGroup.notificationCallbacks | ||
.getInterface(Ci.nsILoadContext) | ||
.associatedWindow; | ||
} | ||
} catch(e) {} | ||
} | ||
return null; | ||
}, | ||
observe: function(aSubject, aTopic, aData) { | ||
if(aTopic != 'http-on-examine-response') return; | ||
|
||
var http = aSubject.QueryInterface(Ci.nsIHttpChannel); | ||
|
||
var aVisitor = new HttpHeaderVisitor(); | ||
http.visitResponseHeaders(aVisitor); | ||
if (!aVisitor.isFlash()) return; | ||
|
||
for(var i in this.SITES) { | ||
var site = this.SITES[i]; | ||
if(site['re'].test(http.URI.spec)) { | ||
var fn = this, args = Array.prototype.slice.call(arguments); | ||
|
||
if(typeof site['preHandle'] === 'function') | ||
site['preHandle'].apply(fn, args); | ||
|
||
if(!site['storageStream'] || !site['count']) { | ||
http.suspend(); | ||
this.getPlayer(site, function() { | ||
http.resume(); | ||
if(typeof site['callback'] === 'function') | ||
site['callback'].apply(fn, args); | ||
}); | ||
} | ||
|
||
var newListener = new TrackingListener(); | ||
aSubject.QueryInterface(Ci.nsITraceableChannel); | ||
newListener.originalListener = aSubject.setNewListener(newListener); | ||
newListener.site = site; | ||
|
||
break; | ||
} | ||
} | ||
}, | ||
QueryInterface: function(aIID) { | ||
if(aIID.equals(Ci.nsISupports) || aIID.equals(Ci.nsIObserver)) | ||
return this; | ||
|
||
return Cr.NS_ERROR_NO_INTERFACE; | ||
}, | ||
register: function() { | ||
this.init(); | ||
this.os.addObserver(this, 'http-on-examine-response', false); | ||
}, | ||
unregister: function() { | ||
this.os.removeObserver(this, 'http-on-examine-response', false); | ||
} | ||
}; | ||
|
||
// TrackingListener, redirect youku player to modified player | ||
function TrackingListener() { | ||
this.originalListener = null; | ||
this.site = null; | ||
} | ||
TrackingListener.prototype = { | ||
onStartRequest: function(request, context) { | ||
this.originalListener.onStartRequest(request, context); | ||
}, | ||
onStopRequest: function(request, context) { | ||
this.originalListener.onStopRequest(request, context, Cr.NS_OK); | ||
}, | ||
onDataAvailable: function(request, context) { | ||
this.originalListener.onDataAvailable(request, context, this.site['storageStream'].newInputStream(0), 0, this.site['count']); | ||
} | ||
}; | ||
|
||
function HttpHeaderVisitor() { | ||
this._isFlash = false; | ||
} | ||
HttpHeaderVisitor.prototype = { | ||
visitHeader: function(aHeader, aValue) { | ||
if (aHeader.indexOf("Content-Type") !== -1) { | ||
if (aValue.indexOf("application/x-shockwave-flash") !== -1) { | ||
this._isFlash = true; | ||
} | ||
} | ||
}, | ||
isFlash: function() { | ||
return this._isFlash; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||
xmlns:em="http://www.mozilla.org/2004/em-rdf#"> | ||
<RDF:Description about="urn:mozilla:extension:[email protected]"> | ||
<em:updates> | ||
<RDF:Seq> | ||
<RDF:li> | ||
<RDF:Description> | ||
<em:version>1.7.4</em:version> | ||
<em:targetApplication> | ||
<RDF:Description> | ||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> | ||
<em:minVersion>10.0</em:minVersion> | ||
<em:maxVersion>*</em:maxVersion> | ||
<em:updateLink>https://github.com/rasso1/youkuantiads/releases/download/1031/AntiChinaVideoAds10311.xpi</em:updateLink> | ||
</RDF:Description> | ||
</em:targetApplication> | ||
</RDF:Description> | ||
</RDF:li> | ||
</RDF:Seq> | ||
</em:updates> | ||
</RDF:Description> | ||
</RDF:RDF> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
火狐去视频广告扩展AntiChinaVideoAdsAlliances(本地播放版): | ||
|
||
在以下作者基础上修改而成: | ||
OpenGG.Clean.Player 作者 鲁夫的爱 (一代风流人物,开帮派之先河) | ||
[email protected] 作者cinhoo (退隐江湖之风清扬,时不时出来指点2招) | ||
播放器/代码 作者 15536900 (仍在兢兢业业镇守边关的郭大侠) | ||
播放器 作者 catcat520 (有独到之秘的小龙女,喵喵控的应该是妹妹吧 ) | ||
前身是cinhoo大神的youkuantiADs,改名而已。大都是cinhoo代码,只为更新而改小部分 | ||
|
||
功能介绍: | ||
火狐浏览器扩展,自带本地播放器版,去除国内主流视频网站的几十秒无节操广告, | ||
如爱奇艺,pps,letv,pptv,优酷,酷六,腾讯,搜狐,17173,多玩等 | ||
|
||
使用方法: | ||
下载的扩展拉到火狐附加组件列表即可安装,关闭打开的视频页并清理浏览器缓存, | ||
再重启下浏览器,看看是不是广告影无踪了 | ||
|
||
下崽地址(两版本): | ||
新版启用霸气侧漏名:AntiChinaVideoAdsAlliances(中国反视频广告联盟)支持在线更新: | ||
1.位于github的在线更新版本(下载安装后点击在线更新获取最新版本): | ||
https://github.com/rasso1/youkuantiads/releases/download/1027/AntiChinaVideoAds_with_player10272.xpi | ||
360盘备用地址: http://yunpan.cn/Q7pgYgEB6JcGB (提取码:a5f5) | ||
2 .火狐官方扩展中心版本(新版在线更新需通过3天官方安全审核,也可手动下载更新): | ||
https://addons.mozilla.org/zh-CN/firefox/addon/antichinavideoadsalliances/ | ||
|
||
|
||
|
||
|
||
版本更新历史: | ||
10月27日更新,修复乐视网盘播放,修复乐视在线直播,为美观缩写英文名(ACVAA)及缩短版本号(最新版本号1.7.2) | ||
10月23日更新,优化图标设计,增加内容介绍,缩减安装包大小,使用新版爱奇艺播放器(最新版本号1.7.0.6) | ||
09月28日更新,修复PPTV播放黑屏的问题。(最新版本号1.7.0.5) | ||
09月26日更新,提交火狐官方扩展中心认证,并提供下载,该版本与通过github更新方式不同,请选择安装。 | ||
09月20日更新,增加17173定制外链广告过滤(最新版本号1.7.0.3) | ||
09月19日二更,增加扩展图标,修改内容介绍(如有较好的图标设计或者内容介绍,欢迎提供,希望成为大家的扩展为大家) | ||
09月19日更新,增加17173部分外链广告过滤 | ||
09月18日更新,youkuantiads名有歧义,非只过滤优酷广告,故现更名为AntiChinaVideoAdsAlliances 中国反视频广告联盟, | ||
原youkuantiads不再提供升级服务,抱歉。 | ||
09月18日更新,修复部分爱奇艺外链无法播放问题,合2搜狐视频正则为1. | ||
09月17日二更,修复部分搜狐电影广告未除问题。同时大家可以试用自动更新功能(一般浏览器打开扩展列表时自动检查更新, | ||
也可在AntiChinaVideoAdsAlliances“更多”中,点击“关”,强制使用“检查更新”,左下侧即会出现更新) | ||
09月17日更新,使用GitHub在线更新功能,更新也不再需番茄。同时修复部分搜狐电视台直播的广告未除问题。 | ||
09月15日更新, 修复因土豆更改css文件导致部分电脑无法显示播放进度条问题 | ||
09月08日更新, 修复17173的部分视频去广告 | ||
08月25日更新,增加搜狐部分视频的广告过滤和搜狐直播电视的视频广告过滤 | ||
08月24日更新,增加外站调用爱奇艺播放器时的广告过滤 | ||
08月15日更新 ,增加17173的15秒广告过滤 | ||
08月11日更新第2弹,增加多玩30秒广告过滤 | ||
08月11日更新第1弹,增加B站的45秒广告过滤 | ||
08月10日更新,修复爱奇艺广告过滤 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const Cu = Components.utils; | ||
|
||
var y = null | ||
|
||
function startup(data, reason) { | ||
Cu.import("chrome://AntiChinaVideoAds/content/AntiChinaVideoAds.js"); | ||
|
||
if(!y) { | ||
y = new AntiChinaVideoAds(); | ||
} | ||
y.register(); | ||
} | ||
|
||
function shutdown(data, reason) { | ||
if(y) { | ||
y.unregister(); | ||
y = null; | ||
} | ||
} | ||
|
||
function install(data, reason) { | ||
} | ||
|
||
function uninstall(data, reason) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
content AntiChinaVideoAds content/ |
Oops, something went wrong.