video tabs

tabbed video sources on certain drama and anime sites

  1. // ==UserScript==
  2. // @name video tabs
  3. // @namespace gnblizz
  4. // @description tabbed video sources on certain drama and anime sites
  5. // @version 1.08
  6. // @include http://www.animehere.com/*
  7. // @include http://www.animenova.org/*
  8. // @include http://www.animenova.tv/*
  9. // @include http://www.animeplus.tv/*
  10. // @include http://www.animesky.net/*
  11. // @include http://www.animetoon.eu/*
  12. // @include http://www.animetoon.org/*
  13. // @include http://www.animetoon.tv/*
  14. // @include http://animewow.eu/*
  15. // @include http://www.animewow.eu/*
  16. // @include http://www.animewow.org/*
  17. // @include http://dramago.com/*
  18. // @include http://www.dramago.com/*
  19. // @include http://www.dramagalaxy.com/*
  20. // @include http://www.dramagalaxy.eu/*
  21. // @include http://www.dramagalaxy.tv/*
  22. // @include http://www.gogoanime.com/*
  23. // @include http://www.gogoanime.to/*
  24. // @include http://www.goodanime.co/*
  25. // @include http://www.goodanime.eu/*
  26. // @include http://www.goodanime.net/*
  27. // @include http://www.gooddrama.net/*
  28. // @include http://gooddrama.to/*
  29. // @include http://www.gooddrama.to/*
  30. // @noframes
  31. // @run-at document-start
  32. // @grant none
  33. // @compatible firefox
  34. // @compatible chrome
  35. // @icon data:image/gif;base64,R0lGODlhMAAwAKECAAAAAICAgP///////yH5BAEKAAMALAAAAAAwADAAAALQnI+py+0Po5y02ouz3rz7D4biBJTmiabqyrbuC8fyHAf2jedpzuOvAAwKh6mhUfg7Hks3gHLpehptwIBTioxig0zrdStIgrslMFA8pCKp1oAZjXW6w/Mt/Nl2t8HeFl7o5QZgBagEYyawNxhUl7h4dlelFlZG+QVY6aglmIjjuKd50xla9RKI0mSCqaPJSMM0aEK4mhfbpSnTabM4WXrShtpHI6gqKvmKnCwns0tm2lOsLP3aUy08aK0zvc3d7b09Ei4+Tl5ufo6err7O3n5QAAA7
  36. // ==/UserScript==
  37. "use strict";
  38. var domain = document.domain.match(/(\w+)\.\w+$/)[1], darkTheme;
  39.  
  40. function TabSites() {
  41. switch(domain) {
  42. case 'gooddrama':
  43. return MakeTabs('html,body,#body,#header,#top_block,.info_block,.note span,#eps_blocks,#downloads_heading,#comments_heading,.reply,.info_box{color:#888;background-color:#111;height:auto}table[width="790"],#eps_blocks,.right_col,.info_block .ad{opacity:.6;}.note>font>span{background-color:inherit!important;}');
  44. case 'dramago':
  45. return MakeTabs('#menu-bar,.bar,#content,#top_block,#search-box-banner-inner,.info_block,#eps_blocks,.s_right_col #sidebar,#footer{background-color:#111;color:#aaa;border:1px solid #777}body{background-color:#444;background-blend-mode:color-burn;}.note span{background-color:#111!important;color:#aaa!important}');
  46. case 'dramagalaxy':
  47. return MakeTabs('#content,#top_block,#search-box-banner-inner,.info_block,#eps_blocks,.s_right_col #sidebar{background-color:#121B23;color:#aaa;border:1px solid #777}img[src$="2egfcQR.png"]{display:none}');
  48. case 'animenova':
  49. return MakeTabs('html,body,#body,#header,#comments_heading,.comment,.info_box{color:#555;background-color:#111;height:auto}br:empty,.note img{display:none;}.comment{border:0px}.right_col,table,.ad,.sc_ad,#g_promo,#upper_header{opacity:.6;}');
  50. case 'animeplus':
  51. case 'animesky':
  52. return MakeTabs('html,body,#body,#header,.part,.note>span,.report_video,#comments_heading,.comment,.info_box{background-color:#000!important;color:#aaa!important;}a.report_video:hover{color:red!important;}.right_col,table,.ad,.sc_ad{opacity:.6;}#comments,.comment,#body,#streams{border:1px solid #555}');
  53. case 'animewow':
  54. return MakeTabs('#page,#body>.s_left_col,#body>.s_right_col,#search-box-banner-inner,#eps_blocks{color:#aaa;background-color:#111;}.vmargin,#top_block,.info_block{border:1px solid #aaa;background-color:#111;}.info_block *{color:#aaa!important}');
  55. case 'gogoanime':
  56. return MakeTabs2('.postcontent', '');
  57. case 'goodanime':
  58. return MakeTabs2('.postcontent', '.topad,#wrapper,.premiumdll,.postcontent,td[bgcolor]{background-color:#111;color:#aaa}#header,#footer,html,body{background-color:#000;color:#aaa}a h5,td[bgcolor] *{color:inherit!important;}');
  59. case 'animehere':
  60. SetStyle('#streams+div.playpage{margin-top:5px;}');
  61. return MakeTabs2('#playbox', '#html,body{background-color:#111;}body,.content,.cfix,.side-title{color:#ccc!important;background-color:#111!important;}.related li a{color:unset;}.tipbot,.sidebar,.banner{background-color:black;color:white;}.tipbot>*,.sidebar>*,.banner>*{opacity:.7;}.related,.like{opacity:.5;}body>footer{background:unset;}a{color: #036;}#stOverlay{display:block!important;z-index:0!important;}');
  62. default:
  63. return MakeTabs('');
  64. }
  65. }
  66.  
  67. function RemoveSomeIframes() {
  68. var streams = obj('#streams');
  69. if(streams) {
  70. var o, name, a=objs('IFRAME'), i=a.length;
  71. if(i) do {
  72. o = a[--i];
  73. if(!streams.contains(o)) {
  74. if(o.id)
  75. name = '#' + o.id;
  76. else {
  77. try {
  78. name = o.src.match(/\/\/(?:www\.)?([^/]+)/)[1];
  79. } catch(e) {
  80. name = 'unknown';
  81. }
  82. }
  83. var div = obj('+DIV'), btn = obj('+BUTTON|type=button|title='+o.getAttribute('src')+'|=show '+name+' content', div);
  84. if(o.parentNode.nodeName == 'TD') o = o.parentNode;
  85. btn.setAttribute('onclick', 'this.parentNode.innerHTML=decodeURIComponent("'+encodeURIComponent(o.outerHTML)+'");');
  86. o.parentNode.insertBefore(div, o);
  87. o.parentNode.removeChild(o);
  88. }
  89. } while(i);
  90. return true;
  91. }
  92. return false;
  93. }
  94.  
  95. function obj(name, parent) {
  96. if(!parent) parent = document;
  97. switch (name.charAt(0)) {
  98. case '#':
  99. return parent.getElementById(name.slice(1));
  100. case '.':
  101. return parent.getElementsByClassName(name.slice(1))[0];
  102. case '+':
  103. var a = name.split('|'); name = a.shift();
  104. var m = name.match(/^\+(\w+)/), node = document.createElement(m[1]);
  105. m = name.match(/\.\w+/); if(m) node.className = m[0].slice(1);
  106. m = name.match(/#\w+/); if(m) node.id = m[0].slice(1);
  107. while(a.length) {
  108. name = a.shift(); m = name.search('=');
  109. switch(m) {
  110. case -1: node.setAttribute(name, name); break;
  111. case 0: node.innerHTML = name.slice(1); break;
  112. default: node.setAttribute(name.slice(0,m), name.slice(m+1)); break;
  113. }
  114. };
  115. if(parent != document) parent.appendChild(node);
  116. return node;
  117. }
  118. return parent.getElementsByTagName(name)[0];
  119. }
  120.  
  121. function objs(name, parent) {
  122. if(!parent) parent = document;
  123. if(name.charAt(0) == '.') return parent.getElementsByClassName(name.slice(1));
  124. return parent.getElementsByTagName(name);
  125. }
  126.  
  127. function SetStyle(style) {
  128. if(style)
  129. return obj('+STYLE|='+style, obj('HEAD'));
  130. }
  131.  
  132. function RemoveElement(node) {
  133. if(node) return node.parentNode.removeChild(node);
  134. }
  135.  
  136. function domainName(href) {
  137. var m = href.match(/\:\/\/(?:www\.|embed\.)?([^\/]+)/);
  138. return(m ? m[1] : 'unknown');
  139. }
  140.  
  141. function Remember(name, value) {
  142. if(localStorage) {
  143. if(value) localStorage.setItem(name, value);
  144. else localStorage.removeItem(name);
  145. }
  146. }
  147.  
  148. function remembered(name) {
  149. if(localStorage)
  150. return localStorage.getItem(name);
  151. }
  152.  
  153. function TabOnMouseUp(event) {
  154. if(!event.ctrlKey) switch(event.button) {
  155. case 1:
  156. break;
  157. case 0:
  158. TabSelect(this);
  159. default:
  160. return;
  161. }
  162. NewWindow(this);
  163. }
  164.  
  165. function NewWindow(o) {
  166. var m = decodeURI(o.dataset.content).match(/src="(\S+?)"/);
  167. console.log(m);
  168. if(m)
  169. window.open(m[1].replace(/&/g,'&'), '_newtab');
  170. }
  171.  
  172. function TabSelect(n) {
  173. //console.log('TabSelect(',n,')');
  174. var o, a;
  175. switch(typeof(n)) {
  176. default:
  177. o = n || obj('#player_tab_0');
  178. break;
  179. case 'string':
  180. a = obj('#player_tabs').childNodes;
  181. for(o = 0;; o++) {
  182. if(o >= a.length) { n = 0; break; }
  183. if(a[o].innerHTML == n) { n = a[o].id.slice(-1); break; }
  184. }
  185. case 'number':
  186. o = obj('#player_tab_'+n) || obj('#player_tab_0');
  187. }
  188. if(o.getAttribute('class') != 'active_tab') {
  189. a = obj('.active_tab');
  190. if(a) a.removeAttribute('class');
  191. o.setAttribute('class', 'active_tab');
  192. obj('#tabplayer').innerHTML = decodeURI(o.dataset.content);
  193. Remember('preferedServer', o.innerHTML);
  194. }
  195. }
  196.  
  197. function MakeTabs(style) {
  198. if(obj('#player_tabs')) return true;
  199. var content = obj('#streams');
  200. if(content) {
  201. var va = objs('.vmargin', content), i=va.length;
  202. if(i) {
  203. var tabs = obj('+UL#player_tabs');
  204. do {
  205. var o = va[--i];
  206. var ifr = obj('IFRAME', o), tab = obj('+LI#player_tab_'+i), ttl;
  207. if(ifr) {
  208. var src = ifr.getAttribute('src');
  209. if(src.match(/[?&]/) == '&') ifr.setAttribute('src', src.replace('&', '?')); // bugfix
  210. if(!ifr.getAttribute('allowfullscreen')) ifr.setAttribute('allowfullscreen', 'true'); // enable fs for html5 video
  211. tab.textContent = domainName(src);
  212. ttl = 'span.playlist';
  213. } else {
  214. tab.textContent = '?';
  215. ttl = '.error_box';
  216. }
  217. ttl = o.querySelector(ttl); if(ttl) tab.title = ttl.textContent;
  218. tab.setAttribute('data-content', encodeURI(o.innerHTML));
  219. RemoveElement(o);
  220. tab.onmouseup = TabOnMouseUp;
  221. tabs.insertBefore(tab, tabs.firstChild);
  222. } while(i);
  223. obj('+LI|title=about videotabs|=ⓘ|style=float:right;padding:5px;', tabs).onclick = About;
  224. //if(!/Chrome/.test(navigator.userAgent))
  225. obj('+LI|title=dim the light|=✶|style=float:right;padding:5px;', tabs).onclick = Dimmer;
  226. if(style) {
  227. obj('+LI|title=toggle dark theme|=▣|style=float:right;padding:5px;', tabs).onclick = ToggleTheme;
  228. if(remembered('noDarkTheme')) darkTheme = style;
  229. else obj('+STYLE#darkTheme|='+style, obj('HEAD'));
  230. }
  231. obj('+LI|=&nbsp', tabs);
  232. content.insertBefore(tabs, va[0]);
  233. obj('+DIV#tabplayer', content);
  234. SetStyle('#player_tabs li{background-color:#393939;color:white;display:block;float:left;width:auto;padding:5px 10px;cursor:pointer;}#player_tabs li:hover{color:yellow;}#player_tabs li:last-child{cursor:auto;float:unset}#player_tabs .active_tab{background-color:#505050}#player_tabs .active_tab:hover{color:gray}a.report_video:link{color:#0047AB}html{height:unset;}\n');
  235. TabSelect(remembered('preferedServer'));
  236. Disclaimer();
  237. return true;
  238. }
  239. }
  240. return false;
  241. }
  242.  
  243. function Dimmer() {
  244. function DimPart(desc) {
  245. var style = '', names = Object.getOwnPropertyNames(desc), name, value;
  246. for(name of names) {
  247. value = desc[name];
  248. if(typeof(value) == 'number') value += 'px';
  249. style += name.replace(/_/g, '-') + ':' + value + '; ';
  250. }
  251. obj('+DIV|style=position:absolute;background-color:black;opacity:.85;z-index:1001;'+style, div);
  252. }
  253. var div = obj('#dimmer', document.body);
  254. if(div)
  255. RemoveElement(div);
  256. else {
  257. div = obj('+DIV#dimmer', document.body);
  258. var po = document.documentElement,
  259. rc = document.querySelector('#tabplayer iframe').getBoundingClientRect(),
  260. rcp = po.getBoundingClientRect(),
  261. above = rc.top-rcp.top,
  262. below = rcp.height - above - rc.height;
  263. console.log('RECT(#tabplayer iframe)', rc);
  264. DimPart({top:0, left:0, width:'100%', height:above, min_width:rcp.width});
  265. DimPart({top:above, left:0, width:'calc(50% - ' + (rcp.width/2 - rc.left) + 'px)', height:rc.height});
  266. DimPart({top:above, left:'calc(50% + ' + (rc.width - rcp.width/2 + rc.left) + 'px)', width:'calc(50% - ' + (rc.width + rc.left - rcp.width/2) + 'px)', height:rc.height});
  267. DimPart({top:above+rc.height, left:0, width:'100%', height:below, min_width:rcp.width, bottom:0});
  268. div.onclick = function(event) { RemoveElement(div); };
  269. return div;
  270. }
  271. }
  272.  
  273. function About() {
  274. var dlg = obj('+DIALOG#aboutvideotabs|open|style=position:fixed;top:20%;right:30%;z-index:2147483647;text-align:center;color:black;background-color:antiquewhite;border:7px ridge greenyellow;', Dimmer()), adr = ['mailto:gnblizz'];
  275. adr.push('@web.de?subject=videotabs%20at%20',document.domain);
  276. obj('+H1|=about videotabs', dlg);
  277. obj('+P|=<small>videotabs is public domain by <a href="'+adr.join('')+'" title="email the author directly">gnblizz</a>.</small>', dlg);
  278. obj('+BUTTON|type=button|=videotabs web page|title=info, code, feedback and stats of videotabs', obj('+A|href=https://gf.qytechs.cn/en/scripts/11480-video-tabs|target=_newtab', dlg));
  279. }
  280.  
  281. function ToggleTheme() {
  282. if(darkTheme) {
  283. obj('+STYLE#darkTheme|='+darkTheme, obj('HEAD'));
  284. Remember('noDarkTheme', darkTheme = '');
  285. } else {
  286. var style = obj('#darkTheme');
  287. darkTheme = style.innerHTML;
  288. document.head.removeChild(style);
  289. Remember('noDarkTheme', 'noDarkTheme');
  290. }
  291. }
  292.  
  293. //gogoanime.com, goodanime.eu | .postcontent
  294. //animehere.com | #playbox
  295. function MakeTabs2(select, style) {
  296. var streams = obj(select), o;
  297. if(streams && obj('IFRAME', streams)) {
  298. streams.id = 'streams';
  299. for(o of streams.children) {
  300. if(o.nodeType == 1 && obj('IFRAME', o))
  301. o.className = 'vmargin';
  302. }
  303. return MakeTabs(style);
  304. }
  305. return false;
  306. }
  307.  
  308. function Disclaimer() {
  309. var o = obj('#footer');
  310. if(o && o.textContent.match(/(Copyright|©)/i))
  311. obj('+P|=<br>Disclaimer: Video materials used here are the property of their respective and rightful owners.', o);
  312. o = document.querySelector('.info_block .note>span.imp:last-of-type');
  313. if(o && o.textContent == '95%')
  314. o.textContent = '0.5%';// a slightly more realistic value
  315. }
  316.  
  317. function FixNovaBug() {
  318. var spn = obj('#full_notes');
  319. if(spn) {
  320. var m = spn.textContent.replace(/\n/gm,'<br>').match(/\u2026\smore(?:<br>)?(.*)\sless\sless/);//u2026 = '...'
  321. if(m) {
  322. spn.parentNode.innerHTML = m[1];
  323. console.log('description text fixed');
  324. return 1;
  325. }
  326. }
  327. }
  328.  
  329. SetStyle('iframe,.vmargin{display:none}').id = 'no_frames';
  330. document.addEventListener("DOMContentLoaded", function() {
  331. if(TabSites()) {
  332. RemoveSomeIframes();
  333. window.setTimeout(function(){try{window.autoClose=-1;MHideBar();}catch(e){}},1999);
  334. } else {
  335. // auto expand description - it's foolish to hide the last few words of a sen...[expand]
  336. if(obj('#brief_notes') && !FixNovaBug()) SetStyle('#full_notes{display:inline!important;}#full_notes>a[href="#"],#brief_notes{display:none!important;}');
  337. // mark watched episodes red
  338. if(obj('#videos')) SetStyle('#videos a:visited{color:red;}');
  339. }
  340. RemoveElement(obj('#no_frames'));
  341. });
  342.  
  343. // public domain by gnblizz
  344. // contact me with my username + '@web.de'

QingJ © 2025

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