zapperpro / Better UI for Netflix Germany

// ==UserScript==
// @name            Better UI for Netflix Germany
// @namespace       BNGer
// @version         0.3
// @description     different than before
// @match           *://www.netflix.com/WiHome*
// @homepage        http://stefan-wilhelm.info/netflix-tampermonkey-script/
// @copyright       2015, Stefan Wilhelm
// @run-at          document-end
// @require         https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// ==/UserScript==

// function from Geruhn
// Please support that work
// at https://gist.github.com/Geruhn
// https://gist.github.com/Geruhn/7644599
function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css;
    head.appendChild(style);
}

addGlobalStyle('body {padding-left:0;}');
addGlobalStyle('[class^="boxShot"] img.boxShotImg {width: 100px;height: auto;}');
addGlobalStyle('[class^="boxShot"] {width: 100px !important; height: auto  !important;}');
addGlobalStyle('[class^="boxShot"] a.playLink:hover {background: none !important;}');
addGlobalStyle('[class^="boxShot"] a.full {width: 100px !important; height: auto !important;}');
addGlobalStyle('.mrow {overflow:auto !important; border-top:solid 1px #000 !important; padding-top:25px;}');
addGlobalStyle('.mrow:first-child {border-top:0 !important;}');
addGlobalStyle('.mrow .agMovie {width: 100px !important; height: 200px !important; overflow:hidden;}');
addGlobalStyle('.boxShotDivider {display:none !important;}');

addGlobalStyle('#fground {overflow:auto;}');
addGlobalStyle('#buifn-menu {float:left; width:12vw; min-height:250px;}');
addGlobalStyle('#bd {float:left; width:70vw;}');
addGlobalStyle('#buifn-menu ul {margin:0; padding:0;}');
addGlobalStyle('#buifn-menu ul li {margin:0; padding:0; border-bottom:solid 1px #000; background-color:#fff; padding:5px; margin-bottom:3px;}');
addGlobalStyle('#buifn-menu ul li a{font-size:14px;}');
addGlobalStyle('.buifn-sctop{font-size:14px; text-decoration:none; color:#000; font-weight:bold;}');
addGlobalStyle('.buifn-sctop:hover{text-decoration:none !important;}');

$(document).ready(function(){
  
    //navigate to category
    $(document).on("click","#buifn-nav li a", function (e) {

        e.preventDefault();
        idtoscroll = $(this).data('scrollto');

        a = $('#'+idtoscroll).offset().top;
        b = $('#hd').height();
        c = a - b;

        $('html, body').animate({
            scrollTop: c
        }, 600);
       
    });

    //navigate to top
    $(document).on("click",".buifn-sctop", function () {

        $('html, body').animate({
            scrollTop: 0
        }, 200);
       
    });

    setTimeout(function() {
         
        //set you list as first row
        $('.mrow.yourListRow').prependTo(".mrows");
        
        //remove slider from list
        $('.mrow').find('.slider').removeAttr('class');
        
        //add title to movies
        $('.mrow .agMovie').find('.boxShotImg').each(function(){
            var vtitle = $(this).attr('alt');
            $(this).parent().parent().append('<span class="vtitle">'+vtitle+'</span>');
        });

        //remove facebook recommend
        $('#headerRow .postcard-container.recommend').parent().remove();

        //add menu
        $('#fground').prepend('<div id="buifn-menu"></div>');

        //sidebar menu
        $('.mrow .hd.clearfix').each(function(){
            $('#buifn-menu').append('<ul id="buifn-nav"></ul>');

            var buifn_text = $.trim($(this).find('h3 a').text());
            if(buifn_text !='')
            {
                buifn_text_meta = buifn_text.split(' ').join('');
                $(this).find('h3').attr('id', buifn_text_meta );
                $('#buifn-nav').append('<li data-text="'+buifn_text+'"><a href="#'+buifn_text_meta+'" data-scrollto="'+buifn_text_meta+'">'+buifn_text+'</a></li>');
            }

            $(this).find('h3').append('<a class="buifn-sctop" href="javascript:void(0);">&#8657;</a>');

        }).promise().done( function(){

            $("#buifn-nav li").sort(sort_li).appendTo('#buifn-nav');
            function sort_li(a, b){
                return ($(b).data('text')) < ($(a).data('text')) ? 1 : -1;    
            }
        });
        
        //add scroll to top
        $('body, html').offset().top;

    }, 250);

    

});