Greasy Fork

来自缓存

Greasy Fork is available in English.

提取电影或电视剧ID并复制到剪切板

提取当前页面网址中的电影或电视剧ID并复制到剪切板,并在页面中固定显示ID

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         提取电影或电视剧ID并复制到剪切板
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  提取当前页面网址中的电影或电视剧ID并复制到剪切板,并在页面中固定显示ID
// @author       You
// @match        https://www.themoviedb.org/movie/*
// @match        https://www.themoviedb.org/tv/*
// @grant        GM_setClipboard
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 获取当前页面的URL
    const url = window.location.href;

    // 使用正则表达式提取movie或tv后的数字部分
    const match = url.match(/\/(movie|tv)\/(\d+)/);
    if (match) {
        const mediaId = match[2];  // 提取出数字部分(ID)
        
        // 将提取到的ID复制到剪切板
        GM_setClipboard(mediaId);

        // 创建一个自定义弹窗
        const popup = document.createElement('div');
        popup.innerHTML = `${match[1].toUpperCase()} ID: <span style="font-size: 36px; font-weight: bold;">${mediaId}</span> 已复制到剪切板`;
        popup.style.position = 'fixed';
        popup.style.top = '50%';
        popup.style.left = '50%';
        popup.style.transform = 'translate(-50%, -50%)';
        popup.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
        popup.style.color = 'white';
        popup.style.padding = '20px';
        popup.style.borderRadius = '8px';
        popup.style.fontSize = '18px';
        popup.style.textAlign = 'center';
        popup.style.zIndex = '10000';
        
        document.body.appendChild(popup);

        // 设置3秒后自动移除弹窗
        setTimeout(() => {
            popup.remove();
        }, 3000);

        // 在页面顶部创建一个固定显示的高亮区域
        const fixedDisplay = document.createElement('div');
        fixedDisplay.innerHTML = `当前${match[1].toUpperCase()} ID: <span style="font-size: 24px; font-weight: bold; color: yellow;">${mediaId}</span>`;
        fixedDisplay.style.position = 'fixed';
        fixedDisplay.style.top = '0';
        fixedDisplay.style.left = '0';
        fixedDisplay.style.width = '100%';
        fixedDisplay.style.backgroundColor = 'rgba(0, 0, 0, 0.9)';
        fixedDisplay.style.color = 'white';
        fixedDisplay.style.padding = '10px';
        fixedDisplay.style.textAlign = 'center';
        fixedDisplay.style.fontSize = '20px';
        fixedDisplay.style.zIndex = '10000';

        // 将高亮显示区域添加到页面
        document.body.appendChild(fixedDisplay);
    } else {
        alert('未找到有效的ID');
    }
})();