Jav Trailers

JabBus/JavDB观看预告片

Pada tanggal 01 Januari 2025. Lihat %(latest_version_link).

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Jav Trailers
// @description  JabBus/JavDB观看预告片
// @namespace    http://tampermonkey.net/
// @version      2024-12-27
// @description  try to take over the world!
// @author       You
// @match        https://javdb.com/v/*
// @match        https://www.javbus.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=javdb.com
// @grant        GM_xmlhttpRequest
// @connect      javtrailers.com
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    // javdb获取包含IPBZ-010的span元素
    const spanElement = document.querySelector('.panel-block.first-block .value a');
    if (spanElement!=null){
        // 获取完整的文本内容
        const javId = spanElement.parentElement.textContent.trim();
        toPreview(javId, javdb);
    }else{
        console.log("no javdb");
    }

    //javbus
    const busElement = document.querySelector('.col-md-3.info p span[style="color:#CC0000;"]');
    console.log(busElement);
    if (busElement!=null){
        // 获取完整的文本内容
        const javId = busElement.textContent.trim();
        toPreview(javId, javbus);
    }else{
        console.log("no javbus");
    }

    function toPreview(javId, funToDo) {
        console.log(javId); // 输出: IPBZ-010
        var url = `https://search.javtrailers.com/indexes/videos/search?q=${javId}&page=1&sort=releaseDate:desc&hitsPerPage=1`
        doGet(url).then(data => {
            console.log(data);
            const contendId = JSON.parse(data)['hits'][0]['contentId']
            funToDo(javId, contendId);
            getTrailer(javId)
        });
    }

    function javdb(javId, contendId) {
        // 输出结果
        console.log(javId); // 输出: IPBZ-010
        const searchUrl = `https://javtrailers.com/search/${javId}`;
        const newUrl = `https://javtrailers.com/video/${contendId}`;

        const existingDiv = document.querySelector('.panel-block.first-block');
        // 生成新的div
        const jableHTML = `
        <div class="panel-block">
            <strong>Jable:</strong>
            &nbsp;<span class="value"><a href="https://jable.tv/videos/${javId}/" target="_blank">${javId}</a></span>
        </div>
        `;
        // 插入新的div到现有div的后边
        existingDiv.insertAdjacentHTML('afterend', jableHTML);
        const toTrailerHTML = `
        <div class="panel-block">
            <strong>预览:</strong>
            &nbsp;<span class="value"><a href="${newUrl}" target="_blank">${javId}</a></span>
            &nbsp;
            <a class="button is-white copy-to-clipboard" title="search" href="${searchUrl}" target="_blank"">
                <span class="icon is-small">
                <i class="icon-search"></i>
                </span>
            </a>
        </div>
        `;
        existingDiv.insertAdjacentHTML('afterend', toTrailerHTML);
    }

    function javbus(javId, contendId) {
        const searchUrl = `https://javtrailers.com/search/${javId}`;
        const newUrl = `https://javtrailers.com/video/${contendId}`;
        // 获取目标div元素中的第一个p标签
        const firstPElement = document.querySelector('.col-md-3.info p');

        const jableHTML = `
            <p>
            <a class="header" >Jable:</a>
            <a style="color:#CC0000;" href="https://jable.tv/videos/${javId}/" target="_blank">${javId}</a>
            </p>
            `;
        firstPElement.insertAdjacentHTML('afterend', jableHTML);
        // 定义要插入的p标签HTML
        const newPHTML = `
            <p>
                <a class="header" href="${searchUrl}" target="_blank">预览:</a>
                <a style="color:#CC0000;" href="${newUrl}" target="_blank">${javId}</a>
            </p>
            `;

        // 在第一个p标签后插入新的p标签
        firstPElement.insertAdjacentHTML('afterend', newPHTML);
    }

    function getTrailer(javId) {
        var url = `https://search.javtrailers.com/indexes/videos/search?q=${javId}&page=1&sort=releaseDate:desc&hitsPerPage=1`
        doGet(url).then(data => {
            console.log(data);
            const contendId = JSON.parse(data)['hits'][0]['contentId']
            url = `https://javtrailers.com/api/video/${contendId}`
            GM_xmlhttpRequest({
                method: "get",
                url: url,
                headers: { "authorization": "AELAbPQCh_fifd93wMvf_kxMD_fqkUAVf@BVgb2!md@TNW8bUEopFExyGCoKRcZX" },
                onload: function (r) {
                    console.log(r.responseText);
                    const trailerUrl = JSON.parse(r.responseText)['video']['trailerG']
                    console.log(trailerUrl);
                    if (trailerUrl.indexOf("m3u8") != -1) {
                        GM_xmlhttpRequest({
                            method: "get",
                            url: trailerUrl,
                            headers: { "authorization": "AELAbPQCh_fifd93wMvf_kxMD_fqkUAVf@BVgb2!md@TNW8bUEopFExyGCoKRcZX" },
                            onload: function (rr) {
                                console.log(rr.responseText);

                            }
                        });
                    } else {
                        insertPreview(trailerUrl)
                    }
                }
            });
            doGet(url).then(data => {
                console.log(data);
                const trailerUrl = JSON.parse(data)['video']['trailerG']
                if (trailerUrl.conatins('m3u8')) {
                    doGet(trailerUrl).then(data => {
                        console.log(data);

                    });
                } else {
                    insertPreview(trailerUrl)
                }
            });
        });
    }

    function insertPreview(videoUrl) {
        console.log(videoUrl);
    }

    async function doGet(url) {
        try {
            const response = await fetch(url, {
                method: 'GET',
                headers: {
                    'authorization': 'Bearer 6b4bd3e560e994a5b009023e1d21f51e95dbb86ca3f47cb03f34f8a2cb9a93f2',
                    'Content-Type': 'application/json'
                }
            });

            if (!response.ok) {
                throw new Error('Network response was not ok ' + response.statusText);
            }
            return response.text();
        } catch (error) {
            console.error('There was a problem with the fetch operation:', error);
        }
    }
})();