live-streaming-url

获取虎牙直播视频流地址

  1. // ==UserScript==
  2. // @name live-streaming-url
  3. // @namespace tampermonkey
  4. // @version 0.1
  5. // @description 获取虎牙直播视频流地址
  6. // @author microJ
  7. // @match https://www.huya.com/*
  8. // @grant none
  9. // @homepage https://github.com/microJ/live-streaming-url
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. "use strict";
  14.  
  15. const streamResultBox = document.createElement("div");
  16.  
  17. try {
  18. const hyPlayerConfig = window.hyPlayerConfig;
  19. if (!hyPlayerConfig) return;
  20.  
  21. const streamList = hyPlayerConfig.stream.data[0].gameStreamInfoList.map(
  22. (info) => {
  23. return `${info.sHlsUrl}/${info.sStreamName}.m3u8`;
  24. }
  25. );
  26.  
  27. streamResultBox.style = `
  28. z-index: 999999;
  29. position: fixed;
  30. top: 0;
  31. left: 0;
  32. `;
  33.  
  34. const hover = document.createElement("div");
  35. hover.innerHTML = "show live-streaming-url";
  36.  
  37. const closeBtn = document.createElement("span");
  38. closeBtn.innerHTML = "X";
  39. closeBtn.style = `
  40. display: inline-block;
  41. padding: 0 10px;
  42. border-radius: 4px;
  43. background: red;
  44. cursor: pointer;
  45. `;
  46. hover.appendChild(closeBtn);
  47.  
  48. const resultText = document.createElement("div");
  49. resultText.innerHTML = streamList.reduce(
  50. (text, stream) => `${text}${stream}<br>`,
  51. ""
  52. );
  53. resultText.style = `
  54. display: none;
  55. padding: 10px;
  56. background-color: #fff;
  57. `;
  58.  
  59. function handleCloseBtnClick() {
  60. streamResultBox.onmouseenter = null;
  61. document.body.removeChild(streamResultBox);
  62. }
  63.  
  64. function handleStreamResultBoxMouseleave() {
  65. console.log(123);
  66. closeBtn.removeEventListener("click", handleCloseBtnClick);
  67. resultText.style.display = "none";
  68. }
  69.  
  70. streamResultBox.onmouseenter = function () {
  71. closeBtn.addEventListener("click", handleCloseBtnClick);
  72. resultText.style.display = "block";
  73. };
  74.  
  75. streamResultBox.onmouseleave = function () {
  76. closeBtn.removeEventListener("click", handleCloseBtnClick);
  77. resultText.style.display = "none";
  78. };
  79.  
  80. streamResultBox.appendChild(hover);
  81. streamResultBox.appendChild(resultText);
  82. document.body.appendChild(streamResultBox);
  83. } catch (err) {
  84. console.log("--------->");
  85. console.log(err);
  86. streamResultBox && document.body.removeChild(streamResultBox);
  87. }
  88. })();

QingJ © 2025

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