IMDB Watchlist on Netflix?

Add Netflix availablity to IMDB watchlist

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        IMDB Watchlist on Netflix?
// @namespace   http://rasmuswriedtlarsen.com
// @description Add Netflix availablity to IMDB watchlist
// @include     http://*.imdb.com/user/*/watchlist*
// @version     0.1
// @grant       none
// @require     https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
// ==/UserScript==

// Not always accurate :(

// Based on https://greasyfork.org/en/scripts/10290-imdb-title-y-n-on-netflix/code
// and button from https://greasyfork.org/en/scripts/12219-imdb-netflix-button/code

(function(){
    $('.lister-item-header').each( function(){
        //used for span id, as it cannot contain spaces
        var title_ref_re = /\/title\/(.*?)\//;

        var header = $(this);
        var title = $('a',this).text();
        var title_ref = title_ref_re.exec( $('a',this).attr('href') )[1];
        var year = /\d+/.exec($('.lister-item-year', this).text())[0];

        var spanTitle = "netflix-checker-"+title_ref;
        $(header).append('<span id=\''+spanTitle+'\' style=\'font-size: 10px; color: White; font-weight: bold; padding:4px;\'></span>');
        $.ajax({ url: 'http://netflixroulette.net/api/api.php?title=' + title + '&year=' + year
        }).done(function(data) {
            var nID = data['show_id'];

            $('#'+spanTitle).html('<a href="http://netflix.com/watch/' + nID + '" target="_new" style="color: #fff;text-decoration: underline;">On Netflix</a>');
            $('#'+spanTitle).css('background-color', 'green');
        }).error(function(err) {
            $('#'+spanTitle).text('Not on Netflix');
            $('#'+spanTitle).css('background-color', 'red');});
        console.log(title+"|"+year);
    }
);
})();