您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
javtrailers.com 加载高清预告片
// ==UserScript== // @name Javtrailers_HD // @namespace http://tampermonkey.net/ // @version 2024-12-31 // @description javtrailers.com 加载高清预告片 // @author You // @match https://javtrailers.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=javtrailers.com // @grant GM_addStyle // @grant GM_xmlhttpRequest // @require https://fastly.jsdelivr.net/npm/[email protected]/dist/video.min.js // @require https://fastly.jsdelivr.net/npm/[email protected]/dist/videojs-vr.min.js // @resource video-js-css https://fastly.jsdelivr.net/npm/[email protected]/dist/video-js.min.css // @resource video-vr-js-css https://fastly.jsdelivr.net/npm/[email protected]/dist/videojs-vr.css // @license MIT // ==/UserScript== (function() { 'use strict'; // 观察目标节点 const targetNode = document.body; // 观察配置 const config = { childList: true, subtree: true }; // 当观察到变动时执行的回调函数 const callback = function (mutationsList, observer) { for (let mutation of mutationsList) { if (mutation.type === 'childList') { const div = document.getElementById('videoPlayerContainer'); if (div) { const parent=div.parentNode; parent.removeChild(div); // 获取目标元素 var elements = document.getElementsByClassName('col-md-8'); // 修改 CSS 属性 elements[0].style.width = '100%'; console.log('remove videoPlayerContainer'); findURL().then(videoURL => { addArt(parent, videoURL) }); } } } }; // 创建一个观察器实例并传入回调函数 const observer = new MutationObserver(callback); // 以上述配置开始观察目标节点 observer.observe(targetNode, config); const artStyle = ` #preview-video-player { width: 100%; height: 630px; } ` GM_addStyle(artStyle); async function findURL() { const nuxt = document.getElementById('__NUXT_DATA__'); const text = nuxt.innerText; const regex = /https:\/\/media\.javtrailers\.com.*?\.(m3u8|mp4)/g; const matches = text.match(regex); var videoURL = null; const contentId = findContentId(); if (matches && matches[0].includes(contentId)) { videoURL = matches[0]; } else { const data = await doGet(`https://javtrailers.com/api/video/${contentId}`) videoURL = JSON.parse(data)['video']['trailerG'] } console.log(videoURL); if (videoURL.indexOf('playlist') != -1) { const data = await doGet(videoURL) const playlist = data.split('\n') const hd = playlist[playlist.length - 1] videoURL = videoURL.replace('playlist.m3u8', hd); } return videoURL; } async function doGet(url) { return new Promise(resolve => { GM.xmlHttpRequest({ method: "GET", headers: { "authorization": "AELAbPQCh_fifd93wMvf_kxMD_fqkUAVf@BVgb2!md@TNW8bUEopFExyGCoKRcZX" }, url, onload: response => resolve(response.responseText), }); }) } function addArt(parent, videoURL) { const poster = findPoster(); const artHTML = ` <video id="preview-video-player" class="video-js" playsinline controls preload="none" poster="${poster}" > </video> `; // 插入新的div到现有div的后边 parent.insertAdjacentHTML('afterend', artHTML); const srcData = { type: "video/mp4", src: videoURL, }; if (videoURL.includes('m3u8')) { srcData.type = "application/x-mpegURL"; } const player = videojs(document.querySelector('#preview-video-player'), { playbackRates: [0.5, 1, 1.5, 2], }); player.src(srcData); } function findPoster() { // 使用类名获取 img 标签 const imgElement = document.querySelector('.img-fluid.mt-4'); // 获取 src 属性 if (imgElement) { const src = imgElement.getAttribute('data-src'); return src; } else { console.log('Image element not found'); } } function findContentId() { // 获取当前 URL const currentURL = window.location.href; // 分割 URL 并获取最后一项 const urlParts = currentURL.split('/'); return urlParts[urlParts.length - 1]; } })();