上传文件至 /

Tampermonkey脚本插件
This commit is contained in:
张梦南 2025-08-10 07:14:20 +00:00
parent 5383b4bcfe
commit 110c32dbef

View File

@ -0,0 +1,72 @@
// ==UserScript==
// @name Jellyfin External Player (PotPlayer)
// @namespace http://dreamlife.top:13000/
// @version 1.0
// @description 在 Jellyfin 详情页中添加 PotPlayer 按钮调用外部potplayer播放器来播放视频文件。
// @author MengNan Zhang
// @match *://*/web/*
// @grant none
// @run-at document-end
// @downloadURL http://dreamlife.top:13000/Cx330/DreamLife_JellyfinExternalPlayer/src/branch/main/Jellyfin External Player (PotPlayer).DreamLife.js
// @updateURL http://dreamlife.top:13000/Cx330/DreamLife_JellyfinExternalPlayer/src/branch/main/Jellyfin External Player (PotPlayer).DreamLife.js
// ==/UserScript==
(function () {
'use strict';
// 获取 Jellyfin API 客户端
function getApiClient() {
return window.ApiClient || window.ConnectionManager?.currentApiClient();
}
// 获取播放链接
async function getPlayUrl(itemId) {
const api = getApiClient();
if (!api) return null;
const baseUrl = api._serverAddress || api._serverInfo?.PublicAddress;
const token = api.accessToken();
if (!baseUrl || !token) return null;
return `${baseUrl}/Videos/${itemId}/stream?static=true&api_key=${token}`;
}
// 添加 PotPlayer 按钮
function addPotPlayerButton(playButton) {
const container = playButton.parentElement;
if (!container || container.querySelector(".external-player-btn")) return;
const btn = document.createElement("button");
btn.className = "detailButton external-player-btn";
btn.style.marginLeft = "8px";
btn.style.background = "transparent";
btn.style.border = "none";
btn.style.cursor = "pointer";
const img = document.createElement("img");
img.src = "https://pc3.gtimg.com/softmgr/logo/48/519_48_1492137107.png"; // PotPlayer logo
img.alt = "PotPlayer";
img.style.width = "26px";
img.style.height = "26px";
btn.appendChild(img);
btn.onclick = async () => {
const id = location.href.match(/id=([^&]+)/)?.[1];
if (!id) return alert("未获取到视频 ID");
const url = await getPlayUrl(id);
if (url) location.href = `potplayer://${url}`;
};
container.appendChild(btn);
}
// 监听页面变化
const observer = new MutationObserver(() => {
document.querySelectorAll(".mainDetailButtons .btnPlay").forEach((btn) => {
addPotPlayerButton(btn);
});
});
observer.observe(document.body, { childList: true, subtree: true });
})();