m3u8

替换JS网页播放器

  1. // ==UserScript==
  2. // @name m3u8
  3. // @namespace https://greasyfork.org/zh-CN/users/235730-jangj001
  4. // @version 0.1
  5. // @description 替换JS网页播放器
  6. // @author QQ:1073481777
  7. // @include *
  8. // @grant none
  9. // @run-at document-start
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. globalThis.geturl='';
  15.  
  16. function inject(){
  17. var domStr = `<input type="submit" id="m3u8-jump" value="跳转下载" class="bgs_btn">`
  18. var div = document.createElement('div')
  19. div.innerHTML = domStr
  20. div.style.position = 'fixed'
  21. div.style.zIndex = '9999'
  22. div.style.bottom = '20px'
  23. div.style.right = '20px'
  24. div.style.textAlign = 'center'
  25. document.body.appendChild(div);
  26.  
  27. var m3u8Jump = document.getElementById('m3u8-jump')
  28. m3u8Jump.addEventListener('click', function () {
  29. window.open('https://jx.wujinkk.com/dplayer/?url='+globalThis.geturl);
  30. })
  31.  
  32. }
  33.  
  34.  
  35. var originXHR = window.XMLHttpRequest;
  36. var stop=false;
  37. var urls=[];
  38. function hookAjax() {
  39. var originOpen = originXHR.prototype.open;
  40. window.XMLHttpRequest = function () {
  41. var realXHR = new originXHR();
  42. realXHR.open = function (method, url) {
  43. if(!stop){
  44. originOpen.call(realXHR, method, url)
  45. console.log(url+'\n');
  46. if(url.indexOf('.m3u8') > 0){
  47. urls.push(url);
  48. if(urls.length>0){
  49. stop=true;
  50. console.log(urls.length+'\n'+urls[urls.length-1]);
  51. globalThis.geturl=urls[urls.length-1];
  52.  
  53. }
  54.  
  55. }
  56. }
  57. }
  58. return realXHR
  59. }
  60. }
  61. setInterval(hookAjax(),1000);
  62. console.log(globalThis.geturl);
  63. var set=setInterval(()=>{
  64. if (document.getElementById("m3u8-jump")==null){
  65. inject();
  66. console.log(globalThis.geturl);
  67. }
  68. },1000);
  69. setInterval(()=>{if (document.getElementById("m3u8-jump")){ clearInterval(set)}},1000);
  70.  
  71. })();