Inject2Download

Simple media download script

当前为 2016-09-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Inject2Download
  3. // @namespace http://lkubuntu.wordpress.com/
  4. // @version 0.2.5.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 twitter_injected = false;
  16. var vine_injected = false;
  17.  
  18. // Helper functions
  19. function i2d_show_url(namespace, url, description) {
  20. function get_absolute_url(url) {
  21. var a = document.createElement('a');
  22. a.href = url;
  23. return a.href;
  24. }
  25.  
  26. if (!description)
  27. description = "";
  28.  
  29. if (typeof url !== "string" || url.replace("\s", "").length === 0)
  30. return;
  31.  
  32. if (url.match(/^mediasource:/))
  33. return;
  34.  
  35. url = get_absolute_url(url);
  36.  
  37. if (!("i2d_url_list" in window))
  38. window.i2d_url_list = [];
  39.  
  40. for (var i = 0; i < i2d_url_list.length; i++) {
  41. if (i2d_url_list[i][0] === namespace &&
  42. i2d_url_list[i][1] === url &&
  43. i2d_url_list[i][2] === description)
  44. return;
  45. }
  46.  
  47.  
  48. i2d_url_list.push([namespace, url, description]);
  49.  
  50. var newurl = decodeURIComponent(url);
  51.  
  52. var text = "[" + namespace + "] " + description + ": ";
  53.  
  54. console.log("[i2d] " + text + newurl);
  55.  
  56. var el = document.getElementById("i2d-popup");
  57. if (!el) {
  58. el = document.createElement("div");
  59. //el.style.position = "absolute";
  60. el.style.width = "max(60%, 100em)";
  61. el.style.height = "max(60%, 100em)";
  62. el.style.maxWidth = "100%";
  63. el.style.maxHeight = "100%";
  64. el.style.background = "white";
  65. el.style.top = "0px";
  66. el.style.left = "0px";
  67. el.style.zIndex = 999999;
  68. el.style.color = "black";
  69. el.style.overflow = "scroll";
  70. el.ondblclick = function() {
  71. el.parentElement.removeChild(el);
  72. };
  73. el.innerHTML = "Double click to close<br />";
  74. el.id = "i2d-popup";
  75. document.body.appendChild(el);
  76. }
  77. el.innerHTML += text + "<a href='" + newurl + "' style='color:blue'>" + newurl + "</a><br />";
  78.  
  79. // XXX: why is this needed? test: http://playbb.me/embed.php?w=718&h=438&vid=at/nw/flying_witch_-_01.mp4, animeplus.tv
  80. document.body.removeChild(el);
  81. el.style.position = "absolute";
  82. document.body.appendChild(el);
  83. }
  84.  
  85.  
  86. // Injecting functions
  87. var get_script_str = function(f) {
  88. return f.toString().replace(/^function.*{|}$/g, '');
  89. };
  90.  
  91. function add_script(s, el) {
  92. var script_body = "(function() {\n" + s + "\n})();";
  93. var myscript = document.createElement('script');
  94. myscript.className = "i2d";
  95. myscript.innerHTML = script_body;
  96. if (el) {
  97. el.appendChild(myscript);
  98. } else {
  99. document.head.appendChild(myscript);
  100. }
  101. }
  102.  
  103. function inject(variable, newvalue, aliases) {
  104. console.log("[i2d] injecting " + variable);
  105. if (!aliases)
  106. aliases = [];
  107.  
  108. add_script(i2d_show_url.toString() + "\n" +
  109. "if (!(window." + variable + ".INJECTED)) {\n" +
  110. "var oldvariable = window." + variable + ";\n" +
  111. "var oldvariable_keys = Object.keys(oldvariable);\n" +
  112. "window." + variable + " = " + newvalue.toString() + ";\n" +
  113. "for (var i = 0; i < oldvariable_keys.length; i++) {\n" +
  114. " window." + variable + "[oldvariable_keys[i]] = oldvariable[oldvariable_keys[i]];\n" +
  115. "}\n" +
  116. "window." + variable + ".INJECTED = true;\n" +
  117. "var aliases = " + JSON.stringify(aliases) + ";\n" +
  118. "for (var i = 0; i < aliases.length; i++) {\n" +
  119. " if (aliases[i] in window && window[aliases[i]] == oldvariable)" +
  120. " window[aliases[i]] = window." + variable + "\n" +
  121. "}\n" +
  122. "}");
  123. }
  124.  
  125. function jquery_plugin_exists(name) {
  126. if (!("jQuery" in window) ||
  127. !("fn" in window.jQuery) ||
  128. !(name in window.jQuery.fn))
  129. return false;
  130.  
  131. return true;
  132. }
  133.  
  134. function inject_jquery_plugin(name, value) {
  135. if (!jquery_plugin_exists(name) ||
  136. window.jQuery.fn[name].INJECTED)
  137. return;
  138.  
  139. inject("jQuery.fn." + name, value);
  140. }
  141.  
  142. function i2d_onload(f) {
  143. if (document.readyState === "loading") {
  144. document.addEventListener("DOMContentLoaded", f);
  145. } else {
  146. f();
  147. }
  148. }
  149.  
  150.  
  151. // Main code
  152. function i2d_main(e) {
  153. if (e) {
  154. if (!e.tagName || e.tagName.toLowerCase() !== "script")
  155. return;
  156. if ((e.className === "i2d")) {
  157. return;
  158. }
  159. }
  160.  
  161. if ("soundManager" in window && !window.soundManager.INJECTED) {
  162. inject("soundManager.createSound", function(arg1, arg2) {
  163. if (typeof arg1 === "string")
  164. i2d_show_url("soundManager", arg2);
  165. else
  166. i2d_show_url("soundManager", arg1.url);
  167.  
  168. return oldvariable.apply(this, arguments);
  169. });
  170. }
  171.  
  172. if ("jwplayer" in window && !window.jwplayer.INJECTED) {
  173. inject("jwplayer", function() {
  174. var result = oldvariable.apply(this, arguments);
  175.  
  176. var check_sources = function(x) {
  177. if (typeof x === "object") {
  178. if (x instanceof Array) {
  179. for (var i = 0; i < x.length; i++) {
  180. check_sources(x[i]);
  181. }
  182. return;
  183. }
  184.  
  185. var label = "";
  186.  
  187. if ("title" in x)
  188. label += "[" + x.title + "]";
  189.  
  190. if ("label" in x)
  191. label += "[" + x.label + "]";
  192.  
  193. if ("streamer" in x) {
  194. i2d_show_url("jwplayer", x.streamer, "[stream]" + label);
  195. }
  196.  
  197. if ("file" in x) {
  198. i2d_show_url("jwplayer", x.file, label);
  199. }
  200.  
  201. if ("sources" in x) {
  202. check_sources(x.sources);
  203. }
  204.  
  205. if ("playlist" in x) {
  206. check_sources(x.playlist);
  207. }
  208. } else if (typeof x === "string") {
  209. i2d_show_url("jwplayer", x);
  210. }
  211. };
  212.  
  213. if ("setup" in result) {
  214. var old_jwplayer_setup = result.setup;
  215. result.setup = function() {
  216. if (typeof arguments[0] === "object") {
  217. var x = arguments[0];
  218.  
  219. if ("modes" in x) {
  220. for (var i = 0; i < x.modes.length; i++) {
  221. // TODO: support more?
  222. if ("type" in x.modes[i] && x.modes[i].type === "html5") {
  223. if ("config" in x.modes[i] && "file" in x.modes[i].config) {
  224. check_sources(x.modes[i].config);
  225. }
  226. }
  227. }
  228. }
  229.  
  230. check_sources(x);
  231. }
  232.  
  233. return old_jwplayer_setup.apply(this, arguments);
  234. };
  235. }
  236.  
  237. if ("load" in result) {
  238. var old_jwplayer_load = result.load;
  239. result.load = function() {
  240. check_sources(arguments[0]);
  241. return old_jwplayer_load.apply(this, arguments);
  242. };
  243. }
  244.  
  245. if ("on" in result) {
  246. result.on('playlistItem', function(item) {
  247. check_sources(item.item);
  248. });
  249.  
  250. var old_jwplayer_on = result.on;
  251. result.on = function() {
  252. if (arguments[0] === "adBlock")
  253. return;
  254.  
  255. return old_jwplayer_on.apply(this, arguments);
  256. };
  257. }
  258.  
  259. return result;
  260. });
  261. }
  262.  
  263. if ("flowplayer" in window && !window.flowplayer.INJECTED) {
  264. inject("flowplayer", function() {
  265. var obj_baseurl = null;
  266. var els = [];
  267.  
  268. function get_url(x) {
  269. x = decodeURIComponent(x);
  270.  
  271. if (obj_baseurl) {
  272. if (x.match(/^[a-z]*:\/\//)) {
  273. return x;
  274. } else {
  275. return obj_baseurl + "/" + x;
  276. }
  277. } else {
  278. return x;
  279. }
  280. }
  281.  
  282. function check_sources(x, els, label) {
  283. if (typeof x === "string") {
  284. if (!x.match(/\.xml$/))
  285. i2d_show_url("flowplayer", get_url(x), label);
  286.  
  287. return;
  288. }
  289.  
  290. if (x instanceof Array) {
  291. for (var i = 0; i < x.length; i++) {
  292. check_sources(x[i], els, label);
  293. }
  294. return;
  295. }
  296.  
  297. if (typeof x !== "object")
  298. return;
  299.  
  300. label = "";
  301.  
  302. if ("title" in x)
  303. label += "[" + x.title + "]";
  304.  
  305. if ("clip" in x) {
  306. if ("baseUrl" in x.clip) {
  307. obj_baseurl = x.clip.baseUrl;
  308.  
  309. for (var i = 0; i < els.length; i++) {
  310. els[i].i2d_baseurl = obj_baseurl;
  311. }
  312. }
  313.  
  314. check_sources(x.clip, els, label);
  315. }
  316.  
  317. if ("sources" in x) {
  318. check_sources(x.sources, els, label);
  319. }
  320.  
  321. if ("playlist" in x) {
  322. check_sources(x.playlist, els, label);
  323. }
  324.  
  325. if ("url" in x) {
  326. check_sources(x.url, els, label);
  327. }
  328.  
  329. if ("src" in x) {
  330. check_sources(x.src, els. label);
  331. }
  332.  
  333. if ("bitrates" in x) {
  334. for (var j = 0; j < x.bitrates.length; j++) {
  335. if ("url" in x.bitrates[j]) {
  336. var description = "";
  337. if (x.bitrates[j].isDefault)
  338. description += "default:";
  339. if (x.bitrates[j].sd)
  340. description += "sd:";
  341. if (x.bitrates[j].hd)
  342. description += "hd:";
  343. if (x.bitrates[j].bitrate)
  344. description += x.bitrates[j].bitrate;
  345.  
  346. i2d_show_url("flowplayer", get_url(x.bitrates[j].url), description);
  347. }
  348. }
  349. }
  350. }
  351.  
  352. if (arguments.length >= 1) {
  353. els = [null];
  354.  
  355. if (typeof arguments[0] === "string") {
  356. try {
  357. els[0] = document.getElementById(arguments[0]);
  358. } catch(e) {
  359. }
  360.  
  361. try {
  362. if (!els[0])
  363. els = document.querySelectorAll(arguments[0]);
  364. } catch(e) {
  365. els = [];
  366. }
  367. } else if (arguments[0] instanceof HTMLElement) {
  368. els = [arguments[0]];
  369. }
  370. }
  371.  
  372. for (var i = 0; i < els.length; i++) {
  373. if (!els[i] || !(els[i] instanceof HTMLElement))
  374. continue;
  375.  
  376. if ("i2d_baseurl" in els[i])
  377. obj_baseurl = els[i].i2d_baseurl;
  378. }
  379.  
  380. if (arguments.length >= 3 && typeof arguments[2] === "object") {
  381. check_sources(arguments[2], els);
  382. } else if (arguments.length >= 3 && typeof arguments[2] === "string") {
  383. i2d_show_url("flowplayer", get_url(arguments[2]));
  384. } else if (arguments.length === 2 && typeof arguments[1] === "object") {
  385. check_sources(arguments[1], els);
  386. } else if (arguments.length === 2 && typeof arguments[1] === "string") {
  387. i2d_show_url("flowplayer", get_url(arguments[1]));
  388. }
  389.  
  390. for (var i = 0; i < els.length; i++) {
  391. if (!els[i] || !(els[i] instanceof HTMLElement))
  392. continue;
  393.  
  394. var href = els[i].getAttribute("href");
  395. if (href) {
  396. i2d_show_url("flowplayer", get_url(href), "href");
  397. }
  398. }
  399.  
  400. var result = oldvariable.apply(this, arguments);
  401.  
  402. if (!result || typeof result !== "object")
  403. return result;
  404.  
  405. if ("addClip" in result) {
  406. var old_fplayer_addclip = result.addClip;
  407. result.addClip = function() {
  408. if (arguments.length > 0)
  409. check_sources(arguments[0], els);
  410.  
  411. return old_fplayer_addclip.apply(this, arguments);
  412. };
  413. }
  414.  
  415. if ("setPlaylist" in result) {
  416. var old_fplayer_setplaylist = result.setPlaylist;
  417. result.setPlaylist = function() {
  418. if (arguments.length > 0)
  419. check_sources(arguments[0], els);
  420.  
  421. return old_fplayer_setplaylist.apply(this, arguments);
  422. };
  423. }
  424.  
  425. if ("load" in result) {
  426. var old_fplayer_load = result.load;
  427. result.load = function() {
  428. if (arguments.length > 0)
  429. check_sources(arguments[0], els);
  430.  
  431. return old_fplayer_load.apply(this, arguments);
  432. };
  433. }
  434.  
  435. /*if ("on" in result) {
  436. result.on("load", function(e, api, video) {
  437. console.log(e);
  438. check_sources(video || api.video, els);
  439. });
  440. }*/
  441.  
  442. return result;
  443. }, ["$f"]);
  444.  
  445. add_script(get_script_str(function() {
  446. flowplayer(function(api, root) {
  447. api.on("load", function(e, api, video) {
  448. flowplayer().load(video || api.video);
  449. });
  450. });
  451. }));
  452. }
  453.  
  454. if ("videojs" in window && !window.videojs.INJECTED) {
  455. inject("videojs", function() {
  456. if (arguments.length > 0 && typeof arguments[0] === "string") {
  457. var my_el = document.getElementById(arguments[0]);
  458. if (!my_el)
  459. my_el = document.querySelector(arguments[0]);
  460.  
  461. if (my_el) {
  462. if (my_el.src) {
  463. i2d_show_url("videojs", my_el.src);
  464. }
  465.  
  466. for (var i = 0; i < my_el.children.length; i++) {
  467. if (my_el.children[i].tagName.toLowerCase() === "source") {
  468. if (my_el.children[i].src) {
  469. i2d_show_url("videojs", my_el.children[i].src, my_el.children[i].getAttribute("label"));
  470. }
  471. }
  472. }
  473. }
  474. }
  475.  
  476. var result = oldvariable.apply(this, arguments);
  477.  
  478. var old_videojs_src = result.src;
  479. result.src = function() {
  480. if (arguments.length > 0 && typeof arguments[0] === "object") {
  481. if ("src" in arguments[0]) {
  482. i2d_show_url("videojs", arguments[0].src);
  483. }
  484. }
  485.  
  486. return old_videojs_src.apply(this, arguments);
  487. };
  488.  
  489. return result;
  490. });
  491.  
  492. add_script(i2d_show_url.toString() +
  493. i2d_onload.toString() +
  494. get_script_str(function() {
  495. i2d_onload(function() {
  496. var els = document.getElementsByClassName("video-js");
  497. for (var i = 0; i < els.length; i++) {
  498. var my_el = els[i];
  499. if (my_el.tagName.toLowerCase() === "video") {
  500. if (!my_el.getAttribute('data-setup')) {
  501. continue;
  502. }
  503. if (my_el.src) {
  504. i2d_show_url("videojs", my_el.src);
  505. }
  506.  
  507. for (var j = 0; j < my_el.children.length; j++) {
  508. if (my_el.children[j].tagName.toLowerCase() === "source") {
  509. if (my_el.children[j].src) {
  510. i2d_show_url("videojs", my_el.children[j].src, my_el.children[j].getAttribute("label"));
  511. }
  512. }
  513. }
  514. }
  515. }
  516. });
  517. }));
  518. }
  519.  
  520. if ("amp" in window && !window.amp.INJECTED) {
  521. inject("amp", function() {
  522. function show_amp_source(sourceobj) {
  523. if ("protectionInfo" in sourceobj) {
  524. console.log("[amp] Cannot decode protection info");
  525. }
  526. if ("src" in sourceobj)
  527. i2d_show_url("amp", sourceobj.src);
  528. }
  529.  
  530. if (arguments.length >= 2 && typeof arguments[1] === "object") {
  531. if ("sourceList" in arguments[1]) {
  532. for (var i = 0; i < arguments[1].sourceList.length; i++) {
  533. show_amp_source(arguments[1].sourceList[i]);
  534. }
  535. }
  536. }
  537.  
  538. var result = oldvariable.apply(this, arguments);
  539.  
  540. if (!result)
  541. return result;
  542.  
  543. var old_amp_src = result.src;
  544. result.src = function() {
  545. for (var i = 0; i < arguments[0].length; i++) {
  546. show_amp_source(arguments[0][i]);
  547. }
  548.  
  549. return old_amp_src.apply(this, arguments);
  550. };
  551.  
  552. return result;
  553. });
  554. }
  555.  
  556. if ("DJPlayer" in window && !window.DJPlayer.INJECTED) {
  557. add_script(i2d_show_url.toString() + "\n" +
  558. "var oldsetmedia = window.DJPlayer.prototype.setMedia;\n" +
  559. "window.DJPlayer.prototype.setMedia = function() {\n" +
  560. " if (arguments.length > 0 && typeof arguments[0] === 'string') {\n" +
  561. " i2d_show_url('DJPlayer', arguments[0]);\n" +
  562. " }\n" +
  563. " return oldsetmedia.apply(this, arguments);\n" +
  564. "}");
  565. }
  566.  
  567. if (("location" in window) && window.location && window.location.host.search("forvo") >= 0 && "createAudioObject" in window && !window.createAudioObject.INJECTED) {
  568. inject("createAudioObject", function(id, mp3, ogg) {
  569. i2d_show_url("forvo", mp3, "mp3");
  570. i2d_show_url("forvo", ogg, "ogg");
  571.  
  572. return oldvariable.apply(this, arguments);
  573. });
  574. }
  575.  
  576. if (("location" in window) && window.location && window.location.href.search("twitter.com/i/videos") >= 0 && !twitter_injected) {
  577. twitter_injected = true;
  578.  
  579. i2d_onload(function() {
  580. var pc = document.getElementById('playerContainer');
  581. if (!pc) {
  582. return;
  583. }
  584.  
  585. var config = pc.getAttribute('data-config');
  586. if (!config) {
  587. return;
  588. }
  589.  
  590. var config_parsed = JSON.parse(config);
  591.  
  592. if ("video_url" in config_parsed) {
  593. i2d_show_url('twitter', config_parsed.video_url);
  594. }
  595. });
  596. }
  597.  
  598. if (("location" in window) && window.location && window.location.href.search("vine.co/v/") >= 0 && !vine_injected) {
  599. vine_injected = true;
  600.  
  601. i2d_onload(function() {
  602. var config_el = document.getElementById("configuration");
  603. if (!config_el) {
  604. return;
  605. }
  606.  
  607. var config = JSON.parse(config_el.innerHTML);
  608. if (!config || typeof config !== "object") {
  609. return;
  610. }
  611.  
  612. if (!("post" in config) || !("videoUrls" in config.post)) {
  613. return;
  614. }
  615.  
  616. for (var i = 0; i < config.post.videoUrls.length; i++) {
  617. var videourl = config.post.videoUrls[i];
  618.  
  619. var formatstr = "[";
  620. formatstr += videourl.format + ":";
  621. formatstr += videourl.idStr;
  622.  
  623. if (videourl.rate > 0)
  624. formatstr += ", " + videourl.rate;
  625.  
  626. formatstr += "]";
  627.  
  628. i2d_show_url('vine', videourl.videoUrl, formatstr);
  629. }
  630. });
  631. }
  632.  
  633. if ("jQuery" in window) {
  634. inject_jquery_plugin("jPlayer", function() {
  635. if (arguments.length > 0 && arguments[0] === "setMedia") {
  636. if (arguments.length > 1) {
  637. if (typeof arguments[1] === "object") {
  638. for (var i in arguments[1]) {
  639. if (i === "title" ||
  640. i === "duration" ||
  641. i === "track" /* for now */ ||
  642. i === "artist" ||
  643. i === "free")
  644. continue;
  645.  
  646. i2d_show_url("jPlayer", arguments[1][i], i);
  647. }
  648. } else if (typeof arguments[1] === "string") {
  649. i2d_show_url("jPlayer", arguments[1]);
  650. }
  651. }
  652. }
  653.  
  654. return oldvariable.apply(this, arguments);
  655. });
  656.  
  657. inject_jquery_plugin("amazingaudioplayer", function() {
  658. var result = oldvariable.apply(this, arguments);
  659.  
  660. function add_source_obj(x) {
  661. type = "";
  662. if ("type" in x) {
  663. type = x.type;
  664. }
  665.  
  666. i2d_show_url("amazingaudioplayer", x.src, type);
  667. }
  668.  
  669. function add_source(x) {
  670. if (x instanceof Array) {
  671. for (var i = 0; i < x.length; i++) {
  672. add_source_obj(x[i]);
  673. }
  674. } else {
  675. add_source_obj(x);
  676. }
  677. }
  678.  
  679. var audioplayer = jQuery(this).data("object").audioPlayer;
  680. if (audioplayer.audioItem) {
  681. add_source(audioplayer.audioItem.source);
  682. }
  683.  
  684. var oldload = audioplayer.load;
  685. audioplayer.load = function(item) {
  686. if ("source" in item) {
  687. add_source(item.source);
  688. }
  689.  
  690. return oldload.apply(this, arguments);
  691. };
  692.  
  693. return result;
  694. });
  695.  
  696. if (jquery_plugin_exists("jPlayerAudio") && !window.jQuery.fn.jPlayerAudio.INJECTED) {
  697. inject_jquery_plugin("jPlayerAudio", function() {
  698. return oldvariable.apply(this, arguments);
  699. });
  700.  
  701. add_script(i2d_show_url.toString() + "\n" +
  702. "var oldmedia=jQuery.jPlayerAudio.prototype.setMedia;\n" +
  703. "jQuery.jPlayerAudio.prototype.setMedia = function(e) {\n" +
  704. " var absolute = this._absoluteMediaUrls(e);\n" +
  705. " jQuery.each(this.formats, function(a, o) {\n" +
  706. " i2d_show_url('cleanaudioplayer', absolute[o]);\n" +
  707. " });\n" +
  708. " return oldmedia.apply(this, arguments);\n" +
  709. "}");
  710. }
  711.  
  712. if (jquery_plugin_exists("jPlayerVideo") && !window.jQuery.fn.jPlayerVideo.INJECTED) {
  713. inject_jquery_plugin("jPlayerVideo", function() {
  714. return oldvariable.apply(this, arguments);
  715. });
  716.  
  717. add_script(i2d_show_url.toString() + "\n" +
  718. "var oldmedia=jQuery.jPlayerVideo.prototype.setMedia;\n" +
  719. "jQuery.jPlayerVideo.prototype.setMedia = function(e) {\n" +
  720. " var absolute = this._absoluteMediaUrls(e);\n" +
  721. " jQuery.each(this.formats, function(a, o) {\n" +
  722. " i2d_show_url('cleanvideoplayer', absolute[o]);\n" +
  723. " });\n" +
  724. " return oldmedia.apply(this, arguments);\n" +
  725. "}");
  726. }
  727. }
  728. }
  729.  
  730. i2d_main();
  731.  
  732. window.addEventListener("afterscriptexecute", function(e) {
  733. i2d_main(e.target);
  734. });
  735.  
  736. i2d_onload(function() {
  737. var get_raws = function() {
  738. var audios = [].slice.call(document.getElementsByTagName("audio"));
  739. var videos = [].slice.call(document.getElementsByTagName("video"));
  740. var els = Array.prototype.concat(audios, videos);
  741.  
  742. for (var i = 0; i < els.length; i++) {
  743. var basename = "raw ";
  744. var el = els[i];
  745.  
  746. if (el.tagName.toLowerCase() === "video") {
  747. basename += "video";
  748. } else {
  749. basename += "audio";
  750. }
  751.  
  752. if (el.id)
  753. basename += ": #" + el.id;
  754.  
  755. var show_updates = function() {
  756. if (el.src)
  757. i2d_show_url(basename, el.src);
  758.  
  759. for (var x = 0; x < el.children.length; x++) {
  760. if (els[i].children[x].tagName.toLowerCase() !== "source") {
  761. continue;
  762. }
  763.  
  764. var type = null;
  765. if (el.children[x].type)
  766. type = el.children[x].type;
  767.  
  768. if (el.children[x].src)
  769. i2d_show_url(basename, el.children[x].src, type);
  770. }
  771. };
  772.  
  773. var observer = new MutationObserver(show_updates);
  774. observer.observe(el, { attributes: true, childList: true });
  775.  
  776. show_updates();
  777. }
  778. };
  779.  
  780. get_raws();
  781.  
  782. i2d_main();
  783. });
  784. })();