Facebook Old by LaNouille974

Set positions of Facebook navbar elements as in the previous version of the social network: friends requests, messages and notifications on the left (next to logo) and the other ones on the right.

اعتبارا من 23-07-2014. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name        Facebook Old by LaNouille974 
// @namespace   https://www.facebook.com
// @include     https://www.facebook.com/*
// @version     1
// @grant       none
// @require     https://code.jquery.com/jquery-1.11.0.min.js
// @description Set positions of Facebook navbar elements as in the previous version of the social network: friends requests, messages and notifications on the left (next to logo) and the other ones on the right.
// ==/UserScript==

$.noConflict();
jQuery( document ).ready(function($) {
    
    /*** Configuration ***/
    var defaultNickName = 'LaNouille974';
    var defaultPic = 'http://img11.hostingpics.net/pics/962935runico.png';
    
    var navBar = $('#blueBarNAXAnchor');
    var logo = navBar.find('h1:first')
    /**** End Configuration ***/
    
    //OLD var originalNavRight = $('div#headNav > div.rfloat');
    var originalNavRight = navBar.find('div.rfloat:first');
    
    //Cloner la navRight
    var newNavRight = originalNavRight.clone();
    
    
    //Un peu de CSS pour les nouvelles navBar
    newNavRight.css({
        'float': 'left',
		'margin-left': logo.width() + 2 + 'px',
		'margin-right': '10px'
    });  
    
    //Retirer les éléments indésirables de chaque navBar
    removeNavElements(originalNavRight, 'old');
    removeNavElements(newNavRight, 'new');
    
    
    //Personnalisation
    var li = $("<li/>");
    li.attr('id', 'thenoodle');
    li.attr('title', 'Cliquer pour changer le texte');
    li.addClass('navItem tinyman litestandNavItem').text(defaultNickName);
    li.prependTo(originalNavRight.children('ul:first'));
    
    $('li#thenoodle').css({
        'height': '25px',
        'line-height': '25px',
        'color': 'white',
        'font-weight': 'bold',
        'position': 'relative',
        'left': '-25px',
        'top': '-2px',
        'background-image': "url('"+ defaultPic +"')",
        'background-repeat': 'no-repeat',
        'background-size': '25px 25px',
        'padding-left' : '32px',
         'cursor': 'pointer'
    });
    
    infiniteFadeInOut($('li#thenoodle'), true);
    
    //Changer le pseudo à la volée
    $('li#thenoodle').click(function(){
        changeNickName($(this));
    });
    
    //Ajoute la nouvelle navBar à gauche
    //OLD newNavRight.prependTo('div#headNav');
    newNavRight.prependTo(logo.parent());
    
    //Modifier emplacements popup
    //Messages
    $("#fbMessagesFlyout").parent().click(function() {
        //Fleche
        $('#fbMessagesFlyout .beeperNub').css({
             'right': '0',
             'left': '35px'
        });
        
        //Popup
        $('#fbMessagesFlyout').css({
            'right': '0',
             'left': '-30px'
        });
    });
    
    //Friends requests
    $("#fbRequestsFlyout").parent().click(function() {
        //Fleche
        $('#fbRequestsFlyout .beeperNub').css({
            'left': '4px' 
        });
        
        //Popup
        $("#fbRequestsFlyout").css({
            'left': '0',
        });
    });
    
    //Notifications
    $('#fbNotificationsFlyout').parent().click(function(){
        //Fleche
        $('#fbNotificationsFlyout .beeperNub').css({
            'right': '0',
             'left': '4px'
         });
        
        //Popup
        $("#fbNotificationsFlyout").css({
            'right': 'auto',
        });
    });

    
    /*** FUNCTIONS ***/
    
    //FadeIn puis fadeOut en boucle de l'élément passé en paramètre
    function infiniteFadeInOut (elem, fadeOut) {
        var targetOpacity = fadeOut ? 0.5 : 1;
        var duration = fadeOut ? 2000 : 500;
        
        fadeOut = !fadeOut; 
            
        elem.animate({
            opacity: targetOpacity 
        }, duration, 'swing', function() {
            infiniteFadeInOut($(this), fadeOut);
        });
    }
    
    //Retire les li indésirables de la navBar passé en param
    //Type = old ou Type = new
    function removeNavElements(navBar, type) {
      
        var elementsToRemove = [];
        
        if (type == 'new')
            elementsToRemove = [0, 1, 4, 5, 6];
        else
            elementsToRemove = [2, 3];
        
        navBar.children('ul:first').children('li').each(function(i) {
            
            //console.log(elementsToRemove);
            
            if ($.inArray(i, elementsToRemove) !== -1) {
               $(this).remove();
               //console.log(i);
            }
        });
    }
    
    function changeNickName(domElem) {
        var precNickName = domElem.text();
        var newNick = '';
        
        do {
            newNick = prompt('Nouveau texte (12 caractères max, taper "!q" pour quitter) :');
            
            if (newNick === null || newNick == '!q') break;
            else if (newNick.length > 12) 
                alert('Nouveau texte trop long ! 12 caractères max. (' + newNick.length + ' saisis)');
            
        } while (newNick.length > 12 || newNick == '')
        
        console.log(newNick);    
        
        if (newNick == null ) {
            if (precNickName == '')
                newNick = defaultNickName;
            else
                newNick = precNickName;
        } 
        else if(newNick == '!q') newNick = precNickName;    
            
        domElem.text(newNick);
    }
});