HTML5 Player on animespirit.ru with myvi.ru

HTML5 Player on animespirit.ru with myvi.ru. Показывает видео встроенное с myvi.ru без Flash плеера.

目前为 2015-11-07 提交的版本。查看 最新版本

// ==UserScript==
// @name	HTML5 Player on animespirit.ru with myvi.ru
// @version	0.2.4
// @author	Anonimous
// @namespace	https://gf.qytechs.cn/en/users/16081-lolipop/HTML5animespirit
// @description	HTML5 Player on animespirit.ru with myvi.ru. Показывает видео встроенное с myvi.ru без Flash плеера.
// @include	/^https?\:\/\/(www\.)?animespirit\.ru($|\/.*$)/
// @license      GPL version 3 or any later version; www.gnu.org/licenses/gpl-3.0.en.html
// @grant	none
// @run-at	document-end
// ==/UserScript==

/*
 * documentation:
 * https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
 * https://msdn.microsoft.com/ru-ru/library/dn265034%28v=vs.85%29.aspx
 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of
 * https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Statements/let
 * https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/String/replace
 */

!(function(){

	const flashPreLink = 'http://myvi.ru/player/flash';
	const html5PreLink = 'http://myvi.ru/player/embed/html';
	const target = document.body;
	const config = {
		childList : true,
		attributes : true,
		characterData : true,
		subtree : true
	};
	const videoType = 'application/mpeg';
	const videoTagName = 'object';
	const videoLinkAttrName = 'data';

	let observer = new MutationObserver(function(mutations) {
		
		for (let mutation of mutations) {
			if (mutation.type === 'childList') {
				replaceByHTML5(mutation.addedNodes);
			}
		}

	});

	function replaceByHTML5(arr) {
		
		for (let el of arr) {
			let objs = el.getElementsByTagName(videoTagName);
			
			for (let obj of objs) {
				if(obj.hasAttribute(videoLinkAttrName)
					 && isVideoLink(obj.data)) {
					
					obj.type = videoType;
					obj.data = (obj.data).replace(flashPreLink, html5PreLink);
				}
			}
		}
	}
				 
	function isVideoLink(data) {
		let linkRegExp = /^https?\:\/\/(www\.)?myvi\.ru\/player\/flash.*/i;
		let isLink = linkRegExp.test(data);
		
		return isLink;
	}

	/*
	 * running
	 */
	observer.observe(target, config);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址