Registration date in VK

Registration date in VK profile

当前为 2016-11-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Registration date in VK
  3. // @name:ru Дата регистрации в VK
  4. // @namespace FIX
  5. // @version 0.2
  6. // @description Registration date in VK profile
  7. // @description:ru Показ даты регистрации в профиле VK
  8. // @author raletag
  9. // @copyright 2016, raletag
  10. // @include *://vk.com/*
  11. // @exclude *://vk.com/notifier.php*
  12. // @exclude *://vk.com/*widget*.php*
  13. // @grant GM_xmlhttpRequest
  14. // @run-at document-end
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19. var month = ['0', 'января', 'ферваля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'];
  20. function error () {
  21. console.error('GET registration date in VK ERROR!');
  22. }
  23. function f () {
  24. var a = document.body.querySelector('#profile_short:not([vrd]'), b, c, d, id;
  25. if (!a) return;
  26. b = document.body.querySelector('a.page_actions_item[onclick*="abuse"]');
  27. c = document.body.querySelector('a.stats[href*="/stats"]');
  28. id = ((b && b.getAttribute('onclick').match(/oid: (\d+)}/i))||(c && c.href.match(/mid=(\d+)/i))||[])[1];
  29. if (!id) return;
  30. a.setAttribute('vrd', '1');
  31. d = new XMLHttpRequest();
  32. d.onload = function () {
  33. var xd = (this.responseText.match(/ya:created dc:date="(.+)T/i)||[])[1], ad, div;
  34. if (xd) {
  35. ad = xd.split('-');
  36. div = document.createElement ('div');
  37. div.className = 'clear_fix profile_info_row';
  38. div.innerHTML = '<div class="label fl_l">Дата регистрации:</div><div class="labeled">' + ad[2] + ' ' + month[parseInt(ad[1])] + ' ' + ad[0] + ' г.</div>';
  39. a.insertBefore(div, a.firstChild);
  40. } else error ();
  41. };
  42. d.onerror = error;
  43. d.timeout = 10000;
  44. d.open('GET', '/foaf.php?id=' + id, true);
  45. d.send();
  46. }
  47. new MutationObserver(f).observe(document.body, {childList: true, subtree: true});
  48. })();