VK-Center

Картинки в ленте по центру

当前为 2016-08-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name VK-Center
  3. // @description Картинки в ленте по центру
  4. // @author Last8Exile
  5. // @license MIT
  6. // @version 1.0
  7. // @noframes
  8. // @include *://vk.com/*
  9. // @namespace https://greasyfork.org/users/61164
  10. // ==/UserScript==
  11. (function()
  12. {
  13. 'use stict';
  14. if (window.top != window.self)
  15. return;
  16. var isUpdated;
  17. refresh();
  18. document.body.addEventListener("DOMNodeInserted",check);
  19. setInterval(check,10000);
  20. function check()
  21. {
  22. if (isUpdated)
  23. {
  24. refresh();
  25. isUpdated = false;
  26. setTimeout(refresh,1000);
  27. }
  28. }
  29. function refresh()
  30. {
  31. var imageBoxes = document.querySelectorAll("div.page_post_sized_thumbs");
  32. for (var item of imageBoxes)
  33. {
  34. var style = item.getAttribute("style");
  35. if (!style.includes("margin"))
  36. item.setAttribute("style",style+" margin: auto;");
  37. }
  38. isUpdated = true;
  39. }
  40. })();