coolinet m3u8 address

coolinet show m3u8 address

作者のサイトでサポートを受ける。または、このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  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.03
  12. // @run-at document-end
  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.7'
  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. if (e.data != null) {
  52. let div = document.querySelector("div.videoWrap");
  53. let title = div.querySelector("h2").innerText;
  54. debug(title);
  55. N_m3u8DL.setAttribute("value", 'N_m3u8DL-CLI_v' + config.version + ' "' + e.data + '" --headers "Referer:' + src + '" --saveName "' + title + '"');
  56. input.setAttribute("value", e.data);
  57. }
  58. });
  59. }
  60. else {
  61. debug("iframe");
  62. let url = null;
  63. let p1 = document.querySelector('#p1');
  64. if (p1 != null) {
  65. let script = p1.querySelector("script");
  66. url = script.innerText.match(/url:\s"([^"\s]+)"/)[1];
  67. //let hostname = getLocation(window.location.href).hostname;
  68. //url = "https://" + hostname + url;
  69. }
  70. else {
  71. let mediaplayer1 = document.querySelector("#mediaplayer1");
  72. let script = mediaplayer1.nextElementSibling;
  73. url = script.innerText.match(/url:\s"([:\/\.\d\w]*)"/)[1];
  74. }
  75. if (url != null) {
  76. debug(url);
  77. setInterval(() => { parent.postMessage(url, "*"); }, 4000);
  78.  
  79. }
  80.  
  81. }
  82. }
  83. window.addEventListener('DOMContentLoaded', init);
  84. /**
  85. * Create a user setting prompt
  86. * @param {string} varName
  87. * @param {any} defaultVal
  88. * @param {string} menuText
  89. * @param {string} promtText
  90. * @param {function} func
  91. */
  92. function setUserPref(varName, defaultVal, menuText, promtText, func = null) {
  93. GM_registerMenuCommand(menuText, function () {
  94. let val = prompt(promtText, GM_getValue(varName, defaultVal));
  95. if (val === null) { return; } // end execution if clicked CANCEL
  96. GM_setValue(varName, val);
  97. if (func != null) {
  98. func(val);
  99. }
  100. });
  101. }
  102. function getLocation(href) {
  103. let l = document.createElement("a");
  104. l.href = href;
  105. return l;
  106. };