JavDB & MissAv Jumper

Combine waterfall layout and jump button for JavDB

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         JavDB & MissAv Jumper
// @namespace    https://javdb.com/
// @version      3.1
// @description  Combine waterfall layout and jump button for JavDB
// @license      MIT
// @author       YourName
// @match        https://javdb.com/*
// @match        https://missav.ws/*
// @match        https://missav.ai/*
// @grant        GM_addStyle
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_deleteValue
// @grant        GM_notification
// @grant        GM_setClipboard
// @grant        GM_getResourceURL
// @grant        GM_registerMenuCommand
// @grant        GM_info
// @grant        GM_openInTab
// @grant        GM_xmlhttpRequest
// @connect      *
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    // JavDB Jump Button Code
    var jumpButton = document.createElement('button');
    jumpButton.style.backgroundColor = 'green';
    jumpButton.style.color = 'white';
    jumpButton.style.position = 'fixed';
    jumpButton.style.bottom = '10px';
    jumpButton.style.left = '10px';
    jumpButton.style.zIndex = '9999';
    jumpButton.style.padding = '16px 24px';
    jumpButton.style.borderRadius = '8px';
    jumpButton.style.fontSize = '24px';
    jumpButton.style.border = 'none';
    jumpButton.style.cursor = 'pointer';
    jumpButton.style.display = 'none';

    jumpButton.addEventListener('click', function() {
        let 番號 = '';
        let url = '';
        if (window.location.href.includes('javdb.com')) {
            var link = document.querySelector('.panel-block.first-block a.button.is-white.copy-to-clipboard');
            if (link) {
                番號 = link.getAttribute('data-clipboard-text');
                if (番號) {
                    url = "https://missav.ws/" + 番號.toLowerCase();
                }
            }
        } else if (window.location.href.includes('missav.ws')) {
            var element = document.querySelector('.text-secondary span.font-medium');
            if (element) {
                番號 = element.innerText;
                番號 = 番號.replace(/-UNCENSORED-LEAK|-CHINESE-SUBTITLE/g, '');
                url = "https://javdb.com/search?f=all&q=" + 番號;
            }
        }
        if (番號 && url) {
            var a = document.createElement('a');
            a.href = url;
            a.target = '_blank';
            a.style.display = 'none';
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
        }
    });

    let 番號 = '';
    if (window.location.href.includes('javdb.com')) {
        var link = document.querySelector('.panel-block.first-block a.button.is-white.copy-to-clipboard');
        if (link) {
            番號 = link.getAttribute('data-clipboard-text');
        }
    } else if (window.location.href.includes('missav.ws')) {
        var element = document.querySelector('.text-secondary span.font-medium');
        if (element) {
            番號 = element.innerText;
            番號 = 番號.replace(/-UNCENSORED-LEAK|-CHINESE-SUBTITLE/g, '');
        }
    }

    if (番號) {
        jumpButton.innerHTML = 番號;
        jumpButton.style.display = 'block';
    } else {
        jumpButton.style.display = 'none';
    }

    document.body.appendChild(jumpButton);

    // 修改磁力連接的下載按鈕
    function updateDownloadButtons() {
        if (window.location.href.includes('javdb.com')) {
            // 找到所有磁力連接項目
            const magnetItems = document.querySelectorAll('#magnets-content .item.columns');

            magnetItems.forEach(item => {
                // 找到該項目的複製按鈕和下載按鈕
                const copyButton = item.querySelector('.copy-to-clipboard');
                const downloadButton = item.querySelector('a.button.is-info.is-small[href^="https://keepshare.org"]');

                if (copyButton && downloadButton) {
                    // 獲取磁力連接
                    const magnetLink = copyButton.getAttribute('data-clipboard-text');

                    if (magnetLink) {
                        // 將下載按鈕的 href 改為磁力連接
                        downloadButton.href = magnetLink;
                        // 移除 target="_blank" 讓磁力連接在當前頁面處理
                        downloadButton.removeAttribute('target');
                    }
                }
            });
        }
    }

    // 頁面載入完成後執行
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', updateDownloadButtons);
    } else {
        updateDownloadButtons();
    }

    // 監聽動態載入的內容(如果有 AJAX 載入)
    const observer = new MutationObserver(() => {
        updateDownloadButtons();
    });

    const magnetsContent = document.querySelector('#magnets-content');
    if (magnetsContent) {
        observer.observe(magnetsContent, { childList: true, subtree: true });
    }
})();