IMDB Copy Buttons V2

Advanced view required for this script to work. Adds "Copy" buttons that copy the actor next to the respective buttons.

当前为 2018-11-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         IMDB Copy Buttons V2
// @namespace    http://kmcgurty.com/
// @version      1
// @description  Advanced view required for this script to work. Adds "Copy" buttons that copy the actor next to the respective buttons.
// @author       Kmcgurty
// @match        https://www.imdb.com/title/*
// @match        https://www.imdb.com/name/*
// @grant        GM_addStyle
// @grant        GM_setClipboard
// ==/UserScript==

GM_addStyle(`
.copybutton{
    font-size: 1em;
    padding: 0px;
    margin: 0 0 0 2px;
}
`);

var toAppend = document.querySelectorAll(".itemprop a, .crew_list a, .writers_list a, .filmo-row b");

for(var i = 0; i < toAppend.length; i++){
    var copyButton = document.createElement('input');
    copyButton.setAttribute("type", "button");
    copyButton.setAttribute("class", "copybutton linkasbutton-secondary");
    copyButton.setAttribute("value", "Copy");
	copyButton.setAttribute("data-copytext", toAppend[i].textContent);

    if(window.location.href.match("/title/")){
        var td = document.createElement("td");
        td.appendChild(copyButton);

        toAppend[i].parentNode.parentNode.insertBefore(td, toAppend[i].parentNode.nextSibling)
    } else if(window.location.href.match("/name/")) {
        toAppend[i].parentElement.querySelector(".year_column").appendChild(copyButton);
    }

    copyButton.addEventListener("click", function(e){
        GM_setClipboard(e.target.getAttribute("data-copytext").trim());

    })
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址