coolinet m3u8 address

coolinet show m3u8 address

От 07.04.2021. Виж последната версия.

  1. // ==UserScript==
  2. // @name coolinet m3u8 address
  3. // @name:zh-TW coolinet m3u8 address
  4. // @name:zh-CN coolinet m3u8 address
  5. // @supportURL https://github.com/zhuzemin
  6. // @description coolinet show m3u8 address
  7. // @description:zh-CN coolinet show m3u8 address
  8. // @description:zh-TW coolinet show m3u8 address
  9. // @include https://www.coolinet.net/*
  10. // @include https://video1.yocoolnet.in/api/player_coolinet.php?*
  11. // @version 1.02
  12. // @run-at document-start
  13. // @author zhuzemin
  14. // @license Mozilla Public License 2.0; http://www.mozilla.org/MPL/2.0/
  15. // @license CC Attribution-ShareAlike 4.0 International; http://creativecommons.org/licenses/by-sa/4.0/
  16. // @grant GM_registerMenuCommand
  17. // @grant GM_setValue
  18. // @grant GM_getValue
  19. // @namespace coolinet_display_m3u8_address
  20. // ==/UserScript==
  21. let config = {
  22. 'debug': false,
  23. 'version': GM_getValue('version') || '2.9.1'
  24. };
  25. let debug = config.debug ? console.log.bind(console) : function () {
  26. };
  27. // prepare UserPrefs
  28. setUserPref(
  29. 'version',
  30. config.version,
  31. 'Set N_m3u8DL version',
  32. `Set N_m3u8DL version`,
  33. );
  34. let init = function () {
  35. if (window.self === window.top) {
  36. let input = document.createElement("input");
  37. input.setAttribute("type", "text");
  38. input.size = window.screen.width;
  39. document.body.insertBefore(input, document.body.firstChild);
  40. let N_m3u8DL = document.createElement("input");
  41. N_m3u8DL.setAttribute("type", "text");
  42. N_m3u8DL.size = window.screen.width;
  43. document.body.insertBefore(N_m3u8DL, document.body.firstChild);
  44. let allmyplayer = document.querySelector("#allmyplayer");
  45. let src = "https:" + allmyplayer.getAttribute("src");
  46. let hostname = getLocation(src).hostname;
  47. debug(hostname);
  48. window.addEventListener('message', function (e) {
  49. debug(e.data);
  50. if (e.data.includes(hostname)) {
  51. let div = document.querySelector("div.videoWrap");
  52. let title = div.querySelector("h2").innerText;
  53. debug(title);
  54. N_m3u8DL.setAttribute("value", 'N_m3u8DL-CLI_v' + config.version + ' "' + e.data + '" --headers "Referer:' + src + '" --saveName "' + title + '"');
  55. input.setAttribute("value", e.data);
  56. }
  57. });
  58. }
  59. else {
  60. let url = null;
  61. let p1 = document.querySelector('#p1');
  62. if (p1 != null) {
  63. let script = p1.querySelector("script");
  64. url = script.innerText.match(/url:\s"([\/\.\d\w]*)"/)[1];
  65. let hostname = getLocation(window.location.href).hostname;
  66. url = "https://" + hostname + url;
  67. }
  68. else {
  69. let mediaplayer1 = document.querySelector("#mediaplayer1");
  70. let script = mediaplayer1.nextElementSibling;
  71. url = script.innerText.match(/url:\s"([:\/\.\d\w]*)"/)[1];
  72. }
  73. debug(url);
  74. setInterval(()=>{parent.postMessage(url, "*");},4000);
  75. }
  76. }
  77. window.addEventListener('DOMContentLoaded', init);
  78. /**
  79. * Create a user setting prompt
  80. * @param {string} varName
  81. * @param {any} defaultVal
  82. * @param {string} menuText
  83. * @param {string} promtText
  84. * @param {function} func
  85. */
  86. function setUserPref(varName, defaultVal, menuText, promtText, func = null) {
  87. GM_registerMenuCommand(menuText, function () {
  88. let val = prompt(promtText, GM_getValue(varName, defaultVal));
  89. if (val === null) { return; } // end execution if clicked CANCEL
  90. GM_setValue(varName, val);
  91. if (func != null) {
  92. func(val);
  93. }
  94. });
  95. }
  96. function getLocation(href) {
  97. let l = document.createElement("a");
  98. l.href = href;
  99. return l;
  100. };