HTML5 Player on animespirit.ru with myvi.ru

HTML5 Player on animespirit.ru with myvi.ru Видео на animespirit.ru можно будет смотреть без Flash Player

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

// ==UserScript==
// @name	HTML5 Player on animespirit.ru with myvi.ru
// @version	0.1
// @author	Anonimous
// @namespace	https://gf.qytechs.cn/en/users/16081-lolipop/HTML5animespirit
// @description	HTML5 Player on animespirit.ru with myvi.ru Видео на animespirit.ru можно будет смотреть без Flash Player 
// @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
// @description:ru
// ==/UserScript==


window.addEventListener('load', function(){
	console.log('begin');
	
	let flashPreLink = 'http://myvi.ru/player/flash/';
	let html5PreLink = 'http://myvi.ru/player/embed/html/';
	let standbyClassName = 'myHTML5StandbyClassLolipop';
	
	function swapLink(text, oldStr, newStr) {
		console.log('change link');
		return text.replace(oldStr, newStr);
	}
	
	function getVideoBlock() {
		return document.querySelectorAll('[id^=an] > object > object');
	}
	
	function notifycation() {
		let notify = document.createElement('div');
		
		notify.style.height = '20px';
		notify.style.width = '100%';
		notify.style.position = 'fixed';
		notify.style.bottom = '0px';
		notify.style.fontWeight = 900;
		notify.style.backgroundColor = 'black';
		notify.style.color = 'white';
		notify.style.zIndex = 999;
		
		notify.innerHTML = 'HTML5 video script is working. Please, wait while page is loading. Click for close.' + 
												' Скрипт для HTML5 видео заработает только когда страница полностью загрузится. Кликни на меня чтобы закрыть.';
		
		notify.onclick = function removeNotify() {
			notify.parentNode.removeChild(notify);
		};
		
		document.body.appendChild(notify);
	}
	
	function createStandby(standbyClass) {
		console.log('begin createStandby');
		
		let stnd = document.createElement('div');
		let videosArr = getVideoBlock();
		
		stnd.style.width = videosArr.width;
		stnd.style.height = videosArr.height;
		stnd.style.backgroundColor = 'black';
		stnd.style.color = 'white';
		stnd.style.fontWeight = 900;
		stnd.classList.add(standbyClass);
		
		stnd.innerHTML = 'Wait. Loading';
		
		return stnd;
	}
	
	function removeStandby(className) {
		console.log('begin removeStandby');
		
    let elements = document.getElementsByClassName(className);
		
		for (val of elements) {
			val.parentNode.removeChild(val);
		}
		
		let videosArr = getVideoBlock();
		
		val.hidden = false;
		for (val of elements) {
			val.hidden = false;
		}
		
	}
	
	function addStandbyBlock() {
		console.log('begin addStandbyBlock');
		let videosArr = getVideoBlock();
		
		for (val of videosArr) {
			val.hidden = true;
			val.parentElement.appendChild(createStandby(standbyClassName));
		}
		
	}
	
	function doHtml5Video() {
		console.log('begin doHtml5Video');
		let videosArr = getVideoBlock();
		
		console.log('first element ' + videosArr[0].innerHTML);
		
		for (val of videosArr) {
			val.hidden = false;
			val.data = swapLink(val.data, flashPreLink, html5PreLink);
			console.log('video link ' + val.data);
			val.type = 'application/mpeg';
		}

	}

	let oldUpAnime = window['upAnime'];
	
	window['upAnime'] = function (num) {
		console.log('upAnime');
		
		oldUpAnime(num);
		addStandbyBlock();
		
		setTimeout(function() {
			removeStandby(standbyClassName);
			doHtml5Video();
		}, 5000);
	}
	
	notifycation();
	
});

QingJ © 2025

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