VKResizer

Auto-resize vk.com wall content

  1. // ==UserScript==
  2. // @name VKResizer
  3. // @version 0.17
  4. // @description Auto-resize vk.com wall content
  5. // @author A-Ivan
  6. // @include https://vk.com/*
  7. // @grant none
  8. // @namespace https://greatest.deepsurf.us/users/61380
  9. // @require http://code.jquery.com/jquery-3.1.0.min.js
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. var ww;
  16. var prev = 0;
  17.  
  18. function check_rect(){
  19. if(isNaN(ww))
  20. {
  21. ww = parseFloat($("#page_wall_posts").css('width'));
  22. }
  23. var check_elem = document.getElementById("narrow_column");
  24. var coords = 0;
  25. try {
  26. var wallType = $("div.page_block").parent("div.wall_module").attr("id");
  27. if(typeof(wallType) != "undefined")
  28. {
  29. coords = check_elem.getBoundingClientRect().bottom;
  30. var coordst = coords > prev ? coords : prev; //Фикс ошибки, вызванной изменениями в стиле.
  31. console.log(coordst);
  32. if(coordst < 10)
  33. {
  34. $("div.post_header").css({'width': ww*1.27204+'px', 'margin-right': '0px'});
  35. $("div.media_desc.post_video_desc").css({'width': ww*1.35264+'px'});
  36. $("div.page_post_sized_thumbs.clear_fix").css({'zoom': '1', '-moz-transform': 'scale(1)'});
  37. $("div.wall_module:last").find("div.wall_post_text").css({'width': ww*1.35264+'px'});
  38. var w = wallType == "profile_wall"? -ww/2 : 0;
  39. $("#page_wall_posts").css({'width': ww*1.50377+'px', 'margin-left': w + 'px'});
  40. $("div.ui_actions_menu_wrap._ui_menu_wrap").css({'margin-right': -ww/4.67 + 'px'});
  41. $("div.ui_actions_menu_wrap._ui_menu_wrap.shown").css({'margin-right': -ww/4.67 + 'px'});
  42. }
  43. else
  44. {
  45. $("div.post_header").css({'width': ww});
  46. $("div.media_desc.post_video_desc").css({'width': ww*0.84886+'px'});
  47. $("div.page_post_sized_thumbs.clear_fix").css({'zoom': '0.65999', '-moz-transform': 'scale(0.65999)'});
  48. $("div.wall_module:last").find("div.wall_post_text").css({'width': ww*0.80604+'px'});
  49. $("#page_wall_posts").css({'width': ww+'px', 'margin-left': '0px'});
  50. $("div.ui_actions_menu_wrap._ui_menu_wrap").css({'margin-right': 0 + 'px'});
  51. $("div.ui_actions_menu_wrap._ui_menu_wrap.shown").css({'margin-right': 0 + 'px'});
  52. }
  53. prev = coords;
  54. }
  55. else //Новости
  56. {
  57. $("#feed_rows").find("div.post_header").css({'width': ww*1.27204+'px'});
  58. $("#feed_rows").find("div.media_desc.post_video_desc").css({'width': ww*1.35264+'px'});
  59. $("#feed_rows").find("div.page_post_sized_thumbs.clear_fix").css({'zoom': '1', '-moz-transform': 'scale(1)'});
  60. $("#feed_rows").find("div.wall_post_text").css({'width': $("#feed_rows").find("div.wall_post_text").parent().css('width')});
  61. }
  62. }
  63. catch(err){}
  64. }
  65.  
  66. setTimeout(check_rect, 0);
  67. $(document).scroll(function(){check_rect();});
  68.  
  69. })();