Inject2Download

Simple media download script

当前为 2018-02-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Inject2Download
  3. // @namespace http://lkubuntu.wordpress.com/
  4. // @version 0.2.9.4
  5. // @description Simple media download script
  6. // @author Anonymous Meerkat
  7. // @include *
  8. // @grant none
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. "use strict";
  14.  
  15. var injected_set = {};
  16.  
  17. // Helper functions
  18. function i2d_show_url(namespace, url, description) {
  19. function get_absolute_url(url) {
  20. var a = document.createElement('a');
  21. a.href = url;
  22. return a.href;
  23. }
  24.  
  25. function run_on_load(f) {
  26. if (document.readyState === "complete" ||
  27. document.readyState === "interactive") {
  28. f();
  29. } else {
  30. var listener = function() {
  31. if (document.readyState === "complete" ||
  32. document.readyState === "interactive") {
  33. f();
  34.  
  35. document.removeEventListener("readystatechange", listener);
  36. }
  37. };
  38.  
  39. document.addEventListener("readystatechange", listener);
  40. //document.addEventListener('DOMContentLoaded', f, false);
  41. //window.addEventListener('load', f, false);
  42. }
  43. }
  44.  
  45. if (!description)
  46. description = "";
  47.  
  48. if (typeof url !== "string" || url.replace("\s", "").length === 0)
  49. return;
  50.  
  51. if (url.match(/^mediasource:/) || url.match(/^blob:/))
  52. return;
  53.  
  54. url = get_absolute_url(url);
  55.  
  56. if (!("i2d_url_list" in window))
  57. window.i2d_url_list = [];
  58.  
  59. for (var i = 0; i < i2d_url_list.length; i++) {
  60. if (i2d_url_list[i][0] === namespace &&
  61. i2d_url_list[i][1] === url &&
  62. i2d_url_list[i][2] === description)
  63. return;
  64. }
  65.  
  66.  
  67. i2d_url_list.push([namespace, url, description]);
  68.  
  69. var newurl = decodeURIComponent(url);
  70.  
  71. var text = "[" + namespace + "] " + description + ": ";
  72.  
  73. console.log("[i2d] " + text + newurl);
  74.  
  75. run_on_load(function() {
  76. var el = document.getElementById("i2d-popup");
  77. var elspan = document.getElementById("i2d-popup-x");
  78. var elspan1 = document.getElementById("i2d-popup-close");
  79. var eldiv = document.getElementById("i2d-popup-div");
  80. var eldivhold = document.getElementById("i2d-popup-div-holder");
  81. if (!el) {
  82. el = document.createElement("div");
  83. el.style.all = "initial";
  84. //el.style.position = "absolute";
  85. el.style.width = "max(60%, 100em)";
  86. el.style.height = "max(60%, 100em)";
  87. el.style.maxWidth = "100%";
  88. el.style.maxHeight = "100%";
  89. el.style.height = "auto";
  90. el.style.width = "auto";
  91. el.style.background = "white";
  92. el.style.top = "0px";
  93. el.style.left = "0px";
  94. el.style.zIndex = Number.MAX_SAFE_INTEGER - 1;
  95. el.style.color = "black";
  96. el.style.fontFamily = "sans-serif";
  97. el.style.fontSize = "16px";
  98. el.style.lineHeight = "normal";
  99. el.style.textAlign = "left";
  100. el.style.overflow = "scroll";
  101.  
  102. /*el.ondblclick = function() {
  103. el.parentElement.removeChild(el);
  104. };*/
  105. eldivhold = document.createElement("div");
  106. eldivhold.id = "i2d-popup-span-holder";
  107. eldivhold.style.all = "initial";
  108. eldivhold.style.width = "100%";
  109. eldivhold.style.display = "block";
  110. eldivhold.style.overflow = "auto";
  111. eldivhold.style.paddingBottom = ".5em";
  112.  
  113. elspan = document.createElement("span");
  114. elspan.style.all = "initial";
  115. elspan.style.fontSize = "130%";
  116. elspan.style.cursor = "pointer";
  117. elspan.style.color = "#900";
  118. elspan.style.padding = ".1em";
  119. elspan.style.float = "left";
  120. elspan.style.display = "inline";
  121. elspan.id = "i2d-popup-x";
  122. elspan.innerHTML = '[hide]';
  123. elspan.style.textDecoration = "underline";
  124. eldivhold.appendChild(elspan);
  125.  
  126. elspan1 = document.createElement("span");
  127. elspan1.style.all = "initial";
  128. elspan1.style.fontSize = "130%";
  129. elspan1.style.cursor = "pointer";
  130. elspan1.style.color = "#900";
  131. elspan1.style.padding = ".1em";
  132. elspan1.style.float = "right";
  133. //elspan1.style.display = "none";
  134. elspan1.style.display = "inline";
  135. elspan1.id = "i2d-popup-close";
  136. elspan1.innerHTML = '[close]';
  137. elspan1.style.textDecoration = "underline";
  138. eldivhold.appendChild(elspan1);
  139.  
  140. //el.innerHTML = "<br style='line-height:150%' />";
  141. el.id = "i2d-popup";
  142. eldiv = document.createElement("div");
  143. eldiv.style.all = "initial";
  144. eldiv.id = "i2d-popup-div";
  145. //eldiv.style.display = "none";
  146. eldiv.style.display = "block";
  147. el.appendChild(eldiv);
  148. el.insertBefore(eldivhold, el.firstChild);
  149. document.body.appendChild(el);
  150.  
  151. elspan.onclick = function() {
  152. /*var el = document.getElementById("i2d-popup");
  153. el.parentElement.removeChild(el);*/
  154. var eldiv = document.getElementById("i2d-popup-div");
  155. var elspan = document.getElementById("i2d-popup-x");
  156. if (eldiv.style.display === "none") {
  157. elspan.innerHTML = '[hide]';
  158. eldiv.style.display = "block";
  159. elspan1.style.display = "inline";
  160. } else {
  161. elspan.innerHTML = '[show]';
  162. eldiv.style.display = "none";
  163. elspan1.style.display = "none";
  164. }
  165. };
  166.  
  167. elspan1.onclick = function() {
  168. var el = document.getElementById("i2d-popup");
  169. el.parentElement.removeChild(el);
  170. };
  171. }
  172. var shorturl = newurl;
  173. if (shorturl.length > 100) {
  174. shorturl = shorturl.substring(0, 99) + "&hellip;";
  175. }
  176. var el_divspan = document.createElement("span");
  177. el_divspan.style.all = "initial";
  178. el_divspan.innerHTML = text;
  179. eldiv.appendChild(el_divspan);
  180. var el_a = document.createElement("a");
  181. el_a.href = newurl;
  182. el_a.style.all = "initial";
  183. el_a.style.color = "blue";
  184. el_a.style.textDecoration = "underline";
  185. el_a.style.cursor = "pointer";
  186. el_a.title = newurl;
  187. el_a.innerHTML = shorturl;
  188. eldiv.appendChild(el_a);
  189. var el_br = document.createElement("br");
  190. el_br.style.all = "initial";
  191. eldiv.appendChild(el_br);
  192. //eldiv.innerHTML += text + "<a href='" + newurl + "' style='color:blue' title='" + newurl + "'>" + shorturl + "</a><br />";
  193.  
  194. // XXX: why is this needed? test: http://playbb.me/embed.php?w=718&h=438&vid=at/nw/flying_witch_-_01.mp4, animeplus.tv
  195. document.body.removeChild(el);
  196. el.style.position = "absolute";
  197. document.body.appendChild(el);
  198.  
  199. /*if (document.getElementById("i2d-popup-x"))
  200. document.getElementById("i2d-popup-x").parentElement.removeChild(document.getElementById("i2d-popup-x"));*/
  201.  
  202. /*el.insertBefore(elspan, el.firstChild);
  203. el.insertBefore(elspan1, el.firstChild);*/
  204. //el.insertBefore(eldivhold, el.firstChild);
  205. });
  206. }
  207.  
  208. function i2d_add_player(options) {
  209. var playlist = [];
  210. var elements = [];
  211. var ret = {};
  212.  
  213. /*var videoel = document.createElement("video");
  214. videoel.setAttribute("controls", "");
  215. options.element.appendChild(videoel);*/
  216.  
  217. if (!(options.elements instanceof Array) && !(options.elements instanceof NodeList)) {
  218. if (typeof options.elements === "string") {
  219. options.elements = document.querySelectorAll(options.elements);
  220. } else {
  221. options.elements = [options.elements];
  222. }
  223. }
  224. for (var i = 0; i < options.elements.length; i++) {
  225. (function(x) {
  226. if (!x)
  227. return;
  228. var videoel = document.createElement("video");
  229. videoel.setAttribute("controls", "");
  230. videoel.style.maxWidth = "100%";
  231. videoel.style.maxHeight = "100%";
  232. videoel.addEventListener("ended", function() {
  233. ret.next_playlist_item();
  234. });
  235. videoel.addEventListener("error", function() {
  236. ret.next_playlist_item();
  237. });
  238. /*var stylestr = "";
  239. for (var key in options.css) {
  240. stylestr += key + ":" + options.css[key] + ";"
  241. }*/
  242. for (var key in options.css) {
  243. videoel.style[key] = options.css[key];
  244. }
  245. //videoel.setAttribute("style", stylestr);
  246. if (options.replaceChildren) {
  247. x.innerHTML = "";
  248. }
  249. if (options.replace) {
  250. x.parentElement.replaceChild(videoel, x);
  251. } else {
  252. x.appendChild(videoel);
  253. }
  254. elements.push(videoel);
  255. })(options.elements[i]);
  256. }
  257. ret.add_urls = function(urls) {
  258. if (urls instanceof Array) {
  259. for (var i = 0; i < urls.length; i++) {
  260. ret.add_urls(urls[i]);
  261. }
  262. return;
  263. }
  264.  
  265. playlist.push(urls);
  266. if (playlist.length === 1) {
  267. ret.set_url(playlist[0]);
  268. }
  269. };
  270. ret.replace_urls = function(urls) {
  271. playlist = [];
  272. return ret.add_urls(urls);
  273. };
  274. var getext = function(url) {
  275. return url.replace(/.*\.([^/.?]*)(?:\?.*)?$/, "$1").toLowerCase();
  276. };
  277. var loadscript = function(variable, url, cb) {
  278. if (!(variable in window)) {
  279. var script = document.createElement("script");
  280. script.src = url;
  281. script.onload = cb;
  282. document.head.insertBefore(script, document.head.lastChild);
  283. } else {
  284. cb();
  285. }
  286. };
  287. ret.set_url = function(url) {
  288. if (!url)
  289. return;
  290. switch(getext(url)) {
  291. case "flv":
  292. loadscript("flvjs", "https://cdn.jsdelivr.net/npm/flv.js@latest", function() {
  293. var flvPlayer = flvjs.createPlayer({
  294. type: 'flv',
  295. url: url
  296. });
  297. for (var i = 0; i < elements.length; i++) {
  298. flvPlayer.attachMediaElement(elements[i]);
  299. }
  300. flvPlayer.load();
  301. });
  302. break;
  303. case "m3u8":
  304. loadscript("Hls", "https://cdn.jsdelivr.net/npm/hls.js@latest", function() {
  305. var hls = new Hls();
  306. hls.loadSource(url);
  307. for (var i = 0; i < elements.length; i++) {
  308. hls.attachMedia(elements[i]);
  309. }
  310. });
  311. break;
  312. default:
  313. for (var i = 0; i < elements.length; i++) {
  314. elements[i].src = url;
  315. }
  316. break;
  317. }
  318. };
  319. ret.next_playlist_item = function() {
  320. playlist = playlist.slice(1);
  321. if (playlist[0])
  322. ret.set_url(playlist[0]);
  323. };
  324. ret.setPlaying = function(playing) {
  325. for (var i = 0; i < elements.length; i++) {
  326. if (playing)
  327. elements[i].play();
  328. else
  329. elements[i].pause();
  330. }
  331. };
  332.  
  333. if (options.urls)
  334. ret.add_urls(options.urls);
  335.  
  336. return ret;
  337. }
  338.  
  339.  
  340. // Injecting functions
  341. var get_script_str = function(f) {
  342. return f.toString().replace(/^function.*{|}$/g, '');
  343. };
  344.  
  345. function add_script(s, el) {
  346. var script_body = "(function() {\n" + s + "\n})();";
  347. var myscript = document.createElement('script');
  348. myscript.className = "i2d";
  349. myscript.innerHTML = script_body;
  350. if (el) {
  351. el.appendChild(myscript);
  352. } else {
  353. document.head.appendChild(myscript);
  354. }
  355. }
  356.  
  357. function inject(variable, newvalue, aliases) {
  358. if (variable instanceof Array) {
  359. for (var i = 0; i < variable.length; i++) {
  360. inject(variable[i], newvalue, aliases);
  361. }
  362. return;
  363. }
  364.  
  365. console.log("[i2d] injecting " + variable);
  366. if (!aliases)
  367. aliases = [];
  368.  
  369. var initobjects = "";
  370. var subvariable = variable;
  371. var subindex = 0;
  372. while (true) {
  373. var index = subvariable.indexOf(".");
  374. var breakme = false;
  375. if (index < 0) {
  376. index = subvariable.length;
  377. breakme = true;
  378. }
  379. subvariable = subvariable.substr(index + 1);
  380. subindex += index + 1;
  381. var subname = variable.substr(0, subindex - 1);
  382. initobjects += "if (!" + subname + ") {" + subname + " = {};}\n";
  383. if (breakme)
  384. break;
  385. }
  386.  
  387. add_script(i2d_show_url.toString() + "\n" + i2d_add_player.toString() + "\n" +
  388. initobjects + "\n" +
  389. "if ((window." + variable + " !== undefined) && !(window." + variable + ".INJECTED)) {\n" +
  390. "var oldvariable = window." + variable + ";\n" +
  391. "var oldvariable_keys = Object.keys(oldvariable);\n" +
  392. "window." + variable + " = " + newvalue.toString() + ";\n" +
  393. "for (var i = 0; i < oldvariable_keys.length; i++) {\n" +
  394. " window." + variable + "[oldvariable_keys[i]] = oldvariable[oldvariable_keys[i]];\n" +
  395. "}\n" +
  396. "window." + variable + ".INJECTED = true;\n" +
  397. "var aliases = " + JSON.stringify(aliases) + ";\n" +
  398. "for (var i = 0; i < aliases.length; i++) {\n" +
  399. " if (aliases[i] in window && window[aliases[i]] == oldvariable)" +
  400. " window[aliases[i]] = window." + variable + "\n" +
  401. "}\n" +
  402. "}");
  403. }
  404.  
  405. function jquery_plugin_exists(name) {
  406. if (!("jQuery" in window) ||
  407. typeof window.jQuery !== "function" ||
  408. !("fn" in window.jQuery) ||
  409. !(name in window.jQuery.fn))
  410. return false;
  411.  
  412.  
  413. return true;
  414. }
  415.  
  416. function inject_jquery_plugin(name, value) {
  417. if (!jquery_plugin_exists(name) ||
  418. window.jQuery.fn[name].INJECTED)
  419. return;
  420.  
  421. inject("jQuery.fn." + name, value);
  422. }
  423.  
  424. function inject_url(pattern, func) {
  425. // https://stackoverflow.com/questions/629671/how-can-i-intercept-xmlhttprequests-from-a-greasemonkey-script
  426. console.log("[i2d] injecting URL: " + pattern);
  427. (function(open) {
  428. window.XMLHttpRequest.prototype.open = function() {
  429. if (arguments[1] &&
  430. arguments[1].match(pattern)) {
  431. var url = arguments[1];
  432. this.addEventListener("readystatechange", function() {
  433. if (this.readyState === 4) {
  434. func.bind(this)(url);
  435. }
  436. });
  437. }
  438. open.apply(this, arguments);
  439. };
  440. })(window.XMLHttpRequest.prototype.open);
  441. }
  442.  
  443. function i2d_onload(f) {
  444. if (document.readyState === "loading") {
  445. document.addEventListener("DOMContentLoaded", f);
  446. } else {
  447. f();
  448. }
  449. }
  450.  
  451.  
  452. // Main code
  453. function i2d_main(e) {
  454. if (e) {
  455. if (!e.tagName || e.tagName.toLowerCase() !== "script")
  456. return;
  457. if ((e.className === "i2d")) {
  458. return;
  459. }
  460.  
  461. /*var ourscript = document.createElement("script");
  462. ourscript.className = "i2d";
  463. ourscript.innerHTML = "i2d_main();" + i2d_main;
  464. e.parentElement.insertBefore(ourscript, e.nextSibling);*/
  465.  
  466. var old_onload = e.onload;
  467. e.onload = function() {
  468. i2d_main();
  469. if (old_onload)
  470. return old_onload.apply(this, arguments);
  471. };
  472. }
  473.  
  474. if ("soundManager" in window && !window.soundManager.INJECTED) {
  475. inject("soundManager.createSound", function(arg1, arg2) {
  476. if (typeof arg1 === "string")
  477. i2d_show_url("soundManager", arg2);
  478. else
  479. i2d_show_url("soundManager", arg1.url);
  480.  
  481. return oldvariable.apply(this, arguments);
  482. });
  483. }
  484.  
  485. if ("jwplayer" in window && !window.jwplayer.INJECTED) {
  486. inject("jwplayer", function() {
  487. var result = oldvariable.apply(this, arguments);
  488.  
  489. var check_sources = function(x) {
  490. if (typeof x === "object") {
  491. if (x instanceof Array) {
  492. for (var i = 0; i < x.length; i++) {
  493. check_sources(x[i]);
  494. }
  495. return;
  496. }
  497.  
  498. var label = "";
  499.  
  500. if ("title" in x)
  501. label += "[" + x.title + "]";
  502.  
  503. if ("label" in x)
  504. label += "[" + x.label + "]";
  505.  
  506. if ("kind" in x)
  507. label += "(" + x.kind + ")";
  508.  
  509. if ("streamer" in x) {
  510. i2d_show_url("jwplayer", x.streamer, "[stream]" + label);
  511. }
  512.  
  513. if ("file" in x) {
  514. i2d_show_url("jwplayer", x.file, label);
  515. }
  516.  
  517. if ("sources" in x) {
  518. check_sources(x.sources);
  519. }
  520.  
  521. if ("playlist" in x) {
  522. check_sources(x.playlist);
  523. }
  524.  
  525. if ("tracks" in x) {
  526. check_sources(x.tracks);
  527. }
  528. } else if (typeof x === "string") {
  529. i2d_show_url("jwplayer", x);
  530. }
  531. };
  532.  
  533. if ("setup" in result) {
  534. var old_jwplayer_setup = result.setup;
  535. result.setup = function() {
  536. if (typeof arguments[0] === "object") {
  537. var x = arguments[0];
  538.  
  539. if ("modes" in x) {
  540. for (var i = 0; i < x.modes.length; i++) {
  541. // TODO: support more?
  542. if ("type" in x.modes[i] && x.modes[i].type === "html5") {
  543. if ("config" in x.modes[i] && "file" in x.modes[i].config) {
  544. check_sources(x.modes[i].config);
  545. }
  546. }
  547. }
  548. }
  549.  
  550. check_sources(x);
  551. }
  552.  
  553. return old_jwplayer_setup.apply(this, arguments);
  554. };
  555. }
  556.  
  557. if ("load" in result) {
  558. var old_jwplayer_load = result.load;
  559. result.load = function() {
  560. check_sources(arguments[0]);
  561. return old_jwplayer_load.apply(this, arguments);
  562. };
  563. }
  564.  
  565. if ("on" in result) {
  566. result.on('playlistItem', function(item) {
  567. check_sources(item.item);
  568. });
  569.  
  570. var old_jwplayer_on = result.on;
  571. result.on = function() {
  572. if (arguments[0] === "adBlock")
  573. return;
  574.  
  575. return old_jwplayer_on.apply(this, arguments);
  576. };
  577. }
  578.  
  579. return result;
  580. });
  581. }
  582.  
  583. if ("flowplayer" in window && !window.flowplayer.INJECTED) {
  584. inject("flowplayer", function() {
  585. var obj_baseurl = null;
  586. var els = [];
  587.  
  588. var urls = [];
  589. var url_pairs = {};
  590. var players = {};
  591. var add_url = function() {
  592. if (Object.keys(players).length === 0) {
  593. urls.push(arguments[1]);
  594. } else {
  595. for (var key in players) {
  596. players[key].add_urls(arguments[1]);
  597. }
  598. }
  599.  
  600. return i2d_show_url.apply(this, arguments);
  601. };
  602. var add_url_pair = function(el) {
  603. var newargs = Array.prototype.slice.call(arguments, 1);
  604. if (!(el in players)) {
  605. if (!url_pairs[el])
  606. url_pairs[el] = [];
  607. url_pairs[el].push(newargs[1]);
  608. } else {
  609. players[el].add_urls(newargs[1]);
  610. }
  611.  
  612. return i2d_show_url.apply(this, newargs);
  613. };
  614.  
  615. function get_url(x) {
  616. x = decodeURIComponent(x);
  617.  
  618. if (obj_baseurl) {
  619. if (x.match(/^[a-z]*:\/\//)) {
  620. return x;
  621. } else {
  622. return obj_baseurl + "/" + x;
  623. }
  624. } else {
  625. return x;
  626. }
  627. }
  628.  
  629. function check_sources(x, els, label) {
  630. if (typeof x === "string") {
  631. if (!x.match(/\.xml$/))
  632. add_url("flowplayer", get_url(x), label);
  633.  
  634. return;
  635. }
  636.  
  637. if (x instanceof Array) {
  638. for (var i = 0; i < x.length; i++) {
  639. check_sources(x[i], els, label);
  640. }
  641. return;
  642. }
  643.  
  644. if (typeof x !== "object")
  645. return;
  646.  
  647. label = "";
  648.  
  649. if ("title" in x)
  650. label += "[" + x.title + "]";
  651.  
  652. if ("clip" in x) {
  653. if ("baseUrl" in x.clip) {
  654. obj_baseurl = x.clip.baseUrl;
  655.  
  656. for (var i = 0; i < els.length; i++) {
  657. els[i].i2d_baseurl = obj_baseurl;
  658. }
  659. }
  660.  
  661. check_sources(x.clip, els, label);
  662. }
  663.  
  664. if ("sources" in x) {
  665. check_sources(x.sources, els, label);
  666. }
  667.  
  668. if ("playlist" in x) {
  669. check_sources(x.playlist, els, label);
  670. }
  671.  
  672. if ("url" in x) {
  673. check_sources(x.url, els, label);
  674. }
  675.  
  676. if ("src" in x) {
  677. check_sources(x.src, els. label);
  678. }
  679.  
  680. if ("bitrates" in x) {
  681. for (var j = 0; j < x.bitrates.length; j++) {
  682. if ("url" in x.bitrates[j]) {
  683. var description = "";
  684. if (x.bitrates[j].isDefault)
  685. description += "default:";
  686. if (x.bitrates[j].sd)
  687. description += "sd:";
  688. if (x.bitrates[j].hd)
  689. description += "hd:";
  690. if (x.bitrates[j].bitrate)
  691. description += x.bitrates[j].bitrate;
  692.  
  693. add_url("flowplayer", get_url(x.bitrates[j].url), description);
  694. }
  695. }
  696. }
  697. }
  698.  
  699. if (arguments.length >= 1) {
  700. els = [null];
  701.  
  702. if (typeof arguments[0] === "string") {
  703. try {
  704. els[0] = document.getElementById(arguments[0]);
  705. } catch(e) {
  706. }
  707.  
  708. try {
  709. if (!els[0])
  710. els = document.querySelectorAll(arguments[0]);
  711. } catch(e) {
  712. els = [];
  713. }
  714. } else if (arguments[0] instanceof HTMLElement) {
  715. els = [arguments[0]];
  716. }
  717. }
  718.  
  719. for (var i = 0; i < els.length; i++) {
  720. if (!els[i] || !(els[i] instanceof HTMLElement))
  721. continue;
  722.  
  723. if ("i2d_baseurl" in els[i])
  724. obj_baseurl = els[i].i2d_baseurl;
  725. }
  726.  
  727. var options = {};
  728.  
  729. if (arguments.length >= 3 && typeof arguments[2] === "object") {
  730. check_sources(arguments[2], els);
  731. options = arguments[2];
  732. } else if (arguments.length >= 3 && typeof arguments[2] === "string") {
  733. add_url("flowplayer", get_url(arguments[2]));
  734. } else if (arguments.length === 2 && typeof arguments[1] === "object") {
  735. check_sources(arguments[1], els);
  736. options = arguments[1];
  737. } else if (arguments.length === 2 && typeof arguments[1] === "string") {
  738. add_url("flowplayer", get_url(arguments[1]));
  739. }
  740.  
  741. for (var i = 0; i < els.length; i++) {
  742. if (!els[i] || !(els[i] instanceof HTMLElement))
  743. continue;
  744.  
  745. var href = els[i].getAttribute("href");
  746. if (href) {
  747. add_url_pair(els[i], "flowplayer", get_url(href), "href");
  748. }
  749. }
  750.  
  751. if (false) {
  752. oldvariable = function() {
  753. var css = {width: "100%", height: "100%"};
  754. for (var key in options.screen) {
  755. var val = options.screen[key];
  756. switch(key) {
  757. case "height":
  758. case "width":
  759. case "bottom":
  760. case "top":
  761. case "left":
  762. case "right":
  763. if (typeof val === "number") {
  764. css[key] = val + "px";
  765. } else {
  766. css[key] = val;
  767. }
  768. break;
  769. default:
  770. css[key] = val;
  771. break;
  772. }
  773. }
  774. for (var i = 0; i < els.length; i++) {
  775. var player_urls = url_pairs[els[i]] || [];
  776. for (var x = 0; x < urls.length; x++) {
  777. player_urls.push(urls[x]);
  778. }
  779. players[els[i]] = i2d_add_player({
  780. elements: els[i],
  781. replaceChildren: true,
  782. urls: player_urls,
  783. css: css
  784. });
  785. }
  786.  
  787. var allp = function(name) {
  788. for (var key in players) {
  789. players[key][name].apply(this, Array.prototype.slice.apply(arguments, 1));
  790. }
  791. };
  792.  
  793. var res = {};
  794. var fns = [
  795. "addClip",
  796. "setPlaylist",
  797. "load",
  798. "playlist",
  799. "play",
  800. "ipad"
  801. ];
  802. for (var i = 0; i < fns.length; i++) {
  803. res[fns[i]] = function(){};
  804. }
  805.  
  806. return res;
  807. };
  808. }
  809.  
  810. var result = oldvariable.apply(this, arguments);
  811.  
  812. if (!result || typeof result !== "object")
  813. return result;
  814.  
  815. if ("addClip" in result) {
  816. var old_fplayer_addclip = result.addClip;
  817. result.addClip = function() {
  818. if (arguments.length > 0)
  819. check_sources(arguments[0], els);
  820.  
  821. return old_fplayer_addclip.apply(this, arguments);
  822. };
  823. }
  824.  
  825. if ("setPlaylist" in result) {
  826. var old_fplayer_setplaylist = result.setPlaylist;
  827. result.setPlaylist = function() {
  828. if (arguments.length > 0)
  829. check_sources(arguments[0], els);
  830.  
  831. return old_fplayer_setplaylist.apply(this, arguments);
  832. };
  833. }
  834.  
  835. if ("load" in result) {
  836. var old_fplayer_load = result.load;
  837. result.load = function() {
  838. if (arguments.length > 0)
  839. check_sources(arguments[0], els);
  840.  
  841. return old_fplayer_load.apply(this, arguments);
  842. };
  843. }
  844.  
  845. if ("play" in result) {
  846. var old_fplayer_play = result.play;
  847. result.play = function() {
  848. if (arguments.length > 0)
  849. check_sources(arguments[0], els);
  850.  
  851. return old_fplayer_play.apply(this, arguments);
  852. };
  853. }
  854.  
  855. /*if ("on" in result) {
  856. result.on("load", function(e, api, video) {
  857. console.log(e);
  858. check_sources(video || api.video, els);
  859. });
  860. }*/
  861.  
  862. return result;
  863. }, ["$f"]);
  864.  
  865. add_script(get_script_str(function() {
  866. flowplayer(function(api, root) {
  867. api.on("load", function(e, api, video) {
  868. flowplayer().load(video || api.video);
  869. });
  870. });
  871. }));
  872. }
  873.  
  874. if ("videojs" in window && !window.videojs.INJECTED) {
  875. inject("videojs", function() {
  876. if (arguments.length > 0 && typeof arguments[0] === "string") {
  877. var my_el = document.getElementById(arguments[0]);
  878. if (!my_el)
  879. my_el = document.querySelector(arguments[0]);
  880.  
  881. if (my_el) {
  882. if (my_el.src) {
  883. i2d_show_url("videojs", my_el.src);
  884. }
  885.  
  886. for (var i = 0; i < my_el.children.length; i++) {
  887. if (my_el.children[i].tagName.toLowerCase() === "source") {
  888. if (my_el.children[i].src) {
  889. i2d_show_url("videojs", my_el.children[i].src, my_el.children[i].getAttribute("label"));
  890. }
  891. }
  892. }
  893. }
  894. }
  895.  
  896. var result = oldvariable.apply(this, arguments);
  897.  
  898. var old_videojs_src = result.src;
  899. result.src = function() {
  900. if (arguments.length > 0 && typeof arguments[0] === "object") {
  901. if ("src" in arguments[0]) {
  902. i2d_show_url("videojs", arguments[0].src);
  903. }
  904. }
  905.  
  906. return old_videojs_src.apply(this, arguments);
  907. };
  908.  
  909. return result;
  910. });
  911.  
  912. add_script(i2d_show_url.toString() +
  913. i2d_onload.toString() +
  914. get_script_str(function() {
  915. i2d_onload(function() {
  916. var els = document.getElementsByClassName("video-js");
  917. for (var i = 0; i < els.length; i++) {
  918. var my_el = els[i];
  919. if (my_el.tagName.toLowerCase() === "video") {
  920. if (!my_el.getAttribute('data-setup')) {
  921. continue;
  922. }
  923. if (my_el.src) {
  924. i2d_show_url("videojs", my_el.src);
  925. }
  926.  
  927. for (var j = 0; j < my_el.children.length; j++) {
  928. if (my_el.children[j].tagName.toLowerCase() === "source") {
  929. if (my_el.children[j].src) {
  930. i2d_show_url("videojs", my_el.children[j].src, my_el.children[j].getAttribute("label"));
  931. }
  932. }
  933. }
  934. }
  935. }
  936. });
  937. }));
  938. }
  939.  
  940. if ("amp" in window && !window.amp.INJECTED) {
  941. inject("amp", function() {
  942. function show_amp_source(sourceobj) {
  943. if ("protectionInfo" in sourceobj) {
  944. console.log("[amp] Cannot decode protection info");
  945. }
  946. if ("src" in sourceobj)
  947. i2d_show_url("amp", sourceobj.src);
  948. }
  949.  
  950. if (arguments.length >= 2 && typeof arguments[1] === "object") {
  951. if ("sourceList" in arguments[1]) {
  952. for (var i = 0; i < arguments[1].sourceList.length; i++) {
  953. show_amp_source(arguments[1].sourceList[i]);
  954. }
  955. }
  956. }
  957.  
  958. var result = oldvariable.apply(this, arguments);
  959.  
  960. if (!result)
  961. return result;
  962.  
  963. var old_amp_src = result.src;
  964. result.src = function() {
  965. for (var i = 0; i < arguments[0].length; i++) {
  966. show_amp_source(arguments[0][i]);
  967. }
  968.  
  969. return old_amp_src.apply(this, arguments);
  970. };
  971.  
  972. return result;
  973. });
  974. }
  975.  
  976. if ("DJPlayer" in window && !window.DJPlayer.INJECTED) {
  977. add_script(i2d_show_url.toString() + "\n" +
  978. "var oldsetmedia = window.DJPlayer.prototype.setMedia;\n" +
  979. "window.DJPlayer.prototype.setMedia = function() {\n" +
  980. " if (arguments.length > 0 && typeof arguments[0] === 'string') {\n" +
  981. " i2d_show_url('DJPlayer', arguments[0]);\n" +
  982. " }\n" +
  983. " return oldsetmedia.apply(this, arguments);\n" +
  984. "}");
  985. }
  986.  
  987. if ("bitmovin" in window && !window.bitmovin.INJECTED) {
  988. inject(["bitmovin.player", "bitdash", "bitmovinPlayer"], function() {
  989. var result = oldvariable.apply(this, arguments);
  990.  
  991. var check_progressive = function(progressive) {
  992. if (typeof progressive === "string") {
  993. i2d_show_url("bitmovin", progressive, "progressive");
  994. } else if (progressive instanceof Array) {
  995. for (var i = 0; i < progressive.length; i++) {
  996. check_progressive(progressive[i]);
  997. }
  998. } else if (typeof progressive === "object") {
  999. var str = "";
  1000. if (progressive.label)
  1001. str += "[" + progressive.label + "] ";
  1002. if (progressive.bitrate)
  1003. str += progressive.bitrate;
  1004.  
  1005. i2d_show_url("bitmovin", progressive.url, str);
  1006. }
  1007. };
  1008.  
  1009. var check_sources = function(x) {
  1010. if (typeof x === "object") {
  1011. if ("source" in x) {
  1012. var sourceobj = x.source;
  1013.  
  1014. if (sourceobj.progressive) {
  1015. check_progressive(sourceobj.progressive);
  1016. }
  1017.  
  1018. if (sourceobj.dash) {
  1019. i2d_show_url("bitmovin", sourceobj.dash, "dash");
  1020. }
  1021.  
  1022. if (sourceobj.hls) {
  1023. i2d_show_url("bitmovin", sourceobj.hls, "hls");
  1024. }
  1025. }
  1026. }
  1027. };
  1028.  
  1029. if ("setup" in result) {
  1030. var old_bitmovin_setup = result.setup;
  1031. result.setup = function() {
  1032. check_sources(arguments[0]);
  1033.  
  1034. return old_bitmovin_setup.apply(this, arguments);
  1035. };
  1036. }
  1037.  
  1038. if ("load" in result) {
  1039. var old_bitmovin_load = result.load;
  1040. result.load = function() {
  1041. check_sources({source: arguments[0]});
  1042.  
  1043. return old_bitmovin_load.apply(this, arguments);
  1044. };
  1045. }
  1046.  
  1047. return result;
  1048. });
  1049. }
  1050.  
  1051. if ("dashjs" in window && window.dashjs.MediaPlayer && !window.dashjs.MediaPlayer.INJECTED) {
  1052. inject("dashjs.MediaPlayer", function() {
  1053. var outer_result = oldvariable.apply(this, arguments);
  1054.  
  1055. var oldcreate = outer_result.create;
  1056. outer_result.create = function() {
  1057. var result = oldcreate.apply(this, arguments);
  1058.  
  1059. var old_attachsource = result.attachSource;
  1060. result.attachSource = function(url) {
  1061. i2d_show_url("dash.js", url);
  1062. return old_attachsource.apply(this, arguments);
  1063. };
  1064.  
  1065. return result;
  1066. };
  1067.  
  1068. return outer_result;
  1069. });
  1070. }
  1071.  
  1072. if ("Hls" in window && window.Hls && !window.Hls.INJECTED) {
  1073. console.log("[i2d] injecting Hls");
  1074. var old_loadsource = window.Hls.prototype.loadSource;
  1075. window.Hls.prototype.loadSource = function(url) {
  1076. i2d_show_url("hls.js", url);
  1077. return old_loadsource.apply(this, arguments);
  1078. };
  1079. window.Hls.INJECTED = true;
  1080. }
  1081.  
  1082. if ("flvjs" in window && window.flvjs.createPlayer && !window.flvjs.createPlayer.INJECTED) {
  1083. inject("flvjs.createPlayer", function(options) {
  1084. if (options) {
  1085. if ("url" in options) {
  1086. i2d_show_url("flv.js", options.url);
  1087. }
  1088. }
  1089. return oldvariable.apply(this, arguments);
  1090. });
  1091. }
  1092.  
  1093. if ("KollusMediaContainer" in window && window.KollusMediaContainer && !window.KollusMediaContainer.INJECTED) {
  1094. inject("KollusMediaContainer.createInstance", function(options) {
  1095. if (options) {
  1096. if ("mediaurl" in options) {
  1097. var types = [];
  1098. if (options.isencrypted)
  1099. types.push("encrypted");
  1100. if (options.isaudiofiles)
  1101. types.push("audio");
  1102. else
  1103. types.push("video");
  1104. i2d_show_url("kollus", options.mediaurl, types.join(":"));
  1105. }
  1106. }
  1107.  
  1108. // Replace flash with HTML5, but it doesn't work for HLS
  1109. if (false) {
  1110. var value = (new KollusMediaContainer(options));
  1111. var old_launchFlashPlayer = value.launchFlashPlayer;
  1112. value.launchFlashPlayer = function() {
  1113. if (options.isencrypted) {
  1114. return old_launchflashplayer.apply(this, arguments);
  1115. } else if (options.isaudiofile) {
  1116. return value.launchHTML5AudioPlayer();
  1117. } else {
  1118. return value.launchHTML5Player();
  1119. }
  1120. };
  1121. value.isURLHasM3U8 = function(){return false;};
  1122. value = value.initialize();
  1123.  
  1124. return value;
  1125. } else {
  1126. return oldvariable.apply(this, arguments);
  1127. }
  1128. });
  1129. }
  1130.  
  1131. if (("location" in window) && window.location && window.location.host.search("soundcloud.com") >= 0 && !("soundcloud" in injected_set)) {
  1132. injected_set["soundcloud"] = true;
  1133.  
  1134. inject_url(/api\.soundcloud\.com\/.*?\/tracks\/[0-9]*\/streams/, function(url) {
  1135. var track = url.match(/\/tracks\/([0-9]*)\//);
  1136. var parsed = JSON.parse(this.responseText);
  1137. for (var item in parsed) {
  1138. i2d_show_url("soundcloud", parsed[item], "[" + item + "] " + track[1]);
  1139. }
  1140. });
  1141. }
  1142.  
  1143. if (("location" in window) && window.location && window.location.host.search("forvo") >= 0 && "createAudioObject" in window && !window.createAudioObject.INJECTED) {
  1144. inject("createAudioObject", function(id, mp3, ogg) {
  1145. i2d_show_url("forvo", mp3, "mp3");
  1146. i2d_show_url("forvo", ogg, "ogg");
  1147.  
  1148. return oldvariable.apply(this, arguments);
  1149. });
  1150. }
  1151.  
  1152. if (("location" in window) && window.location && window.location.href.search("twitter.com/i/videos") >= 0 && !("twitter" in injected_set)) {
  1153. injected_set["twitter"] = true;
  1154.  
  1155. i2d_onload(function() {
  1156. var pc = document.getElementById('playerContainer');
  1157. if (!pc) {
  1158. return;
  1159. }
  1160.  
  1161. var config = pc.getAttribute('data-config');
  1162. if (!config) {
  1163. return;
  1164. }
  1165.  
  1166. var config_parsed = JSON.parse(config);
  1167.  
  1168. if ("video_url" in config_parsed) {
  1169. i2d_show_url('twitter', config_parsed.video_url);
  1170. }
  1171. });
  1172. }
  1173.  
  1174. if (("location" in window) && window.location && window.location.href.search("vine.co/v/") >= 0) {
  1175. var show_video_urls = function(videourls) {
  1176. for (var i = 0; i < videourls.length; i++) {
  1177. var videourl = videourls[i];
  1178.  
  1179. var formatstr = "[";
  1180. formatstr += videourl.format + ":";
  1181. formatstr += videourl.idStr;
  1182.  
  1183. if (videourl.rate > 0)
  1184. formatstr += ", " + videourl.rate;
  1185.  
  1186. formatstr += "]";
  1187.  
  1188. i2d_show_url('vine', videourl.videoUrl, formatstr);
  1189. }
  1190. };
  1191.  
  1192. if (window.location.href.search("/card" ) >= 0 && !("vine_card" in injected_set)) {
  1193. injected_set["vine_card"] = true;
  1194.  
  1195. i2d_onload(function() {
  1196. var config_el = document.getElementById("configuration");
  1197. if (!config_el) {
  1198. return;
  1199. }
  1200.  
  1201. var config = JSON.parse(config_el.innerHTML);
  1202. if (!config || typeof config !== "object") {
  1203. return;
  1204. }
  1205.  
  1206. if (!("post" in config) || !("videoUrls" in config.post)) {
  1207. return;
  1208. }
  1209.  
  1210. show_video_urls(config.post.videoUrls);
  1211. });
  1212. } else if (!("vine_video" in injected_set)) {
  1213. injected_set["vine_video"] = true;
  1214.  
  1215. i2d_onload(function() {
  1216. var scripts = document.getElementsByTagName("script");
  1217. if (scripts.length === 0)
  1218. return;
  1219.  
  1220. var thescript = null;
  1221. for (var i = 0; i < scripts.length; i++) {
  1222. if (scripts[i].innerHTML.search("window.POST_DATA") < 0) {
  1223. continue;
  1224. }
  1225.  
  1226. thescript = scripts[i];
  1227. break;
  1228. }
  1229.  
  1230. var config;
  1231. eval(thescript.innerHTML.replace("window.POST_DATA", "config"));
  1232.  
  1233. var videourls = config[Object.keys(config)[0]].videoUrls;
  1234. show_video_urls(videourls);
  1235. });
  1236. }
  1237. }
  1238.  
  1239. if ("jQuery" in window) {
  1240. inject_jquery_plugin("jPlayer", function() {
  1241. if (arguments.length > 0 && arguments[0] === "setMedia") {
  1242. if (arguments.length > 1) {
  1243. if (typeof arguments[1] === "object") {
  1244. for (var i in arguments[1]) {
  1245. if (i === "title" ||
  1246. i === "duration" ||
  1247. i === "track" /* for now */ ||
  1248. i === "artist" ||
  1249. i === "free")
  1250. continue;
  1251.  
  1252. i2d_show_url("jPlayer", arguments[1][i], i);
  1253. }
  1254. } else if (typeof arguments[1] === "string") {
  1255. i2d_show_url("jPlayer", arguments[1]);
  1256. }
  1257. }
  1258. }
  1259.  
  1260. return oldvariable.apply(this, arguments);
  1261. });
  1262.  
  1263. inject_jquery_plugin("amazingaudioplayer", function() {
  1264. var result = oldvariable.apply(this, arguments);
  1265.  
  1266. function add_source_obj(x) {
  1267. type = "";
  1268. if ("type" in x) {
  1269. type = x.type;
  1270. }
  1271.  
  1272. i2d_show_url("amazingaudioplayer", x.src, type);
  1273. }
  1274.  
  1275. function add_source(x) {
  1276. if (x instanceof Array) {
  1277. for (var i = 0; i < x.length; i++) {
  1278. add_source_obj(x[i]);
  1279. }
  1280. } else {
  1281. add_source_obj(x);
  1282. }
  1283. }
  1284.  
  1285. var audioplayer = jQuery(this).data("object").audioPlayer;
  1286. if (audioplayer.audioItem) {
  1287. add_source(audioplayer.audioItem.source);
  1288. }
  1289.  
  1290. var oldload = audioplayer.load;
  1291. audioplayer.load = function(item) {
  1292. if ("source" in item) {
  1293. add_source(item.source);
  1294. }
  1295.  
  1296. return oldload.apply(this, arguments);
  1297. };
  1298.  
  1299. return result;
  1300. });
  1301.  
  1302. if (jquery_plugin_exists("jPlayerAudio") && !window.jQuery.fn.jPlayerAudio.INJECTED) {
  1303. inject_jquery_plugin("jPlayerAudio", function() {
  1304. return oldvariable.apply(this, arguments);
  1305. });
  1306.  
  1307. add_script(i2d_show_url.toString() + "\n" +
  1308. "var oldmedia=jQuery.jPlayerAudio.prototype.setMedia;\n" +
  1309. "jQuery.jPlayerAudio.prototype.setMedia = function(e) {\n" +
  1310. " var absolute = this._absoluteMediaUrls(e);\n" +
  1311. " jQuery.each(this.formats, function(a, o) {\n" +
  1312. " i2d_show_url('cleanaudioplayer', absolute[o]);\n" +
  1313. " });\n" +
  1314. " return oldmedia.apply(this, arguments);\n" +
  1315. "}");
  1316. }
  1317.  
  1318. if (jquery_plugin_exists("jPlayerVideo") && !window.jQuery.fn.jPlayerVideo.INJECTED) {
  1319. inject_jquery_plugin("jPlayerVideo", function() {
  1320. return oldvariable.apply(this, arguments);
  1321. });
  1322.  
  1323. add_script(i2d_show_url.toString() + "\n" +
  1324. "var oldmedia=jQuery.jPlayerVideo.prototype.setMedia;\n" +
  1325. "jQuery.jPlayerVideo.prototype.setMedia = function(e) {\n" +
  1326. " var absolute = this._absoluteMediaUrls(e);\n" +
  1327. " jQuery.each(this.formats, function(a, o) {\n" +
  1328. " i2d_show_url('cleanvideoplayer', absolute[o]);\n" +
  1329. " });\n" +
  1330. " return oldmedia.apply(this, arguments);\n" +
  1331. "}");
  1332. }
  1333.  
  1334. inject_jquery_plugin("flowplayer", function() {
  1335. var newargs = Array.from(arguments);
  1336. newargs.unshift(jQuery(this)[0]);
  1337. return window.flowplayer.apply(this, newargs);
  1338. });
  1339. }
  1340. }
  1341.  
  1342. i2d_main();
  1343.  
  1344. window.addEventListener("afterscriptexecute", function(e) {
  1345. i2d_main(e.target);
  1346. });
  1347.  
  1348. var process_raw_tag = function(el) {
  1349. var basename = "raw ";
  1350.  
  1351. if (el.tagName.toLowerCase() === "video") {
  1352. basename += "video";
  1353. } else {
  1354. basename += "audio";
  1355. }
  1356.  
  1357. if (el.id)
  1358. basename += ": #" + el.id;
  1359.  
  1360. var show_updates = function() {
  1361. if (el.src)
  1362. i2d_show_url(basename, el.src);
  1363.  
  1364. for (var x = 0; x < el.children.length; x++) {
  1365. if (el.children[x].tagName.toLowerCase() !== "source" &&
  1366. el.children[x].tagName.toLowerCase() !== "track") {
  1367. continue;
  1368. }
  1369.  
  1370. var type = "";
  1371. if (el.children[x].type)
  1372. type += "[" + el.children[x].type + "]";
  1373.  
  1374. if (el.children[x].label)
  1375. type += "[" + el.children[x].label + "]";
  1376.  
  1377. if (el.children[x].srclang)
  1378. type += "[" + el.children[x].srclang + "]";
  1379.  
  1380. if (el.children[x].kind)
  1381. type += "(" + el.children[x].kind + ")";
  1382.  
  1383. if (el.children[x].src)
  1384. i2d_show_url(basename, el.children[x].src, type);
  1385. }
  1386. };
  1387.  
  1388. var observer = new MutationObserver(show_updates);
  1389. observer.observe(el, { attributes: true, childList: true });
  1390.  
  1391. show_updates();
  1392. };
  1393.  
  1394. var process_el = function(el) {
  1395. if (el.nodeName === "SCRIPT") {
  1396. i2d_main(el);
  1397. } else if (el.nodeName === "VIDEO" ||
  1398. el.nodeName === "AUDIO") {
  1399. process_raw_tag(el);
  1400. }
  1401.  
  1402. if (el.children) {
  1403. for (var i = 0; i < el.children.length; i++) {
  1404. process_el(el.children[i]);
  1405. }
  1406. }
  1407. };
  1408.  
  1409. var script_observer_cb = function(mutations, observer) {
  1410. for (var i = 0; i < mutations.length; i++) {
  1411. if (mutations[i].addedNodes) {
  1412. for (var x = 0; x < mutations[i].addedNodes.length; x++) {
  1413. var addednode = mutations[i].addedNodes[x];
  1414. process_el(addednode);
  1415. }
  1416. }
  1417. if (mutations[i].removedNodes) {
  1418. for (var x = 0; x < mutations[i].removedNodes.length; x++) {
  1419. if (mutations[i].removedNodes[x].nodeName === "SCRIPT")
  1420. i2d_main(mutations[i].removedNodes[x]);
  1421. }
  1422. }
  1423. }
  1424. };
  1425.  
  1426. var script_observer = new MutationObserver(script_observer_cb);
  1427.  
  1428. script_observer.observe(document, {childList: true, subtree: true});
  1429.  
  1430. i2d_onload(function() {
  1431. var get_raws = function() {
  1432. var audios = [].slice.call(document.getElementsByTagName("audio"));
  1433. var videos = [].slice.call(document.getElementsByTagName("video"));
  1434. var els = Array.prototype.concat(audios, videos);
  1435.  
  1436. for (var i = 0; i < els.length; i++) {
  1437. var basename = "raw ";
  1438. var el = els[i];
  1439.  
  1440. if (el.tagName.toLowerCase() === "video") {
  1441. basename += "video";
  1442. } else {
  1443. basename += "audio";
  1444. }
  1445.  
  1446. if (el.id)
  1447. basename += ": #" + el.id;
  1448.  
  1449. var show_updates = function() {
  1450. if (el.src)
  1451. i2d_show_url(basename, el.src);
  1452.  
  1453. for (var x = 0; x < el.children.length; x++) {
  1454. if (els[i].children[x].tagName.toLowerCase() !== "source" &&
  1455. els[i].children[x].tagName.toLowerCase() !== "track") {
  1456. continue;
  1457. }
  1458.  
  1459. var type = "";
  1460. if (el.children[x].type)
  1461. type += "[" + el.children[x].type + "]";
  1462.  
  1463. if (el.children[x].label)
  1464. type += "[" + el.children[x].label + "]";
  1465.  
  1466. if (el.children[x].srclang)
  1467. type += "[" + el.children[x].srclang + "]";
  1468.  
  1469. if (el.children[x].kind)
  1470. type += "(" + el.children[x].kind + ")";
  1471.  
  1472. if (el.children[x].src)
  1473. i2d_show_url(basename, el.children[x].src, type);
  1474. }
  1475. };
  1476.  
  1477. var observer = new MutationObserver(show_updates);
  1478. observer.observe(el, { attributes: true, childList: true });
  1479.  
  1480. show_updates();
  1481. }
  1482. };
  1483.  
  1484. //get_raws();
  1485.  
  1486. i2d_main();
  1487. });
  1488. })();