IMDB Watchlist on Netflix?

Add Netflix availablity to IMDB watchlist

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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);
    }
);
})();