115已有影片标记

在AVMOO、JAVBUS等片库网站中自动标记出自己115网盘中已存在的影片(以蓝色加粗标题的形式)

À partir de 2019-10-02. Voir la dernière version.

// ==UserScript==
// @name         115已有影片标记
// @author       kyay006
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  在AVMOO、JAVBUS等片库网站中自动标记出自己115网盘中已存在的影片(以蓝色加粗标题的形式)
// @description  理论上只要页面看起来跟AVMOO、JAVBUS像,脚本就支持该网站,只需自行在下方参照格式添加一条match即可
// @match        http*://avmask.com/*
// @match        http*://avmoo.com/*
// @match        http*://www.javbus.com/*
// @domain     115.com
// @require      https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
// @grant         GM_xmlhttpRequest
// @grant         GM_notification
// ==/UserScript==

(function() {
    var cookie = "";//★★★使用前请先在双引号中填入你的115 Cookie★★★
    var nodes = $('div.photo-info');

    var url_user_info = "https://webapi.115.com/files/index_info";
    var url_search = "https://webapi.115.com/files/search?cid=0&limit=1&search_value=";

    getCookieState();

    function getCookieState(){
        if(cookie == ""){
            msg("脚本中的Cookie为空\n请先在脚本中填写Cookie,否则将无法查询数据!");
        }else{
            httpGet(url_user_info,function(xhr){
                var json = $.parseJSON(xhr.responseText);
                if(json.state){
                    urlMatch();
                }else{
                    msg("脚本中的Cookie已过期,请重新填写!");
                }
            })
        }
    }

    function urlMatch(){
        var path = window.location.pathname;
        if(path.search("/movie") == -1){
            nodes.each(function(){
                findVideo($(this));
            })
        }else{
            var code = $("span[style='color:#CC0000;']").text();
            httpGet(url_search + code,function(xhr){
                var json = $.parseJSON(xhr.responseText);
                if(!$.isEmptyObject(json.data)){
                    setCss($("div.container h3:first"));
                }else{
                    code = code.replace("-","");
                    httpGet(url_search + code, function(xhr){
                        var json = $.parseJSON(xhr.responseText);
                        if(!$.isEmptyObject(json.data)){
                            setCss($("div.container h3:first"));
                        }
                    })
                }
            });
        }
    }

    function findVideo(node){
        censored(node);
    }

    function censored(node){
        var code = node.find('span date:first').text();
        var span = node.find("span:first");
        httpGet(url_search + code, function(xhr){
            var json = $.parseJSON(xhr.responseText);
            if(!$.isEmptyObject(json.data)){
                setCss(span);
            }else{
                code = code.replace("-","");
                httpGet(url_search + code, function(xhr){
                    var json = $.parseJSON(xhr.responseText);
                    if(!$.isEmptyObject(json.data)){
                        setCss(span);
                    }
                })
            }
        })
    }

    function setCss(ele){
        ele.css("font-weight","bold");
        ele.css("color","blue");
    }

    function httpGet(url, callback){
        GM_xmlhttpRequest({
            method:"GET",
            url:url,
            headers:{'Cookie':cookie},
            onload:xhr => callback(xhr)
        })
    }

    function msg(content){
        GM_notification(content,"油猴脚本\"115已有影片标记\"");
    }
    // Your code here...
})();