您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add buttons on top of target element to generate thumbs and open path
当前为
// ==UserScript== // @name Emby Functions // @namespace http://tampermonkey.net/ // @version 1.2 // @description Add buttons on top of target element to generate thumbs and open path // @author Wayne // @match http://192.168.0.47:10074/* // @grant none // @license MIT // ==/UserScript== (function () { "use strict"; const EMBY_LOCAL_ENDPOINT = "http://192.168.0.47:10162/generate_thumb"; const DOPUS_LOCAL_ENDPOINT = "http://localhost:10074/open?path="; function findPathElement() { const mediaSource = document.querySelector(".mediaSources"); if (!mediaSource) return null; return mediaSource.querySelector("div:nth-child(2) > div > div:first-child"); } function generateSingleThumb(path, mode) { return () => { console.log("Generating Single Thumb:", path); const encodedPath = encodeURIComponent(path); fetch(`${EMBY_LOCAL_ENDPOINT}?path=${encodedPath}&mode=${mode}`) .then(() => { console.log("Single Thumb Generated"); alert("✅ Thumbnail generated successfully!"); }) .catch((err) => { console.error(err); alert("❌ Failed to generate single thumb: " + err); }); }; } function generateFullThumb(path, mode) { return () => { console.log("Generating Full Thumb:", path); const encodedPath = encodeURIComponent(path); fetch(`${EMBY_LOCAL_ENDPOINT}?path=${encodedPath}&mode=${mode}`) .then(() => { console.log("Full Thumb Generated"); alert("✅ Thumbnail generated successfully!"); }) .catch((err) => { console.error(err); alert("Failed to generate full thumb: " + err); }); }; } function generateSkipThumb(path, mode) { return () => { console.log("Generating Full Thumb (Skip Exist):", path); const encodedPath = encodeURIComponent(path); fetch(`${EMBY_LOCAL_ENDPOINT}?path=${encodedPath}&mode=${mode}`) .then(() => { console.log("Full Thumb Generated"); alert("✅ Thumbnail generated successfully!"); }) .catch((err) => { console.error(err); alert("Failed to generate full thumb: " + err); }); }; } function openPath(path) { return () => { const encodedPath = encodeURIComponent(path); fetch(`${DOPUS_LOCAL_ENDPOINT}${encodedPath}`) .then(() => console.log("Opened in Directory Opus")) .catch((err) => alert("Failed to open path: " + err)); }; } function createButton(label, onClick) { const btn = document.createElement("button"); btn.textContent = label; btn.style.marginRight = "8px"; btn.style.padding = "6px 12px"; btn.style.borderRadius = "6px"; btn.style.backgroundColor = "#56bf4f"; btn.style.color = "black"; btn.style.border = "none"; btn.style.cursor = "pointer"; btn.addEventListener("click", onClick); return btn; } function insertButtons() { const target = findPathElement(); if (!target) return; const pathText = target.textContent.trim(); if (!pathText) return; const container = document.createElement("div"); container.style.marginBottom = "8px"; const btnPath = createButton("Open Path", openPath(pathText)); const btnSingle = createButton( "Generate Single Thumb (Overwrite)", generateSingleThumb(pathText, "single") ); const btnFull = createButton( "Generate Full Thumb (Overwrite)", generateFullThumb(pathText, "full") ); const btnSkip = createButton("Generate Full Thumb (Skip)", generateSkipThumb(pathText, "skip")); container.appendChild(btnPath); container.appendChild(btnSingle); container.appendChild(btnFull); container.appendChild(btnSkip); target.parentElement.insertBefore(container, target); } const observer = new MutationObserver(() => { const target = findPathElement(); if (target) { observer.disconnect(); // only run once insertButtons(); } }); observer.observe(document.body, { childList: true, subtree: true }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址