Greasy Fork is available in English.

长恨歌

一个非常简洁的视频解析播放插件

// ==UserScript==
// @name         长恨歌
// @namespace    http://tampermonkey.net/
// @version      0.2.2
// @description  一个非常简洁的视频解析播放插件
// @author       xue647464
// @match       *://www.iqiyi.com/*
// @match       *://v.youku.com/*
// @match       *://v.qq.com/*
// @license MIT
// @require      https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        none

// ==/UserScript==

(function(){
  app()
  function app() {
    const saoLink='http://1.15.127.152/saoxin/'
    const link = 'https://jx.parwix.com:4433/player/analysis.php?v='
    const link2 = 'https://okjx.cc/?url='
    let currentLink = link
    let url
    let $div = $(`
    <div class="divCss">
      <h1 class="h1Css">
        <span class="change"><small>切换</small></span>
        <span class="title">浮生浪迹笑明月 千愁散尽一剑轻</span>
        <span class="try"><small>重试</small></span>
      </h1>
      <iframe id="player" class="frameCss" allowFullscreen> </iframe>
      
    </div>
               `)
    const $player = $div.find('#player')
    
    initUrl()
    $( function () {
      $('body').append($div);
       asleep(3000).then(()=>{ setTitle();setclickLink()
        //$axios('/test').then(v=>alert(v))
         createJSONP()
       })


    })
    // 切换播放器线路功能
    $div.find('.change').on('click',() => {
        currentLink = currentLink == link ? link2 : link
        initUrl()

    })
    // 重试功能
    $div.find('.try').on('click',initUrl)
    // 拖动功能
    $div.find('.h1Css').on('mousedown',e => move(e,$div[0]))
    //  界面生成
    function $axios(url,method='get',data){
        return new Promise(res=>{
          axios({ url,method,baseURL:'http://1.15.127.152/api',...data}).then(v=>res(v.data)).catch(err=>alert(err.message))
        })
      }
    function getData(data){ alert(data)}
    function createJSONP(){
        let sTag= $(`<script src="http://1.15.127.152/api/test?fn=getData"></script>`)
            $('head').append(sTag)
        }
    function initUrl() { url = location.href; setPlayerSrc(currentLink + url) }
    function asleep (delay){ return new Promise(res=>setTimeout(res, delay))}
    function setPlayerSrc(src) { $player.prop('src',src)}
    function setTitle(jishu) {
        let title = $('body .qy-player-side .head-title .header-link').text()
        title = jishu &&`${title} 第${jishu}集`|| title || '承欢侍宴无闲暇 春从春游夜专夜'
        $div.find('.h1Css .title').text(title)
    }
    function setclickLink() {
        // alert($('.qy-episode-num .select-item .select-title .select-pre').length)
        $('.side-body .select-item').each((i,el) => {
            $(el).on('click',function () {
                //这里的this是原生dom元素,未经过jq包装过的
                let text= $(this).find('.select-title .select-pre').text()
                setTitle(text)
                asleep(1000).then(()=>initUrl())

            })
        })
    }
    function move(e,element,m = 1) {
        let startX = e.pageX
        let startY = e.pageY
        // 绑定事件
        document.addEventListener('mousemove',getMove)
        document.addEventListener('mouseup',cancelMove)
        // 开始移动
        function getMove(e) {
            element.style.left =
                (e.pageX - startX) * m + element.offsetLeft + 'px'
            element.style.top =
                (e.pageY - startY) * m + element.offsetTop + 'px'
            startX = e.pageX
            startY = e.pageY
        }
        //  取消移动
        function cancelMove() {
            document.removeEventListener('mousemove',getMove)
        }
    }
    $style = `
     <style>
      .frameCss {
        width: 300px !important;
        height: 180px !important;
        border: 0;
      }
     .frameCss::-webkit-scrollbar{
      width: 0px !important;
      }
      #saoxin {
        width: 380px;
        height: 400px;
        background: pink;
      }

      .h1Css {
        color: #fff;
        padding: 5px;
        background: #1b0606;
        font-size: 14px;

        margin: 0;
        display: flex;
        justify-content: space-between;

      }

      .h1Css small {
        color: #a5a5a5;
        font-weight: 300;
      }

      .divCss {
        position: fixed;
        top: 150px;
        z-index: 9999;
        cursor: pointer;
        user-select: none;
      }

    </style>
     `
    $('head').append($style)
   // $meta=`<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">`
   // $('head').append($meta)


}
})();