Links on Disney+ - IMDB, Rotten Tomatoes, Metacritic

Add links for searching titles from disneyplus.com

目前为 2022-01-02 提交的版本。查看 最新版本

// ==UserScript==
// @name         Links on Disney+ - IMDB, Rotten Tomatoes, Metacritic
// @description  Add links for searching titles from disneyplus.com
// @version      0.1
// @author       mica
// @namespace    greasyfork.org/users/12559
// @include      https://www.disneyplus.com/series/*
// @include      https://www.disneyplus.com/movies/*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
// @grant        none
// @license      MIT
// ==/UserScript==

$('head').append(`
    <style>
        #sbox {margin: -16px 0 0 8px}
        #sbox a {margin: 0 6px}
        #sbox img {width: 20px; height: 20px;}
    </style>
`);
var url
setInterval(function() {
    if (url != location.href) {
        url = location.href;
        function checkReady() {
            if (document.getElementsByTagName('body')[0].getAttribute('style') == null) {
                setTimeout(checkReady, 1000);
            } else {
                setTimeout(makeLinks, 1500);
            }
        }
        function makeLinks() {
            var title = $('#unauth-navbar-target > img').attr('alt');
            var mc = 'https://www.metacritic.com/search/all/' + encodeURIComponent(title.replace(/\*|\//g,' ')) + '/results';
            var imdb = 'https://www.imdb.com/find?s=tt&ref_=fn_tt&q=' + encodeURIComponent(title);
            var rt = 'https://www.rottentomatoes.com/search/?search=' + encodeURIComponent(title);
            $('[data-gv2containerkey|="contentMeta"]').children().first().append([
                $('<div>').attr('id', 'sbox').append([
                    $('<a>').attr('href', mc).attr('target', '_blank').html('<img src="https://www.metacritic.com/favicon.ico">'),
                    $('<a>').attr('href', imdb).attr('target', '_blank').html('<img src="https://www.imdb.com/favicon.ico">'),
                    $('<a>').attr('href', rt).attr('target', '_blank').html('<img src="https://www.rottentomatoes.com/favicon.ico">')
                ])
            ]);
        }
        checkReady();
    }
}, 500);