b站番剧播放页内跳转樱花搜索

打开播放页面发现没会员?点击页面右侧的樱花图标跳转至樱花动漫观看

// ==UserScript==
// @name         b站番剧播放页内跳转樱花搜索
// @namespace    http://tampermonkey.net/
// @version      2.0.1
// @description  打开播放页面发现没会员?点击页面右侧的樱花图标跳转至樱花动漫观看
// @author       kakasearch
// @match        https://www.bilibili.com/bangumi/*
// @icon         data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiID8+DQo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPg0KPHN2ZyB3aWR0aD0iODAwcHQiIGhlaWdodD0iODAwcHQiIHZpZXdCb3g9IjAgMCA4MDAgODAwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+DQo8ZyBpZD0iI2ZmN2YwMmZmIj4NCjxwYXRoIGZpbGw9IiNmZjdmMDIiIG9wYWNpdHk9IjEuMDAiIGQ9IiBNIDUzNi42OCAxNTYuMDYgQyA1MzYuODQgMTQ2Ljk3IDU0Mi4yNyAxMzguMTIgNTUwLjkyIDEzNC44NiBDIDU1Mi44NSAxNDMuODYgNTU0LjcyIDE1Mi44NyA1NTYuNjAgMTYxLjg3IEMgNTU3LjA2IDE2NS4yOSA1NTkuNTcgMTY3LjgxIDU2MS4zNiAxNzAuNTkgQyA1NzMuNjcgMTY5LjYzIDU4Ni41NCAxNzEuMzUgNTk3LjM0IDE3Ny42NSBDIDYwOC41MyAxODQuMDUgNjE2Ljk0IDE5NC44MSA2MjEuMjIgMjA2LjkwIEMgNjI2LjEyIDIxNy4wOCA2MzcuMjAgMjIzLjUyIDYzOS41NiAyMzUuMDUgQyA2MzcuNjIgMjQ3LjIzIDYzNS40OCAyNTkuOTggNjI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DM1Ny40MSA2NTYuNDEgMzU0LjMzIFoiIC8+DQo8L2c+DQo8L3N2Zz4NCg==
// @run-at        document-end
// @grant        unsafeWindow
// @grant        GM_openInTab
// @require https://greasyfork.org/scripts/430421-%E4%B8%AD%E6%96%87%E7%B9%81%E4%BD%93%E7%AE%80%E4%BD%93%E8%BD%AC%E5%8C%96%E5%BA%93/code/%E4%B8%AD%E6%96%87%E7%B9%81%E4%BD%93%E7%AE%80%E4%BD%93%E8%BD%AC%E5%8C%96%E5%BA%93.js?version=1225835
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    let window = unsafeWindow
    let upload_url = 'http://www.nekostu.top:1760'
    let search_url = "http://www.yinghuacd.com/search/" //换成其他url以跳转其他网站 如age "https://www.agefans.vip/search?query="
    function handle_name(name){
        name = simplized(name) //繁体转简体
        name = name.replace(/(.*)/,'')//去中文括号
        name = name.replace(/第.*季/,'') //去第二季
        name = name.replace(/剧场版/,'') //去剧场版  "剧场版 王室教师海涅"
        name = name.split('/')[name.split('/').length-1] //去/,保留最后部分
        name = name.slice(0,18)//樱花动漫最长支持18个字符,太长会502
        name = name.trim() // //去多余空格  "无限滑板 / SK8 the Infinity"
        name = name.split(' ')[0] //以空格分割,取前面的   伊甸星原 EDENS ZERO
        name = name.split(',')[name.split(',').length-1] //以,分割,取后面的
        name = name.split('-')[0] // 以-分割,取前面的  "催眠麦克风-Division Rap Battle- Rhyme Anima"
        return name
    }

    function inject_div(){
        if( document.querySelector("#bili_to_yh")){
        return}
    var div = document.createElement("div");
        // 设置div的样式
        div.id = "bili_to_yh"
        div.style.width = "75px";
        div.style.height = "75px";
        div.style.position = "fixed";
        div.style.top = "50%";

        div.style.right = "0";
        div.style.position = "fixed";
        div.style.transform = "translateY(-50%)";
        let img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC4AAAAqCAMAAAD79pkTAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAPZQTFRFAAAA7GyL7GyL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RUL7u1MRgDf0B1egcYXmlRb/TNOy+jv+0EFPgJn6nqTt6PfVjDavt9d/Li+06Ofs9mv33/uwTvtLyCPR618Lt3pAAAAAElFTkSuQmCC"
        div.innerHTML = `<a title="跳转樱花观看"><img src='${img}' style="height:50px"></a>`
        // 将div插入到body中
        document.body.appendChild(div);
       document.querySelector("#bili_to_yh > a > img").addEventListener("mouseover", function() {
            document.querySelector("#bili_to_yh> a > img").style.height = "75px";
            document.querySelector("#bili_to_yh").style.height = "75px";
});
       document.querySelector("#bili_to_yh > a > img").addEventListener("mouseout", function() {
            document.querySelector("#bili_to_yh > a > img").style.height = "50px";
           document.querySelector("#bili_to_yh").style.height = "50px";
});
       document.querySelector("#bili_to_yh").addEventListener("click", function() {
            let title = document.querySelector("a[class^=mediainfo_media_title]")||document.querySelector("a[class^=mediainfo_mediaTitle]")
            let href = search_url+ handle_name(title.innerText)+"?yname="+title.innerText
            GM_openInTab(href ,{active: true,insert: true})
});
    }

    ///////////////////////////////////////////bili////////////////////////////////////////////////////////
    if(/bilibili/.test(window.location.href)){
        let i = setInterval(inject_div,100)
        setTimeout(function(){clearInterval(i)},5000)
        let ci = 0
        let obser = setInterval(
            function(){
                let video= document.querySelector("#bilibili-player video")
                if(video){
                    clearInterval(obser)
                    let observer = new MutationObserver(()=>{inject_div()})
                    observer.observe(video, { attributes: true });//检测video变化,防止中途切p失效
                }
            },200
        )
        }




/*     ///////////////////////////////////////////樱花////////////////////////////////////////////////////////
    if (/yhdm.*bv=/.test(window.location.href) ){
        let items = /search\/(.*)\?bv=(.*)&yname=(.*)/.exec(window.location.href)
        let query_name = items[1]
        let bv = items[2]
        let yname = items[3]
        let run_num =0
        let i = setInterval(function(){
            if(document.querySelector("div.fire.l > div > ul > li") || run_num>=10){
                clearInterval(i)
            }else if( /未找到相关信息/.test(document.querySelector("div.fire.l > div > ul").innerText)){ //出现bug
                clearInterval(i)
                GM_xmlhttpRequest({
                    method: 'GET',
                    //url: 'http://localhost:1760/bili2yh?bv=' + bv + "&name=" + query_name+"&yname="+yname,
                    url: upload_url + "/bili2yh?bv=" + bv + "&name=" + query_name+"&yname="+yname,
                    onload: function(xhr) {
                        console.log(xhr.responseText)
                        if (xhr.status == 200) {
                            let data = JSON.parse(xhr.responseText)
                            if(data.code == 0){
                            console.log("found")
                                let name = data.data
                                window.location.href = search_url+ name
                            }else{
                            console.log("not found")
                            }
                            console.log('上传bug成功')
                        } else {
                            console.log('上传bug失败')
                        }

                    },
                    onerror:function(){console.log('上传bug失败')}
                });
            }
            run_num +=1

        },500)


        } */

})();