电影天堂跳转豆瓣搜索

在电影天堂、阳光电影等网站搜到的影片,可以快捷的跳转到豆瓣搜索页面。查看评分、评论、演员信息等

当前为 2021-06-23 提交的版本,查看 最新版本

// ==UserScript==
// @name         电影天堂跳转豆瓣搜索
// @match        *://www.dytt8.net/*
// @match        *://www.ygdy8.com/*
// @match        *://www.dydytt.net/*
// @namespace    https://mdkml.gitee.io/
// @version      0.3
// @description  在电影天堂、阳光电影等网站搜到的影片,可以快捷的跳转到豆瓣搜索页面。查看评分、评论、演员信息等
// @author       MDKML
// @icon         https://mdkml.gitee.io/img/favicon.ico
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    var shade = document.createElement('div')
    shade.id = "search-app-box-shade"
    shade.style = "width:100%;height:100%;top:0;left:0;z-index: 888; position: fixed;background-color: rgb(0, 0, 0); opacity: 0.3;display: none;"
    document.body.insertAdjacentElement("afterBegin", shade);

    var div = document.createElement('div')
    div.id = 'search-app-box'
    div.style = "position: fixed; top: 120px; left: 20px; font-size: 12px;z-index: 999;"
    document.body.insertAdjacentElement("afterBegin", div);

    div.onmouseenter = function () {
        shade.style.display = "block"
    }
    div.onmouseleave = function () {
        shade.style.display = "none"
    }

    var h = document.getElementsByTagName("H1")
    var name = h[0].innerText;
    name = name.split("《")[1]
    name = name.split("》")[0]
    name = name.split("/")[0]
    let a = document.createElement('a')
    a.innerText = "豆瓣搜索"
    var style = "display: block;padding:10px;font-size: 18px; font-weight: bold;color:#072;cursor:pointer;border-radius: 25px;text-decoration:none;"
    a.style = style
    // 鼠标移入移除效果,相当于hover
    a.onmouseenter = function () {
        this.style = style + "color: #ffffff; background-color: #0084ff;";
    }
    a.onmouseleave = function () {
        this.style = style + "color: #072;";
    }
    a.onclick = function () {
        window.open("https://search.douban.com/movie/subject_search?search_text=" + encodeURI(name));
    }
    div.appendChild(a)

    h[0].appendChild(div);
    // Your code here...
})();