Sleazy Fork is available in English.

91无限次观看脚本

解决91观看次数的问题

目前為 2018-05-12 提交的版本,檢視 最新版本

// ==UserScript==
// @name         91无限次观看脚本
// @namespace    http://91porn.com/
// @version      0.92
// @description  解决91观看次数的问题
// @author       https://t.me/nrop19

// @include      http*://91porn.com/*
// @include      http*://www.91porn.com/*
// @include      http://*.*p*.space/*

// @grant        GM_xmlhttpRequest
// @grant        GM_addStyle
//
// ==/UserScript==

(function() {
    let href = window.location.href;
    if(!href.match(/(?:index|v|video|uvideos|view_video).php.*/))
        return;
    let videoListPageStyle=`
.video-layer{
display: none;
color: #fff;
font-size: 16px;
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 101;
}

.video-bg{background: rgba(0,0,0,0.7);}

.video-show{
display: flex !important;
align-items: center;
justify-content: center;
}

.video-layer-close{
cursor: pointer;
position: absolute;
right: 5px;
top: 5px;
}
.video-layer-close img{width: 28px;}

.video-layer .video-content{
position: relative;
border: 2px solid #fff;
}

.video-layer .video-player{
display:block;
padding: 10px 20px;
}
.video-layer .video-player video{min-width: 600px;max-height: 600px;}

.video-layer .video-loading{display:none;padding: 20px;}

.video-layer.video-loading .video-player{display:none;}
.video-layer.video-loading .video-loading{display:block; text-align: center;}


.video-logo{position: relative;cursor:pointer;}
.video-logo:hover:after{
left:0;
top:0;
content: "";
position: absolute;
width: 100%;
height: 100%;
background-position: center;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAQAAAD9CzEMAAACgklEQVR4Ae3XzUobbRyG8WlMFLUbSYjYVg+gUJRCJB6IUBfSIoacQIsxB6CtW4sEbOm7UmwgGxE8i2JIN8Yoim7UtKD2NcnmauDmWc3HMxPaRcHfvQ1e8DcZEufBv4AYMxSpUKNJp7smNSoskyWGY5vtBROscYGfc94z3nsgzSYdbNqUSPUSmOcHYTWZixZI8BmRG7ZYJEOS/u5SZMixzS0iJeJhA0PsY8AhCwzi/bpF6hiwx1CYQIJ9jP95SxwnYAmWuAeTIG4PfMKo8wLHPiZpYJRsgXmMb6RxQm6UA4xXQYE0P5G6/nyERAO5Jukf2DS313EibYoWsuEXmKCDvMNx7T+GLIkC0uapd2ANOfR858B3nlveUUfIqlcgxgWygOMxgF+8CUzkkDMeuQMzyI3Px0oIPNUwd8i0O1BEtnCCApZT7SAFd6CCLAYHLKfKI2V3oIZkggOWU2WRqjvQRJLBAcup0siVO9BB+oMDllMNIO0/FXgdPtBEUqEDtWgnivpP/hL1n1xBcvaAThP1bbqMbFsDOo33viJL7kAWufV+FFhOoz3mDsl4PezOgz7LrtMEHejU62Hn8AGpk/AKBJxG6+cYWcHxCozTAXNB14JOoxWRFk/cAa2E3DOJE3EvaSHrOH6BFE2kwShOhI1xglwy4h3Q5jAOIiTGqGLM2r54lTAaTIU8zgnGRxxbIM4exj0FEpZ3TpEWxi594b78KiFH5Bj2+VjlOQaMXQbDfn2PU0Lklh3yZEkz0F2aLHnK3GHoOH3RfoDMcU1Yl8z28hMqyQZtbFqsM9L7j8BnrHKGn1NW9Km1BCyLMU2BMlWuaHd3RZUyS2T0SLMH/uoeAtb9BmqvVYRfGSB/AAAAAElFTkSuQmCC");
background-repeat: no-repeat;
}
img.moduleFeaturedThumb{float:none !important;}
`;

    const videoLayerHTML=`
<div class='video-content video-bg'>
<div class='video-layer-close' title='ESC键快捷关闭窗口'><img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAQAAAD9CzEMAAAAyElEQVRYw+2WSwrDMAwFBTlkfqdLakIPaZguCiWNQyzZyqLFb23PgLAfEmlpafnb0BHo1adnVjob/glEnYKZCGwGBYF3IoMSD/DQC4bPpYxih4/6kaoVxfhEMbrjRUQYrxTV+GuFCz5RTO54ERGmo8IVnyrc8YnCH38Yyx34ROGPv11w84i+Xk7UN20Jvtc3bRHeVuZFeF3TVuHzTVuNd1HkO+e8ad3w503riq9QsOr/606xWBavzbx4BetuZ1sdFxO+paXlx/ICYTRfOPrpBZkAAAAASUVORK5CYII='></div>
<div class='video-player'>
</div>
<div class='video-loading'>
正在读取视频信息。。。
</div>
</div>`;

    const videoContentHTML=`
<h2>{title}</h2>
<div>
<video controls="controls" autoplay="autoplay">
<source src="{url}" type="video/mp4">
</video>
</div>
<div>
视频文件地址: <a href='{url}' target='_blank'>视频文件</a>
<div><a href="https://t.me/nrop19" target="_blacnk">Telegram 讨论群</a> 视频解析由<a href="http://jiexiba.tech" target="_blacnk">解析吧</a>提供</div>
</div>
`;
    const videoInfoHtml = `<h2 style="text-align: center;font-size:16px !important;">91无限次观看脚本已经生效</h2>
<div style="text-align: center;font-size:14px !important;"><a target="_blank" href="https://t.me/nrop19">点击加入Telegram群</a> 视频解析接口由<a target="_blank" href="http://jiexiba.tech">解析吧</a>提供</div>
<video controls="controls" style="width: 100%;max-height: 400px;"><source src="$src" type="video/mp4"></video>`;

    const currentPage = window.location.href.match(/([^/]+)\.php/)[1];
    //console.log({currentPage});

    class VideoLayer{
        constructor() {
            let html;
            if(currentPage === 'view_video')//视频页面占位符
                html = this.videoInfoPageInit();

            this.__api = 'http://www.jiexiba.tech/apiapi/youhou';
            this.__ready = true;
            document.addEventListener('keydown',e=>{
                if(e.keyCode === 27)
                    this.close();
            },false);
            if(currentPage === 'view_video'){//单一视频详情页面
                this.videoInfoPage();
            }else{//其它页面,绑定点击事件
                this.videoListPage();
            }
        }

        getMp4(url, callback, title){
            GM_xmlhttpRequest({
                method: "POST",
                url: this.__api,
                headers: {
                    'Origin': 'http://www.jiexiba.tech',
                    'Referer': 'http://www.jiexiba.tech',
                    'Content-Type': 'application/json',
                },
                data: JSON.stringify({id:"porn", link:url}),
                onload: ({response}) => {
                    try{
                        response = JSON.parse(response);
                        if(response.result == 404)
                            throw new Error('没有获取到视频连接');
                        callback({mp4:response.result,title});
                    }
                    catch(e){
                        let message = '没有获取到视频连接';
                        if(response === 'Too Many Requests')
                            message = '视频观看得太频繁了,请稍后再继续观看';
                        alert(message);
                        this.close();
                    }
                }});
        }

        //视频详情页面
        videoInfoPageInit(){
            const $video = document.querySelector('#viewvideo-content');
            const html = $video.innerHTML;
            $video.innerHTML = '91无限次观看脚本工作中';
            return html;
        }
        videoInfoPageError(html){
            const $video = document.querySelector('#viewvideo-content');
            $video.innerHTML = html;
        }
        videoInfoPage(){
            console.log('videoInfoPage 1');
            const $video = document.querySelector('#viewvideo-content');
            this.getMp4(window.location.href, res=>{
                console.log('videoInfoPage 2',res);
                $video.innerHTML = videoInfoHtml.replace('$src',res.mp4);
            });
        }

        //视频列表页面
        videoListPage(){
            const $videos = document.querySelectorAll('#tab-featured p, #videobox .imagechannelhd, #videobox .imagechannel, div#myvideo-content .videothumb');
            const callback = result=>{
                if(!!result.error){
                    this.close();
                    alert(result.error);
                    return;
                }
                this.show(result.title, result.mp4);
            };
            $videos.forEach($video => {
                const $a = $video.querySelector('a');
                const $img = $a.querySelector('img');
                let $target;
                let title;
                if(currentPage === 'index'){//index.php
                    videoListPageStyle += '.video-logo{float:left;}';
                    $target = $a;
                    title = $a.nextElementSibling.innerText;
                }else if(currentPage === 'uvideos'){//uvideos.php
                    $target = $video;
                    title = $video.nextElementSibling.querySelector('a').innerText;
                }else{//v.php和video.php
                    $target = $video;
                    title = $img.title;
                }
                const href = $a.href;
                $target.title= '直接播放视频';
                $target.className += ' video-logo';
                $target.onclick = () => {
                    if(!this.__ready)
                        return alert('91无限次观看脚本初始化失败\n请刷新页面让脚本再次初始化\n仍然没有解决请到Telegram聊天群反馈脚本问题:https://t.me/nrop19');
                    this.$videoLayer.className += ' video-loading';
                    this.$videoLayer.className += ' video-show';
                    this.getMp4(href, callback, title);
                    return false;
                };
            });

            //插入css
            GM_addStyle(videoListPageStyle);

            //创建div层
            this.$videoLayer = document.createElement('div');
            this.$videoLayer.className = 'video-layer';
            this.$videoLayer.innerHTML = videoLayerHTML;
            this.$videoTitle = this.$videoLayer.querySelector('h2');
            this.$videoContent = this.$videoLayer.querySelector('.video-player');
            this.$videoLayer.querySelector('.video-layer-close').onclick = this.close.bind(this);
            document.body.appendChild(this.$videoLayer);
        }

        close() {
            this.$videoContent.innerHTML = '';
            this.$videoLayer.className = this.$videoLayer.className.replace(/\s*video-show/g, '');
        }
        show(title, url) {
            let html = videoContentHTML.replace(/\{title\}/g,title);
            html = html.replace(/\{url\}/g,url);
            this.$videoContent.innerHTML = html;
            this.$videoLayer.className = this.$videoLayer.className.replace(/\s*video-loading/g, '');
        }
    }
    const video = new VideoLayer();
})();