Greasy Fork

Greasy Fork is available in English.

vipVideos_skipAd

去视频广告,优酷、土豆VIP免费看

当前为 2015-03-12 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           vipVideos_skipAd
// @namespace      vipVideos_skipAd
// @author	       xinggsf~gmail。com
// @description    去视频广告,优酷、土豆VIP免费看
// @license        GPL version 3
// @homepageURL    http://greasyfork.icu/scripts/8561
// updateURL       http://greasyfork.icu/scripts/8561/code/vipVideos_skipAd.user.js
// downloadURL     http://greasyfork.icu/scripts/8561/code/vipVideos_skipAd.user.js
// @include      http://www.iqiyi.com/*
// @include      http://v.pps.tv/play_*
// @include      http://ipd.pps.tv/play_*
// @include      http://www.tudou.com/albumplay/*
// @include      http://www.tudou.com/listplay/*
// @include      http://www.tudou.com/programs/view/*
// @include      http://v.youku.com/v_show/id_*
// @include      http://v.youku.com/v_playlist/*
// @version        1.0
// @encoding       utf-8
// @modified       03/11/2015
// @run-at         document-end
// @grant          none
// ==/UserScript==

(function() {
Overload = function (fn_objs) {
	var is_match = function (x, y) {
		if (x == y)
			return true;
		if (x.indexOf("*") == -1)
			return false;

		var x_arr = x.split(","),
		y_arr = y.split(",");
		if (x_arr.length != y_arr.length)
			return false;
		while (x_arr.length) {
			var x_first = x_arr.shift(),
			y_first = y_arr.shift();
			if (x_first != "*" && x_first != y_first)
				return false;
		}
		return true;
	};
	var ret = function () {
		var args = arguments,
		args_len = args.length,
		args_types = [],
		args_type,
		fn_objs = args.callee._fn_objs,
		match_fn = function () {};

		for (var i = 0; i < args_len; i++) {
			var type = typeof args[i];
			type == "object" && (args[i].length > -1) && (type = "array");
			args_types.push(type);
		}
		args_type = args_types.join(",");
		for (var k in fn_objs) {
			if (is_match(k, args_type)) {
				match_fn = fn_objs[k];
				break;
			}
		}
		return match_fn.apply(this, args);
	};
	ret._fn_objs = fn_objs;
	return ret;
};
String.prototype.format = Overload({
	"array" : function (params) {
		var reg = /{(\d+)}/gm;
		return this.replace(reg, function (match, name) {
			return params[~~name];
		});
	},
	"object" : function (param) {
		var reg = /{([^{}]+)}/gm;
		return this.replace(reg, function (match, name) {
			return param[name];
		});
	}
});
if (typeof String.prototype.startsWith !== 'function') {
	String.prototype.startsWith = function (str){
		return this.slice(0, str.length) === str;
	};
	String.prototype.endsWith = function (str){
		return this.slice(-str.length) === str;
	};
}

var router = {
	handlers: {},

	run: function() {
	  var o, handler = this.matchHandler();
	  console.log('handler:', handler);
	  if (handler) {
		setTimeout(function(){
			//Object.create(handler).proc();
			o = new handler();
			console.log('handler proc():', o);
			o.proc();
		}, 9);
	  }
	},

	register: function(domain, handler) {
	  this.handlers[domain] = handler;
	},

	matchHandler: function() {
		console.log('matchHandler() --');
		var host = location.host.match(/\w+\.\w+$/)[0];
		return (host in this.handlers) ? this.handlers[host] : null;
	}
};

var Class={
	create:function(){
		return function(){
			this.init.apply(this,arguments);
		};
	}
};
/*定义基类Base*/
var Base=Class.create();
Base.prototype={
	extend:function(obj){
		for(var i in obj){
			this[i]=obj[i];
		}
	},	
	
	getFlashvar : function(vName) {
		var ret, s = new RegExp(vName +'=([^&]+)');//,'i'
		s = this.flashvars.match(s);
		ret = s && s.length > 1;
		if (ret) this.params.push(s[1]);
		return ret;
	},
	isProc : function() {
		return true;
	},
	rebuildSwf : function() {
		var p, s = this.data.swfMark.format(this.params);
		p = this.player.parentNode;
		if (p.childNodes.length===1) {
			p.innerHTML = s;
		}
		else {
			p.innerHTML = p.innerHTML.replace(/<object [\s\S]+?<\/object>/,s);		
		}
	},
	init : function() {
		this.params=[];
	},
	proc : function() {
		this.player = document.getElementById(this.data.id);
		if (!this.player) return;
		console.log('get player: ', this.player);
		var s = this.player.innerHTML;
		s = s.match(/name="flashvars"\s+value="([^"]+)"/i);
		if (!s && s.length < 2) return;
		this.flashvars = unescape(s[1]).replace(/&amp;/g,'&');
		console.log('flashvars: ', this.flashvars);
		
		if (!this.isProc()) return;
		this.getParams();
		console.log('getParams(): ', this.params);
		this.rebuildSwf();
	}
};

/*定义子类YouKu*/
var YouKu=Class.create();
var repeater=new Base();
repeater.extend({
	init : function() {
		this.data = {
			domain: 'youKu.com',
			id: 'movie_player',
			swfMark: '<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.buguanji.com/Public/Home/player/20141007/loader.swf" width="100%" height="100%" id="movie_player" name="movie_player" bgcolor="#000000" isfullscreen="true" allowfullscreen="true" allowscriptaccess="always" wmode="transparent" flashvars="isShowRelatedVideo=false&showAd=0&show_ce=0&showsearch=0&VideoIDS={0}&isAutoPlay=true&winType=BDskin&Type=PlayList&vip=1">'
		};
		Base.prototype.init.apply(this,arguments);
	},
	getParams:function(){
		this.getFlashvar('VideoIDS');
		if (!this.params.length)
			throw new Error('param error!');
	}
});
YouKu.prototype=repeater;
router.register('youku.com', YouKu);

var Tudou=Class.create();
repeater=new Base();
repeater.extend({
	init : function() {
		this.data = {
			domain: 'tudou.com',
			id: 'tudouHomePlayer',
			swfMark: '<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.buguanji.com/Public/Home/player/20141007/loader.swf" width="100%" height="100%" id="tudouHomePlayer" name="tudouHomePlayer" bgcolor="#000000" isfullscreen="true" allowfullscreen="true" allowscriptaccess="always" wmode="transparent" flashvars="isShowRelatedVideo=false&showAd=0&show_ce=0&showsearch=0&VideoIDS={0}&isAutoPlay=true&winType=BDskin&Type=PlayList&vip=1">'
		};
		Base.prototype.init.apply(this,arguments);
	},
	isProc:function(){
		return this.flashvars.indexOf('referrer=http://vip.') > 0 ||
				this.flashvars.indexOf('referrer=&') > 0;
	},
	getParams:function(){
		this.getFlashvar('vcode');
		if (!this.params.length)
			throw new Error('param error!');
	}
});
Tudou.prototype=repeater;
router.register('tudou.com', Tudou);

var Iqiyi=Class.create();
repeater=new Base();
repeater.extend({
	init : function() {
		this.data = {
			domain: 'iqiyi.com',
			id: 'flash',
			swfMark: '<embed data-widget-player="flash" pluginspage="http://www.macromedia.com/go/getflashplayer" loop="true" play="true" quality="hight" devicefont="false" allowfullscreen="true" menu="true" type="application/x-shockwave-flash" width="100%" height="100%" src="{0}" id="flash" bgcolor="#000000" wmode="transparent"  flashvars="components=feffbfe6e0&tvId={1}&autoplay=true&flashP2PCoreUrl={2}&cid=qc_100001_100141&origin=true&outsite=false&definitionID={3}" align="middle" hint="true" allowscriptaccess="always" Scale="NoScale">'
		};
		Base.prototype.init.apply(this,arguments);
	},
	// isProc:function(){
		// return this.flashvars.indexOf('components=feffbfe6e0') === -1;
	// },
	getParams:function(){
		this.params.push(this.player.getAttribute('data'));
/* 		var s = this.flashvars.replace(/&\w+?loader=[^&]+/g,'')
							.replace(/&tipdataurl=[^&]+/i,'')
							.replace(/&adurl=[^&]+/i,'')
							.replace(/components=\w+/i,'components=feffbfe6e0')
							.replace(/&cid=qc_[^&]+/,'&cid=qc_100001_100141');
		this.params.push(s); */
		if (!this.getFlashvar('tvId'))
			this.params.push('');
		this.getFlashvar('flashP2PCoreUrl');
		if (!this.getFlashvar('definitionID'))
			this.getFlashvar('vid');
		if (this.params.length < 4)
			throw new Error('param little!');
	}
});
Iqiyi.prototype=repeater;
router.register('iqiyi.com', Iqiyi);

var PpsTV=Class.create();
repeater=new Base();
repeater.extend({
	data : {
		domain: 'pps.tv',
		id: 'myDynamicContent',
		swfMark: '<embed data-widget-player="flash" pluginspage="http://www.macromedia.com/go/getflashplayer" loop="true" play="true" quality="hight" devicefont="false" allowfullscreen="true" menu="true" type="application/x-shockwave-flash" width="100%" height="100%" src="http://www.iqiyi.com/common/flashplayer/20150311/MainPlayer_5_2_19_3_c3_2_4.swf" id="flash" bgcolor="#000000" wmode="transparent"  flashvars="components=feffbfe6e0&tvId={0}&autoplay=true&flashP2PCoreUrl=http://www.iqiyi.com/common/flashplayer/20150216/30032.swf&cid=qc_100001_100141&origin=true&outsite=false&definitionID={1}" align="middle" hint="true" allowscriptaccess="always" Scale="NoScale">'
	},
	getParams:function(){
		if (!this.getFlashvar('tvId'))
			this.params.push('');
		if (!this.getFlashvar('definitionID'))
			this.getFlashvar('vid');
	}
});
PpsTV.prototype=repeater;
router.register('pps.tv', PpsTV);

router.run();
})();