您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在豆瓣电影页面检查Emby中是否存在当前影视,若存在则显示跳转至Emby的按钮
当前为
// ==UserScript== // @name 豆瓣跳转至Emby // @namespace http://tampermonkey.net/ // @version 1.0.0 // @description 在豆瓣电影页面检查Emby中是否存在当前影视,若存在则显示跳转至Emby的按钮 // @author Your name // @match https://movie.douban.com/* // @grant GM_xmlhttpRequest // @connect * // @license MIT // @note 23-10-25 0.1 豆瓣跳转至Emby // @note 23-10-25 1.0.0 修复年份查询不到问题 // ==/UserScript== (function () { 'use strict'; // emby地址 const embyServer = 'http://192.168.123.8:58096' // emby api const embyApiKey = 'd54070cb3e4f4e99b0c557792608bba2' // 通过电影名称在Emby中进行检索 function searchInEmby(movieName) { return searchEmbyByNameAndYear(movieName) } function httpRequest(options) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ ...options, onload: response => resolve(response), onerror: error => reject(error) }); }); } async function searchEmbyByNameAndYear(dbMovie) { const name = dbMovie.name; let yearParam = dbMovie.year ? `&Years=${dbMovie.year},${parseInt(dbMovie.year) - 1},${parseInt(dbMovie.year) + 1}` : ''; let includeItemTypes = "IncludeItemTypes=movie"; let ignorePlayed = ""; // 删除季信息 if (dbMovie.type === "tv") { yearParam = ''; includeItemTypes = "IncludeItemTypes=Series"; } const url = `${embyServer}/emby/Items?api_key=${embyApiKey}${ignorePlayed}&Recursive=true&${includeItemTypes}&SearchTerm=${name}${yearParam}`; const response = await httpRequest({ method: 'get', url }); const data = JSON.parse(response.responseText); if (response.status === 200 && data.TotalRecordCount > 0) { for (let i = 0; i < data.Items.length; i++) { const item = data.Items[i]; if (item.Name === name) { return item; } } return null; } else { return null; } } // 获取当前电影名称 function getMovieName() { let title = document.querySelector('title').innerText.replace(/(^\s*)|(\s*$)/g, '').replace(' (豆瓣)', ''); const subject = document.querySelector('.year').textContent.replace('(', '').replace(')', ''); const type = answerObj.TYPE; if (type == "tv") { title = title.replace(/ 第[一二三四五六七八九十\d]+季/g, '') } return { name: title, year: subject, type: type } } // 添加一个按钮跳转到Emby async function addEmbyButton() { const movieName = getMovieName(); const embyInfo = await searchInEmby(movieName) if (movieName && embyInfo) { const subjectwrap = document.querySelector('h1'); const embyButton = document.createElement('span'); const subject = document.querySelector('.year'); subjectwrap.insertBefore(embyButton, subject.nextSibling); embyButton.insertAdjacentHTML('afterend', createSvg(embyInfo, 'pc')) } } function createSvg(embyInfo, platform) { let style = '' if (platform == 'pc') { style = '.cupfox:hover{background: #fff!important;}' } return `<style>.cupfox{vertical-align: middle;}${style}</style> <a href="${embyServer}/web/index.html#!/item?id=${embyInfo.Id}&serverId=${embyInfo.ServerId}" class="cupfox" target="_blank"> <svg fill="#52b54b" width="23px" height="23px" viewBox="0 0 24.00 24.00" role="img" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path d="M11.041 0c-.007 0-1.456 1.43-3.219 3.176L4.615 6.352l.512.513.512.512-2.819 2.791L0 12.961l1.83 1.848a3468.32 3468.32 0 0 0 3.182 3.209l1.351 1.359.508-.496c.28-.273.515-.498.524-.498.008 0 1.266 1.264 2.794 2.808L12.97 24l.187-.182c.23-.225 5.007-4.95 5.717-5.656l.52-.516-.502-.513c-.276-.282-.5-.52-.496-.53.003-.009 1.264-1.26 2.802-2.783 1.538-1.522 2.8-2.776 2.803-2.785.005-.012-3.617-3.684-6.107-6.193L17.65 4.6l-.505.505c-.279.278-.517.501-.53.497-.013-.005-1.27-1.267-2.793-2.805A449.655 449.655 0 0 0 11.041 0zM9.223 7.367c.091.038 7.951 4.608 7.957 4.627.003.013-1.781 1.056-3.965 2.32a999.898 999.898 0 0 1-3.996 2.307c-.019.006-.026-1.266-.026-4.629 0-3.7.007-4.634.03-4.625z"></path></g></svg> </a> ` } // 在页面加载完成后添加按钮 window.onload = function () { addEmbyButton(); }; })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址