PlayOrDownload

We Should try!

  1. // ==UserScript==
  2. // @name PlayOrDownload
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description We Should try!
  6. // @author You
  7. // @match https://x99av.com/video/**
  8. // @match https://api.theporn.xyz/video/**
  9. // @icon https://www.google.com/s2/favicons?domain=x99av.com
  10. // @grant none
  11. // ==/UserScript==
  12. /*jshint esversion: 6 */
  13.  
  14.  
  15. var num = -1;
  16. var localhost;
  17. var m3u8_ClassName;
  18. var video_play;
  19.  
  20.  
  21. function addDIV(video_play,num){
  22.  
  23.  
  24. console.log("host:"+localhost);
  25. let btn1 = document.createElement("button");
  26. btn1.setAttribute("id","btn1")
  27.  
  28. let btn2 = document.createElement("button");
  29. btn2.setAttribute("id","btn2")
  30. let videoTg = document.getElementById(video_play);
  31. if(!videoTg){
  32. videoTg = document.getElementById("orginal_video_player").parentNode;
  33. }else {
  34. videoTg = document.getElementById(video_play).parentNode;
  35. }
  36. btn1.innerHTML = "播放";
  37. btn2.innerHTML = "下载";
  38.  
  39. videoTg.appendChild(btn1);
  40. videoTg.appendChild(btn2);
  41.  
  42.  
  43.  
  44. document.getElementById("btn1").onclick=function () {
  45.  
  46. window.open("http://www.m3u8player.top/?play="+localhost+findM3U8());};
  47.  
  48.  
  49. document.getElementById("btn2").onclick=function () {
  50.  
  51. window.open("https://blog.luckly-mjw.cn/tool-show/m3u8-downloader/index.html?source="+localhost+findM3U8());};
  52. };
  53.  
  54.  
  55.  
  56.  
  57. function findM3U8(m3u8_className) {
  58. let sc = document.getElementsByClassName(m3u8_ClassName)[0].getElementsByTagName("script")[0].innerHTML;
  59. let m3u8 = sc.substring(sc.indexOf("/video/"),sc.indexOf("m3u8?et=")+4);
  60. console.log("m3u8:"+m3u8)
  61.  
  62. if (m3u8==null||m3u8==''){
  63. alert("m3u8为空")
  64. return ;
  65. };
  66.  
  67.  
  68.  
  69. // let input = document.getElementById("customInput");
  70. // input.value = m3u8;
  71. // input.select();
  72. // document.execCommand("copy");
  73. // alert(m3u8);
  74.  
  75. return m3u8;
  76. };
  77.  
  78. function play(){
  79.  
  80.  
  81. }
  82.  
  83. function isReady(){
  84. let url = window.location.href;
  85. if(url.includes("https://x99av.com/")){
  86. video_play="video-player-container";
  87. m3u8_ClassName = "pb-3 pb-e-lg-30 __player__container";
  88.  
  89. }else if(url.includes("https://api.theporn.xyz/")){
  90. video_play="download-button";
  91. m3u8_ClassName = "ui 16:9 embed color-loader";
  92. }
  93. localhost ="https://"+ window.location.host;
  94. let b1 = url.search("video") !=-1;
  95. let b2 = url.search("m3u8") ==-1;
  96. let b = b1&&b2;
  97. console.log(b);
  98. if (!b){
  99. return;
  100. }
  101. console.log("video_play"+video_play);
  102. console.log(" m3u8_ClassName"+ m3u8_ClassName)
  103. addDIV(video_play,num);
  104. }
  105. window.onload = function(){ isReady();}
  106.  
  107.  
  108.  
  109.  
  110.