油猴腳本 xvideo下載(JS)



觀念


1.找到mp4的網址

2.插入按鈕

3.讓按鈕打開網頁 


[1.1] get elementbyid()

[2.1]   createElement btn

[3.1 ]

(a. ) onclick

(b.)  window.open    

(c.)         insertBefore

(d.)addEventListener




參考資源:



https://www.w3schools.com/jsref/event_createevent.asp




----------------------------------------------------

window.addEventListener('load', function(){

var cum

var s_html = `

  <div class="ct_div">


  <style>

      /*最外層的框*/

      .ct_div {

          background-color: #FFF;

          padding: 5px;

          padding-left: 11px;

      }


      /*「截圖」按鈕*/

      .but_ct {

          margin-top: 10px;

          padding: 3px 7px;

          border: 2px solid #00B4D8;

          color: #00B4D8;

          display: inline-block;

          text-align: center;

          line-height: 27px;

          font-size: 1.4em;

          margin-right: 10px;

      }


      .but_ct:hover {

          background-color: #00B4D8;

          border: 1px solid #00B4D8;

          color: #FFF;

          display: inline-block;



  </style>

  <div class="but_ct" >下載影片!</div>

  <span style="font-size:14px; color:rgb(100, 100, 100)">(快速鍵 「F8」)</span>



</div>

      `


     function gongneng(p,M) {

        var x,r,g,k,s,vid,Z;

        x = document.getElementsByTagName("div");

        r = x[14].textContent;

        r.match(/.mp4/).input;

        g = r.match(/.mp4/).input;

        k = g.split("{");

        try{

            s = k[42].match(/mp4/).input;

        }

        catch(e) {

            s = k[41].match(/mp4/).input;

        }

        vid = s.split(/VideoUrlHigh/)[1].split(/html5/)[0];

        Z = vid.replace("');", "");

        M = Z.replace("('", "");

       cum=M


     }



        function addbtn(p,M){

        let pretag = document.getElementsByTagName("div");

        p = pretag[14];

        let btn = document.createElement("div");

        btn.innerHTML = s_html;

        btn.onclick = ()=>{

            window.open(cum);

      }


        p.insertBefore(btn, p.childNodes[0]);


    }


    document.body.addEventListener("keydown", function (e) {

if (e.keyCode == 119) { //F8

            window.open(cum);

}

});


gongneng();


    addbtn();

document.getElementById("demo").style.fontSize = "larger";


});


留言