VK Messanger remover

Changes name of "Messanger" section back

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         VK Messanger remover
// @version      0.4
// @description  Changes name of "Messanger" section back
// @author       Intel777
// @copyright    2020, Alexander Boris (https://t.me/intel777)
// @license      MIT
// @match        https://vk.com/*
// @grant        none
// @run-at       document-start
// @namespace https://greasyfork.org/users/734002
// ==/UserScript==

var ai_title_translations = {
    'Мессенджер': 'Сообщения',
    'Messanger': 'Messages'
};

var legacy_ui_chat_tab_translations = {
    'Все чаты': 'Диалоги',
    'Chats': 'Dialogs'
};

var tab_title_observer = new MutationObserver(function(mutations, me){
    if (document.title in ai_title_translations){
        document.title = ai_title_translations[document.title];
    } 
});

var ai_title_observer = new MutationObserver(function(mutations, me){
    var messanger_ai = document.getElementById('l_msg');
    if(messanger_ai){
        var target_span = messanger_ai.getElementsByClassName('left_label');
        if(target_span){
            if (target_span[0].innerText in ai_title_translations){
                target_span[0].innerText = ai_title_translations[target_span[0].innerText];
            }
            me.disconnect();
            return;
        }
    }
});

var legacy_ui_chats_observer = new MutationObserver(function(mutations, me){
    var rmenu_chats_a = document.getElementById('ui_rmenu_all');
    if(rmenu_chats_a){
        if(rmenu_chats_a.innerText in legacy_ui_chat_tab_translations){
            rmenu_chats_a.innerText = legacy_ui_chat_tab_translations[rmenu_chats_a.innerText];
        }
        me.disconnect();
        return;
    }
});

(function() {
    'use strict';
    ai_title_observer.observe(document, {childList: true, subtree: true});
    legacy_ui_chats_observer.observe(document, {childList: true, subtree: true});
    tab_title_observer.observe(document, {childList: true, subtree: true});
})();