// ==UserScript==
// @name yahvt
// @description yet another html5 video tool
// @namespace gnblizz
// @version 1.16
// @include http://anilinkz.io/*
// @include http://www.animecenter.tv/*
// @include http://www.animedreaming.tv/*
// @include http://anime-exceed.com/*
// @include http://www.animefreak.tv/*
// @include http://www.animehere.com/*
// @include http://www.animenova.org/*
// @include http://www.animeplus.tv/*
// @include http://www.animeseason.com/*
// @include http://www.animesky.net/*
// @include http://as.animes-stream24.tv/*
// @include http://www.anime-sub.co/*
// @include http://www.animetoon.org/*
// @include http://www.animeultima.io/*
// @include http://www.animewow.org/*
// @include http://bestanimes.tv/*
// @include http://www.chia-anime.tv/*
// @include http://www.clipfish.de/*
// @include http://dramago.com/*
// @include http://www.dramago.com/*
// @include http://www.dramagalaxy.tv/*
// @include http://dubbedanime.net/*
// @include http://www.dubzonline.ca/*
// @include http://freeanime.com/*
// @include http://www.gogoanime.to/*
// @include http://www.goodanime.co/*
// @include http://www.gooddrama.to/*
// @include http://www.lovemyanime.net/*
// @include http://www.videozoo.me/*
// @include about:blank?video=*
// @include h*embed*
// @include h*gogo/*
// @include h*widget/*
// @match http://*.mangaotaku.org/*
// @include http://player.arkvid.tv/*
// @include http://www.dramastream.org/*
// @exclude https://openload.co/embed/*
// @exclude https://apis.google.com/*
// @run-at document-start
// @grant GM_xmlhttpRequest
// @icon data:image/gif;base64,R0lGODlhMAAwAKECAAAAAICAgP///////yH5BAEKAAMALAAAAAAwADAAAALQnI+py+0Po5y02ouz3rz7D4biBJTmiabqyrbuC8fyHAf2jedpzuOvAAwKh6mhUfg7Hks3gHLpehptwIBTioxig0zrdStIgrslMFA8pCKp1oAZjXW6w/Mt/Nl2t8HeFl7o5QZgBagEYyawNxhUl7h4dlelFlZG+QVY6aglmIjjuKd50xla9RKI0mSCqaPJSMM0aEK4mhfbpSnTabM4WXrShtpHI6gqKvmKnCwns0tm2lOsLP3aUy08aK0zvc3d7b09Ei4+Tl5ufo6err7O3n5QAAA7
// @compatible firefox
// @compatible chrome
// @downloadURL none
// ==/UserScript==
"use strict";
var doc=document, isTop=window.self==window.top, domain = (document.domain||'unknown.').split('.').reverse(), insertionPoint, isFF = /Firefox/i.test(navigator.userAgent), maxmsg=99;
document.addEventListener('DOMContentLoaded', yahvt);
!function earlyHacks(){
switch(domain[1]) {
case 'clipfish'://.de
if(isFF) nn('SCRIPT', doc.body).innerHTML = 'checkMobile=function(){isMobile=true;}';
else Object.defineProperty(navigator, "userAgent", {value: 'fake Android'});
break;
}
}();
function sites(){
var a,i,o,e,b;
//console.log('yahvt: domain =', domain);
switch(domain[1]) {
case 'anilinkz'://.tv => io
SetStyle('#waifu,body>div:empty[style*="z-index: 2147483647;"]{display:none;}');
//SetStyle('div[style*="position"]{background-color:green;opacity:0.6;}');
allowFullscreen('#player');
setTimeout(function () {
var i = setInterval(function () {}, 999);
do { clearInterval(i); } while(--i);
i = setTimeout(function () {}, 999);
do { clearTimeout(i); } while(--i);
}, 45000);
break;
case 'animecenter'://.tv
allowFullscreen('#video');
break;
case 'animedreaming'://.tv
allowFullscreen('.videoholder');
break;
case 'anime-exceed'://.com
allowFullscreen('#player', (/^\/cool\//.test(location.pathname)?'':'body'),0,999);
break;
case 'animefreak'://.tv
a=na('.multi'); for(o of a) {
e = o.getAttribute('onclick');
if(e && /loadParts\('http/.test(e))
o.onclick = function(event) {
var vid_file = decodeURIComponent(this.getAttribute('onclick').match(/loadParts\('([^']+)'/)[1]);
doc.getElementById("player").innerHTML = '';
};
}
break;
case 'animehere'://.com => error!
allowFullscreen('#playbox');
break;
case 'animenova'://.tv => org
case 'animeplus'://.tv
case 'animesky'://.net => error!
case 'animetoon'://.tv => org
case 'animewow'://.eu => org
case 'dramagalaxy'://.eu,com => tv
case 'dramago'://.com
case 'gooddrama'://.net => to
allowFullscreen('#streams');
break;
case 'animeseason'://.com
if(fn('#series_info'))
SetStyle('table a:visited{color:gray;}table a:hover{color:#FC0;}');
allowFullscreen('#video_source', 0, '#player_list A');
break;
case 'dramastream'://.org => error!
allowFullscreen('div[align]', 'center');
break;
case 'anime-sub'://.com => co
allowFullscreen('#movie-content');
break;
case 'animeultima'://.tv => io
allowFullscreen('#pembed');
break;
case 'bestanimes'://.tv
allowFullscreen('.post');
break;
case 'freeanime'://.com
nn('SCRIPT', doc.body).innerHTML = '$(window).unbind();\n$("#header").css("background-attachment","scroll")';
allowFullscreen('.z-video', 0, 'ul.z-tabs-nav LI', 999);
break;
case 'goodanime'://.net => co
case 'videozoo'://.me
allowFullscreen('#content');
case 'dubzonline'://.com => ca
return(location.pathname == '/embed.php');
case 'lovemyanime'://.net
//allowFullscreen('.player-area');
break;
case 'animes-stream24'://.net => .tv
allowFullscreen('#main');
break;
case 'gogoanime'://.com => .to
return location.pathname=='/flowplayer/' || allowFullscreen('#content');
case 'arkvid'://.tv
return domain[2]=='player';
case 'mangaotaku': // => error! // animeboy,dramastream
return 1;// return(location.pathname == '/dr_video_player.php');
case 'unknown'://about:blank?video="..."
if(/^about:blank\?video=/.test(location.href))
return nn('SCRIPT', doc.body).textContent = '("'+location.href.slice(18)+'")';
break;
default:
return(/(embed\b|\/gogo\/|\/widget\/)/.test(doc.URL));
}
function allowFullscreen(selTop, selFrame, mirrors, delay) {
if(delay)
window.setTimeout( function() { allowFullscreen(selTop, selFrame, mirrors); }, delay);
else {
var a,i;
if(isTop) {
if(mirrors) {
a = doc.querySelectorAll(mirrors);
for(i of a) {
i.addEventListener('click', function() {
window.setTimeout( function() { doc.querySelector(selTop+' IFRAME').setAttribute('allowfullscreen', 'true'); }, 99);
});
}
}
a = doc.querySelectorAll(selTop+' IFRAME');
if(!a.length) console.log('yahvt: couldn\'t apply fullscreen attribute because '+selTop+' IFRAME not found in '+doc.URL);
for(i of a) { i.setAttribute('allowfullscreen', 'true'); }
} else if(selFrame) {
a = doc.querySelectorAll(selFrame+' IFRAME');
for(i of a) { i.setAttribute('allowfullscreen', 'true'); }
}
}
}}
// FULL SCREEN API
//requires about:config full-screen-api.allow-trusted-requests-only=false
function SetFullScreenMode(v) {
(v.requestFullscreen||v.mozRequestFullScreen||v.webkitRequestFullscreen||v.webkitEnterFullscreen).call(v);
//console.info('To allow full screen mode, you may want to set full-screen-api.allow-trusted-requests-only to false in about:config.');
}
function FullScreenElement() {
if(doc.exitFullscreen) return doc.fullscreenElement;
if(doc.mozCancelFullScreen) return doc.mozFullScreenElement;
if(doc.webkitExitFullscreen) return doc.webkitFullscreenElement;
}
function EndFullScreenMode() {
if(!FullScreenElement()) return false;
(doc.exitFullscreen||doc.mozCancelFullScreen||doc.webkitExitFullscreen).call(doc);
return true;
}
function OnFullScreenChange(fn) {
if(doc.exitFullscreen) doc.addEventListener("fullscreenchange", fn);
if(doc.mozCancelFullScreen) doc.addEventListener("mozfullscreenchange", fn);
if(doc.webkitExitFullscreen) doc.addEventListener("webkitfullscreenchange", fn);
}
function SetFocus(v) {
if(!v) v = fn('VIDEO');
v.focus();
if(!isFF) setTimeout(function(){ v.focus(); }, 0); // same old chrome bug
}
// new node
function nn(name, parent) {
var a = name.split(/,(?! )/); name = a.shift();
var node = doc.createElement(name.match(/^\w+/)[0]),
m = name.match(/#\w+/); if(m) node.id = m[0].slice(1);
m = name.match(/\.\w+/); if(m) node.className = m[0].slice(1);
while(a.length) {
var t = a.shift(), l = t.indexOf('=');
switch(l) {
case -1:
node.setAttribute(t, t);
break;
case 0:
node.textContent = t.slice(1);
break;
case 1:
if(t.charAt(0) == '?') {
node.innerHTML = t.slice(2);
break;
}
default:
node.setAttribute(t.slice(0, l), t.slice(l+1));
}
};
if(parent) parent.appendChild(node);
return node;
}
// find node
function fn(name, parent) {
if(!parent) parent = doc;
switch(name.charAt(0)) {
case '#':
return parent.getElementById(name.slice(1));
case '.':
return parent.getElementsByClassName(name.slice(1))[0];
}
return parent.getElementsByTagName(name)[0];
}
// find nodes array
function na(name, parent) {
if(!parent) parent = doc;
return (name.charAt(0)=='.') ? parent.getElementsByClassName(name.slice(1)) : parent.getElementsByTagName(name);
}
// remove node
function rn(node) {
if(typeof(node)=='string') node = fn(node);
if(node) return node.parentNode.removeChild(node);
}
function domainName(href) {
if(!href) href = location.href;
var m = href.match(/\:\/\/(?:www\.|embed\.)?([^\/]+)/);
if(m) return m[1];
return 'unknown';
}
function Remember(name, value) {
try {
if(sessionStorage) switch(value) {
case '':
sessionStorage.removeItem(name);
break;
case undefined:
value = 'yes';
default:
sessionStorage.setItem(name, value);
}
}catch(e){}
}
function remembered(name, forget) {
try {
var x = sessionStorage.getItem(name);
if(forget) sessionStorage.removeItem(name);
return x;
} catch(e) {
if(name=='autoplay' && (domain[1]=='unknown' || /\bnoflash\b/.test(location.search) || /(part|clip)_?0?[2-9]/.test(location.pathname))) return 'yes';
}
}
// style
function SetStyle(style) {
var st = nn('STYLE', doc.head);
st.innerHTML = style;
return st;
}
function MakeCSSString(name, def) {
var names = Object.getOwnPropertyNames(def), style = (names.indexOf('top') < 0 ? '' : 'position:absolute;' ), x, value;
for(x of names) {
value = def[x];
if(typeof(value) == 'number' && x != 'z_index') value += 'px';
style += x.replace(/_/g,'-') + ': ' + value + '; ';
}
return name + '{' + style + '}\n';
}
//*/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////*/
function findVideoFiles() {
function getScript(o) {
s = o.innerHTML;
if(s.length) {
var m = s.match(/^eval(\(function\(p(?:,[a-ek]){5}\).+\bsplit\b.+)$/m), timer;
if(m) {
try { s += eval(m[1]); console.log('yahvt: Packed script detected.'); } catch(e) { console.log('yahvt: Packed script parse error.'); }
}
s = unescape(s.replace(/\s\/\/.*$/gm,'').replace(/\s+/gm,' ').replace(/\/\*.*\*\//g,'').replace(/'/g,'"'));
if(domain[1]=='dailymotion') s = s.replace(/\\\//g, '/');
return s;
}
}
function add(m) { if(m && v.indexOf(m)<0) v.push(m); }
function addm1(m) { if(m && v.indexOf(m[1])<0) v.push(m[1]); }
function find(pattern) {
var g = /g/.test(pattern.flags);
do {
var m = pattern.exec(s);
if(!m) break;
try {
add(decodeURIComponent(unescape(m[1])));
} catch(e) {
add(m[1]);
}
} while(g);
}
//findVideoFiles() {
var v = [], s, m, a, i, p;
a = fn('VIDEO', doc.body);
if(a) {//usually doesn't exist yet
add(a.getAttribute('src'));
a = na('SOURCE', a);
for(i of a) {
add(i.getAttribute('src'));
}
}
a = na('SCRIPT', (domain[1]=='videozoo' ? doc.documentElement : doc.body)); for(i of a) {
if(getScript(i)) {
find(/"(https?:\/\/[^"]+\.(?:mp4|flv)\b[^"]*)"/gi);
find(/"(.+\.php\b.+\.(?:mp4|flv))"/gi);
find(/"([^"]+\bpicasa\.php\b[^"]+)"/gi);
find(/"(https\:\/\/[^"]*\.google(?:video\.com\/videoplayback|usercontent.com\/)[^"]+)"/gi);
}
}
switch(domain[1]) {
case 'trollvid'://.net// Is this of any use today? TODO obsolete?
for(i of a) {
s = i.innerHTML; m = s.match(/['"](http.+?data.*?file.*?)['"]/i); addm1(m);
}
a = na('SCRIPT', doc.head); for(i of a) {
m = i.innerHTML.match(/unescape\(atob\('(.+?)'/);
if(m) { m = unescape(atob(m[1])); if(/\.(mp4|flv)/i.test(m)) add(m); }
}
break;
case 'videobam'://.com// Is this of any use today?
for(i of a) {
s = i.innerHTML; m = s.match(/['"](http:\\\/\\\/[^'"]+\.(?:mp4|flv)\b[^'"]*)['"]/i); if(m) add(m[1].replace(/\\\//g,'/'));
}
case 'yourupload'://.com// experimental
try {
s = fn('#player').nextElementSibling.textContent;
m = s.match(/'(\/play\/\d+\.flv\?.+?)'/);if(m) add(m[1]);
}catch(e){ console.log(e); }
case 'test':
}
try {// even if it looks wierd...
m = doc.querySelector('#flowplayer+script').innerHTML.replace(/\s+/g, ' ').match(/\/\* playlist\: \[ \{ url\: '(.*)'/)[1];
if(!/\<|\>/.test(m)) {
console.log('yahvt: html5_path in comment found.');
add(m);
}
} catch(e){}
try {// animeboy
add(unescape(fn('NOSCRIPT').innerHTML.match(/pixel format: ' + v.videoWidth + 'x' + v.videoHeight
+ '
duration: ' + Math.floor(t/60) + ':' + ('0' + Math.floor(t%60)).slice(-2);
} else div.style.color = '#666';
m = src.match(/https?:\/\/([^:?/]+)/);
if(m) txt += '
video host name: ' + m[1];
m = src.match(/.*\/([^?/]*)/);
if(m) txt += '
video file name: ' + m[1];
txt += '
A - toggle stretch mode
F - toggle full screen mode
I - '+(meta ? 'this info
Q - quick viewing
S - slow motion' : 'some info')+'
Z - toggle zoom to 100%';
if(meta) {
adr.push('@web.de?subject=yahvt%20at%20', document.domain);
txt += '
yahvt is public domain by gnblizz.';
}
div.innerHTML = txt;
v.parentNode.appendChild(div);
window.setTimeout(StopInfo, 15000);
}
function StopInfo() {
if(!v.paused || v.currentTime < 5) return rn(p.querySelector('div.info,div.info2'));
var div = p.querySelector('div.info');
if(div) nn('SMALL,?=
If there are issues regarding yahvt, someone has to complain.
Therefore, the two links above.', div);
}
function NextPart(name) {
var m = name.match(/^(.*(?:part|clip)_?0?)(\d+)(.*)$/), i;
if(m)
return {now: i = parseInt(m[2]), next: ++i, URL: m[1]+i+m.pop()};
else {
m = name.match(/^(.*%26sp%3D)a(%26episode%3D\d+)A(%26.*)$/);//animeboy,mangaotaku
if(m)
return {now: 'A', next: 'B', URL: m[1]+'b'+m[2]+'B'+m.pop()};
}
}
function StartStop() {
if(v.paused) v.play();
else v.pause();
}
function TestResource(url, btn) {
var req = new XMLHttpRequest();
try {
if(req) {
req.open('HEAD', url, true);
req.onloadend = function () {
switch(req.status) {
case 200:
if(req.statusText != 'Not Found')
btn.click();
case 404:
rn(btn);
}
};
req.send();
}
}catch(e){ console.log('yahvt:', e, url, req); }
}
//insertVideo() {
var nvp = NextPart(doc.URL), txt = '';
if(fn('#flowplayer')) txt += '
Video '+((/(part|clip)_?\d/.test(av[0]+doc.URL)) ? 'part ' : '')+'found at ' + domainName(doc.URL) + '.
Video not found.
'; break; } } } } } catch(e) { console.log('yahvt:', e); } } function receiveMessage(event) { function RestoreFormat() { var frame = fn('#yahvt_currentview'); if(frame) frame.removeAttribute(id); rn('#yahvt_fmtbtn'); rn('#yahvt_dimmer'); rn('#yahvt_topstyle'); } function InsertButton() { var spn, btn; try { switch(domain[1]) { case 'animecenter': case 'freeanime': return nn('BUTTON#yahvt_fmtbtn,type=button,title=video width,style=float:left;,='+x, fn('.rating_div')); case 'anilinkz': spn = fn('#watchmode').parentNode; btn = nn('BUTTON#yahvt_fmtbtn,type=button,title=video width,style=float:right;margin:12px 12px 0px 0px;,='+x); spn.parentNode.insertBefore(btn, spn); return btn; case 'animeseason': spn = fn('#video_views'); btn = nn('DIV#yahvt_fmtbtn,style=background:url(/images/video_icons.png) -171px 0 no-repeat;width:57px;height:55px;margin-right:55px;line-height:55px;cursor:pointer;,title=video width,?='+x); spn.parentNode.insertBefore(btn, spn); return btn; } } catch(e) { console.log(e); } spn = nn('SPAN,style=position:relative;'); btn = nn('BUTTON#yahvt_fmtbtn,type=button,title=video width,style=position:absolute;top:-21px;left:1px;,='+x, spn); m.insertBefore(spn, frame.nextSibling); return btn; } try { //console.log('yahvt: received message', event); if(typeof event.data != 'string') return; switch(event.data.slice(0,11)) { case 'videoformat': var m = event.data.match(/(\d+)x(\d+)$/), x = parseInt(m[1]), y = parseInt(m[2])+(isFF ? 56 : 64), frame, frames = na('IFRAME'), txt, id, stl, zi=100000; RestoreFormat(); for(m of frames) { if(m.contentWindow === event.source) { frame = m; break; } } //console.log('yahvt: detected frame:', frame); if(!frame) switch(domain[1]) { case 'anime-exceed': frame = doc.querySelector('#player>iframe'); break; default: return; } m = frame.parentNode; if(!m.id) m.id = 'yahvt_currentview'; id = '#' + m.id; txt = MakeCSSString('html,body', { width: '100%', height: '100%', overflow: 'hidden'}) + MakeCSSString(id, { width: frame.clientWidth, height: frame.clientHeight, min_height: frame.clientHeight}) + MakeCSSString(id+(isFF ? '>iframe' : '>iframe:not(:-webkit-full-screen)'), { border: '0px !important', position: 'fixed', width: x+'px!important', height: y+'px!important', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', margin: '0 auto', max_width: '100%', max_height: '100%', z_index: zi}); txt += MakeCSSString('#yahvt_fmtbtn', {display: 'none' }); txt += MakeCSSString('#yahvt_dimmer>div', { background_color: 'black', opacity: '.85'}) + MakeCSSString('#yahvt_dimmer>.topshade', { position: 'fixed', width: '100%', height: 'calc(50% - '+y/2+'px)', top: 0, left: 0, z_index: zi}) + MakeCSSString('#yahvt_dimmer>.bottomshade', { position: 'fixed', width: '100%', height: 'calc(50% - '+y/2+'px)', bottom: 0, left: 0, z_index: zi}) + MakeCSSString('#yahvt_dimmer>.leftshade', { position: 'fixed', width: 'calc(50% - '+x/2+'px)', height: y, top: 'calc(50% - '+y/2+'px)', left: 0, z_index: zi}) + MakeCSSString('#yahvt_dimmer>.rightshade', { position: 'fixed', width: 'calc(50% - '+x/2+'px)', height: y, top: 'calc(50% - '+y/2+'px)', right: 0, z_index: zi}); InsertButton().onclick = function() { stl.disabled = false; }; stl = SetStyle(txt); stl.id = 'yahvt_topstyle'; m = nn('DIV#yahvt_dimmer', m); nn('div.topshade', m); nn('div.bottomshade', m); nn('div.leftshade', m); nn('div.rightshade', m); m.onclick = function() { stl.disabled = true; }; break; case 'videoended': RestoreFormat(); break; } } catch(e){ console.log(e); } } if(isTop && !/^(anime-exceed|animefreak|anime-sub|bestanimes|clipfish)$/.test(domain[1])) window.addEventListener('message', receiveMessage, false); // public domain by gnblizz // contact me with my username + '@web.de'