Greasy Fork is available in English.

Открепление верхней панели ВКонтакте (VK)

Открепление верхней панели в социальной сети ВКонтакте (новый дизайн) при прокрутке страницы.

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name Открепление верхней панели ВКонтакте (VK)
  3. // @namespace FIX
  4. // @version 1.4
  5. // @description Открепление верхней панели в социальной сети ВКонтакте (новый дизайн) при прокрутке страницы.
  6. // @copyright 2016-2017, raletag
  7. // @author raletag
  8. // @include *://vk.com/*
  9. // @exclude *://vk.com/notifier.php*
  10. // @exclude *://vk.com/*widget*.php*
  11. // @grant none
  12. // @run-at document-end
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. var ishide = false,
  18. MO = window.MutationObserver,
  19. style = document.createElement("style");
  20. function h () {
  21. var playing = document.body.querySelector('#top_audio_player').classList.contains('top_audio_player_playing'),
  22. exclude = (window.location.pathname.indexOf('/gim') === 0 || window.location.pathname === '/im' || window.location.pathname === '/al_im.php' || document.body.querySelector('.app_container')),
  23. scroll = (document.body.scrollTop > 42);
  24. if (!ishide&&!playing&&!exclude&&scroll) { // скрыть
  25. document.body.querySelector('#page_header_cont').style.display = 'none';
  26. document.body.classList.add('headefix');
  27. ishide = true;
  28. //console.log('HIDE TOP PANEL');
  29. } else if ((ishide&&(playing||exclude||!scroll))) { // показать
  30. document.body.querySelector('#page_header_cont').style.display = null;
  31. document.body.querySelector('#side_bar_inner').style.marginTop = null;
  32. document.body.classList.remove('headefix');
  33. ishide = false;
  34. //console.log('SHOW TOP PANEL');
  35. }
  36. }
  37. style.innerHTML='.headefix .ui_search_fixed {top: 0px!important;} .headefix .side_bar_inner{margin-top: 0px;} .headefix .photos_period_delimiter_fixed{margin: 0px 0 0 -20px!important;} .headefix ._audio_rows_header.audio_rows_header.fixed{top:0px!important;} .headefix #stl_bg {padding-top: 20px!important;}';
  38. (document.head||document.body||document.documentElement||document).appendChild(style);
  39. window.addEventListener ('scroll', h, false);
  40. if (MO) {
  41. new MO(h).observe(document.body.querySelector('#top_audio_player'), {attributes: true, attributeFilter: ['class']});
  42. }
  43. h();
  44. })();