Greasy Fork

Greasy Fork is available in English.

vipVideos_skipAd

优酷、土豆VIP免费看,去iqiyi.com、pps.tv视频广告

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

您需要先安装一款用户脚本管理器扩展,例如 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免费看,去iqiyi.com、pps.tv视频广告
// @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
// @license        GPL version 3
// @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/*
// @include        http://tv.sohu.com/*
// @include        http://*.tv.sohu.com/*
// @version        1.3.5
// @encoding       utf-8
// @modified       2015.03.18
// @run-at         document-end
// @grant          none
// ==/UserScript==

(function() {
function $(css){
	return document.querySelector(css);
}
function Overload(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, key) {
			return params[~~key];
		});
	},
	"object" : function (param) {
		var reg = /{([^{}]+)}/gm;
		return this.replace(reg, function (match, key) {
			return param[key];
		});
	}
});
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();//new Function(handler)
			console.log('handler proc():', o);
			o.proc();
		}, 99);
	  }
	},

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

/*定义基类Base*/
function Base() {
	//这里放置final、静态方法,不在原型链上
	this.clearSelectTags = function(css){
		var c = document.querySelectorAll(css);
		if (!c) return;
		Array.prototype.forEach.call(c, function(t){
			t.parentNode.removeChild(t);
		});
	};

	this.argName = 'flashvars';
	this.params = {};
}
Base.prototype={
	extend: function(obj){
		for(var i in obj){
			this[i]=obj[i];
		}
	},
	putVar: function(vName, pn) {
		var s = new RegExp(vName +'=([^&]+)');//,'i'
		s = this.flashvars.match(s);
		s = s ? s[1] : '';
		if (1 === arguments.length) return s;
		this.params[pn] = s;
		return this;//方便用链式语法
	},
	isProc : function() {
		return true;
	},
	getFlashvars : function() {
		// var r, s = this.player.innerHTML;
		// r = s.match(/name="flashvars"\s+value="([^"]+)"/i);
		// if (!r) r = s.match(/value="([^"]+)"\s+name="flashvars"/i);
		// if (r && r.length === 3)
		//	 this.flashvars = unescape(r[1]).replace(/&amp;/g,'&');
		this.flashvars = this.player.children[this.argName].value;
		console.log(this.argName, this.flashvars);
	},
	rebuildSwf : function() {
		this.player.outerHTML = this.swfMark.format(this.params);
	},
	proc : function() {
		this.player = $(this.swfCSS);
		console.log('get player: ', this.player);
		if (!this.player) return;
		this.getFlashvars();

		if (!this.flashvars || !this.isProc()) return;
		this.getParams();
		console.log('getParams(): ', this.params);
		this.rebuildSwf();
		this.clearSelectTags('script');
	}
};

/*定义子类Youku*/
function Youku() {
	Base.call(this);
	this.swfMark = '<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.buguanji.com/Public/Home/player/20141007/player.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={vid}&isAutoPlay=true&winType=BDskin&Type=PlayList">';
	this.swfCSS = '#movie_player';
}
var repeater=new Base();
repeater.extend({
	getParams:function(){
		if (!this.putVar('VideoIDS', 'vid').params.vid)
			throw new Error('param error!');
	}
});
Youku.prototype=repeater;
router.register('youku.com', Youku);

function Tudou() {
	Base.call(this);
	//http://100.100.100.100/buguanji.swf
	this.swfCSS = '#tudouHomePlayer';
	this.swfMark = '<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.buguanji.com/Public/Home/player/20141007/player.swf" width="100%" height="100%" id="tudouHomePlayer" name="tudouHomePlayer" bgcolor="#000" isfullscreen="true" allowfullscreen="true" allowscriptaccess="always" wmode="transparent" flashvars="isShowRelatedVideo=false&showAd=0&show_ce=0&showsearch=0&VideoIDS={vid}&isAutoPlay=true&winType=BDskin&Type=PlayList">';
}
repeater=new Base();
repeater.extend({
	isProc:function(){
		//有播放时间限制即进行处理
		return /paidTime=\d{2,}&/.test(this.flashvars);
	},
	getParams:function(){
		if (!this.putVar('vcode','vid').params.vid)
			throw new Error('param error!');
	}
});
Tudou.prototype=repeater;
router.register('tudou.com', Tudou);

function Iqiyi() {
	Base.call(this);
	this.swfCSS = '#flash';
	this.swfMark = '<embed data-widget-player="flash" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" quality="hight" devicefont="false" allowfullscreen="true" menu="true" type="application/x-shockwave-flash" width="100%" height="100%" id="flash" bgcolor="#000" wmode="transparent" align="middle" allowscriptaccess="always" src="{src}" flashvars="components=feffbfe6e0&tvId={tvId}&autoplay=true&flashP2PCoreUrl={p2p}&cid=qc_100001_100141&origin=true&outsite=false&definitionID={did}">';
	this.argName = 'flashVars';
}
repeater=new Base();
repeater.extend({
/* 	isProc:function(){
		console.info($("a.link_pay"));
		//return $("style#797082642689");
		return !$("div.vdoRel");
	}, */
	getParams:function(){
		this.params.src = 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); */
		this.putVar('tvId','tvId')
			.putVar('flashP2PCoreUrl','p2p');
		var s = this.putVar('definitionID');
		if (!s && !(s = this.putVar('vid')))
			throw new Error('param little!');
		this.params.did = s;
	}
});
Iqiyi.prototype=repeater;
router.register('iqiyi.com', Iqiyi);

function PpsTV() {
	Base.call(this);
	this.swfCSS = 'div.flash-player > object';
	this.swfMark = '<embed data-widget-player="flash" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" quality="hight" devicefont="false" allowfullscreen="true" menu="true" type="application/x-shockwave-flash" width="100%" height="100%" align="middle" allowscriptaccess="always" 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={tvId}&autoplay=true&flashP2PCoreUrl=http://www.iqiyi.com/common/flashplayer/20150216/30032.swf&cid=qc_100001_100141&origin=true&outsite=false&definitionID={did}">';
}
repeater=new Base();
repeater.extend({
	getParams:function(){
		var s = this.putVar('tvId','tvId').putVar('definitionID');
		if (!s && !(s = this.putVar('vid')))
			throw new Error('param little!');
		this.params.did = s;
	},
	proc : function() {
		//Base.prototype.proc.apply(this, arguments);
		//等待播放器DOM构造完成后,即调用父类方法
		var me = this,
		timer = setInterval(function(){
			if ($(me.swfCSS)) {
				clearInterval(timer);
				Base.prototype.proc.call(me);
			}
		}, 100);
	}
});
PpsTV.prototype=repeater;
router.register('pps.tv', PpsTV);

function Sohu() {}
repeater=new Base();
repeater.extend({
	proc : function() {
		var p = $('embed#player');
		if (!p) return;
		console.log('get player: ', p);
		var s = p.getAttribute('flashvars');
		s = s.replace(/sid=[^&]+/,'sid=0')
			.replace(/api_key=[^&]+/,'api_key=647bfb88a84fc3c469d289f961993be6')
			.replace(/&plid=[^&]+/,'');
		s = 'flashvars="'+ s + '&plid=7038006"';
		p.outerHTML = p.outerHTML
			.replace(/flashvars="([^"]+)"/, s);
		this.clearSelectTags('script');
/* 		var s = this.putVar('vid');
		if (!s) s = this.putVar('id');
		if (s) {
			//var s, d = new Date();
			//d = d.toISOString().slice(0, 9).replace(/-/g, '');yyyyMMdd日期格式
			//s = 'http://tv.sohu.com/upload/swf/{0}/Main.swf';
			//s = s.format([d]);
			//this.params.push(s);
			this.params.vid = s;
			console.log('getParams: ', this.params);
			var s = '<embed id="player" allowfullscreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="100%" height="100%" src="{src}" quality="high" bgcolor="#000" allowscriptaccess="always" flashvars="&vid={vid}&plid=7038006&changeRateBtn=1&jump=0&skin=0&likeBtn=0&autoplay=true&downloadBtn=0&cinemaBtn=0&bfBtn=0&shareBtn=0&sogouBtn=0&showRecommend=0&showCtrlBar=1&skinNum=1&ua=http://tv.&api_key=647bfb88a84fc3c469d289f961993be6&cmscat=1&topBarFull=1&imgCutBtn=0&sid=null&isListPlay=1&playListId=1&nid=1&pid=1&pageurl=http://www.sohu.com"></embed>';
			this.player.outerHTML = s.format(this.params);
			console.log("finish! Now flash player is modified!", this);
			this.clearSelectTags('script');
		} */
	}
});
Sohu.prototype=repeater;
router.register('sohu.com', Sohu);

router.run();
})();