Links on Netflix - IMDB, Metacritic, Rotten Tomatoes

Add search links to Netflix titles

目前為 2016-10-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Links on Netflix - IMDB, Metacritic, Rotten Tomatoes
// @description  Add search links to Netflix titles
// @version      0.1
// @author       mica
// @namespace    greasyfork.org/users/12559
// @include      https://www.netflix.com/*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
    $('style').html(`
        a.slnk {margin: 4px 6px 0 4px;}
        a.slnk img {width: 20px; height: 20px;}
            `).appendTo('head');
    var url;
    setInterval(function() {
        if (url != location.href) {
            url = location.href;
            setTimeout(function() {
                $('a.slnk').remove();
                if ($('.title:last').text() != '') {
                    var title = $('.title:last').text();
                } else {
                    var title = $('img.logo:last').attr('alt');
                }
                var imdb = 'http://www.imdb.com/find?s=tt&ref_=fn_tt&q=' + title;
                $('<a>').attr('href', imdb).attr('target', '_blank').addClass('slnk')
                    .html('<img src="http://i.media-imdb.com/images/favicon.ico">')
                        .appendTo('div.meta:last');
                var mc = 'http://www.metacritic.com/search/all/' + title + '/results?cats[movie]=1&cats[tv]=1&search_type=advanced';
                $('<a>').attr('href', mc).attr('target', '_blank').addClass('slnk')
                    .html('<img src="http://www.metacritic.com/favicon.ico">')
                        .appendTo('div.meta:last');
                var rt = 'https://www.rottentomatoes.com/search/?search=' + title;
                $('<a>').attr('href', rt).attr('target', '_blank').addClass('slnk')
                    .html('<img src="https://staticv2.rottentomatoes.com/static/images/icons/favicon.ico">')
                        .appendTo('div.meta:last');
            }, 1100);
        }
    }, 300);
})();