My 115

115

目前为 2022-05-31 提交的版本。查看 最新版本

// ==UserScript==
// @name         My 115
// @namespace    http://tampermonkey.net/
// @version      0.12
// @description  115
// @author       You



// @include     http*://115.com/*

// @icon         https://www.google.com/s2/favicons?domain=115.com
// @grant        none
// ==/UserScript==
function addJQuery(callback) {
    var script = document.createElement("script");
    script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
    script.addEventListener('load', function() {
        var script = document.createElement("script");
        script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
        document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
}



function main(){
    const regex = /((?:(?!(boy|oy|hjd|jd|com|om|SIS|IS|sis)))[a-zA-Z]{2,4})-?\d{3,4}/g;
    const subtitle_r = /((?:(?!(boy|oy|hjd|jd|com|om|SIS|IS)))[a-zA-Z]{2,5})-?\d{3,4}(-|_)?(ch|C|c)/g;

    function already_download(already, title, sub=false) {
        if (! Object.keys(already).includes(title)) {
            return 1 // red, 1 means not downloaded yet
        } else if (already[title]) {
            return 2 // blue, 2 means already downloaded and has chinese subtitle or I don't have subtitle on 115
        } else if (!already[title] && sub){
            return 3 // purple, 3 means already downloaded but dont have subtitle
        }
        return 2
    }
    function mainBtnClick() {
        $.ajax({url: "https://www.mingren.life/av", success: (result) => {
           var already = result
           var items = $(".name")
           items.each((i, video) => {
               var texts = $(video).find("span")
               var t = texts.text().toUpperCase()
               const found = t.match(regex);
               const sub = t.match(subtitle_r)
               if (found && found.length === 1) {
                   var code = found[0]
                   var temp = code.match(/[a-zA-Z]+|\d+/g)
                   code = temp[0] + "-" + temp[1]

                   if (already_download(already, code, sub && sub.length > 0) === 1) {
                       $(texts).css("color", "red")
                   } else if (already_download(already, code, sub && sub.length > 0) === 2) {
                       $(texts).css("color", "blue")
                   } else {
                       $(texts).css("color", "purple")

                   }
               } else if (found && found.length > 1) {
                   $(texts).css("color", "green")
               }

           })
        }})

    }

    $(document).ready(function(){
        'use strict';
        let body = $("body");
        let btn = $("<button style='z-index:100;position: absolute; left: 100px; top: 200px' id='main-btn-addon'>Start</button>")
        body.append(btn)

           $('#main-btn-addon').click(mainBtnClick)

        console.log(body)
    });
}
// load jQuery and execute the main function
addJQuery(main);