How to make vk.com less disturbing?

How to make vk.com less disturb you from really important things?
The easiest way it to remove yourself from that social network, or not create an account, If you haven’t got one.
But, what to do, if you have lots of “friends” in vk.com, and you can’t contact them in other way?
Or, if You are using music features of vk.com?

Lets assume, that our task is: make it so, that vk.com could be used as messenger and music player at work time. Also, out of the work hours, we want to use full functionality of vk.com.

This goal could be easilly achieved by userscript, installed through GreasyMonkey/TamperMonkey.

Установка скрипта:

1. Install browser plugin for userscripts

For Firefox it’s GreaseMonkey
For Google Chrome and other browsers, based on it, and not having it’s own plugins store (Chromium, Vivaldi) it’s TamperMonkey
For Opera it’s separated extension TamperMonkey

2. Copy javascript from here: https://github.com/MihanEntalpo/VkMessagingAndAudioOnly/blob/master/script.js

Or right from here:

// ==UserScript==
// @name        vk.com only messaging
// @namespace   mihanentalpo.me
// @description Allow to use messaging only on vk.com
// @include     https://vk.com/*
// @match       https://vk.com/*
// @match       http://vk.com/*
// @version     1
// @grant       none
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// ==/UserScript==

(function(){
    
global_vkscript_is_active = false;
global_current_href = '';

function every_page_remove()
{
   jQuery('.left_box.attention').remove();  
}
 
function detect_move_out(url)
{
  var regtxt = "^https://(new\.)?vk.com/(im|audios?|away|share|login)";
  var regexp = new RegExp(regtxt);
  if (!regexp.test(url))
  {
     window.location.href = "https://vk.com/im";
  }
}

function update_url(url)
    {
        if (global_current_href != url)
        {
            jQuery('#url-box').text('URL:' + url);
            detect_move_out(url);
            every_page_remove();
            global_current_href = url;
        }
    }
    
/**
* Function, returning time limits of working
*/
function get_time_limits()
{
  return {
    // Start to block everything except music and messages from time:
    from: "9:30",
    // Block until time:
    to: "18:30"
  };
}
 
/**
* Check, should blocking be active now? 
*/
function is_active(){
 
  d = Date.now();  
  var d1 = new Date(d);
  var d2 = new Date(d);
   
  var limits = get_time_limits();
   
  d1.setHours(limits.from.split(":")[0]);
  d1.setMinutes(limits.from.split(":")[1]);
   
  d2.setHours(limits.to.split(":")[0]);
  d2.setMinutes(limits.to.split(":")[1]);
   
  return (d2 > d && d1 < d);  
 
}
 
 
/**
* Try to activate or deactivate
*/
function tryToActivate()
{  
  jQuery("#ads_left").remove();
  if (!global_vkscript_is_active && is_active())
  {  
    global_vkscript_is_active = true;
    jQuery('#side_bar li').each(function (index, element) {  
      text = jQuery(element).find('span.left_label.inl_bl').text();      
      if (-1 == jQuery.inArray(text, ["Сообщения", "Музыка"]))
      {
        jQuery(element).remove();
      }
    });
 
    jQuery('.more_div').remove();
    jQuery('body').append('
URL:
'); update_url(window.location.href); setInterval(function(){ update_url(window.location.href); }, 1000); } else if(global_vkscript_is_active && !is_active()) { window.location.reload(); } } /** * Check for activation every 2 seconds */ setInterval(tryToActivate, 2000); })();

3. Create new userscript in newly installed browser extension, and copy the code to it.

Testing:

1. Open vk.com website, and, if needed, authorize. If vk.com have been already opened, the page must be reloaded.

2. If the time now is inside specified limits, all left menu’s items except “Music” and “Messages” should disappear

3. When time goes outside of the specified limits, full left menu would became accessible.

Left bar
in normal state
Left base
when all unneded is blocked

4. Additional bonus: adverstment block on the left sidebar should disappear

5. If you try to enter some page, that is not “messages” or “music” at work-time, redirect to “messages” would happen.

The only disadvantage of this script, is that it doesn’t automatic disable at the weekend of holidays


So, what do you think ?