您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add an IMDB Link to Plex
当前为
// ==UserScript== // @name Add IMDB Link to Plex // @description Add an IMDB Link to Plex // @match https://app.plex.tv/desktop* // @grant GM_xmlhttpRequest // @version 0.0.1.20201218201500 // @namespace https://greasyfork.org/users/718390 // ==/UserScript== 'use strict'; //since plex is a spa (single page app), we have to perpetually monitor the page elements that get rendered, we can't count on a traditional full browser page refresh var timerHandle = setInterval(main, 1000); function main() { //"metadata" string in url means we're on an actual movie page in plex, otherwise just keep looping on timer if (window.location.href.indexOf("metadata") === -1) return; //also keep looping till we see the title element get rendered var title = document.querySelector("div[data-qa-id='preplay-mainTitle']"); var year = document.querySelector("div[data-qa-id='preplay-secondTitle']").textContent; if (!title) return; //now that we've found a title we can do our bizness... //but only if we haven't already =) if (document.getElementById("imdbhack")) return; //create new element to show imdb link (or error message) var imdbhack = document.createElement("a"); imdbhack.id = "imdbhack"; title.insertAdjacentElement('afterend', imdbhack); //stack-o showed this oddball imdb "api" we can use to look up the magic imdb "id" for a movie //https://stackoverflow.com/questions/1966503/does-imdb-provide-an-api/7744369#7744369 GM_xmlhttpRequest({ method: "GET", url: "https://sg.media-imdb.com/suggests/" + title.textContent[0].toLowerCase() + "/" + encodeURI(title.textContent + " " + year) + ".json", onload: function (response) { if (response.responseText.indexOf("Bad query") > -1) { imdbhack.textContent = "not found on imdb"; } else { var getId = /\"id\":\"(.*?)\"/; var match = response.responseText.match(getId); //match[1] will contain the id for the win! //finally we get to jam in our href to the corresponding imdb movie deets page! //nugget: cool part here is we can target the anchor id for the user reviews!! if that's not your main interest, just remove imdbhack.href = "https://www.imdb.com/title/" + match[1] + "/#titleUserReviewsTeaser"; imdbhack.textContent = "imdb link"; imdbhack.target = "_blank"; }; } }); }