Registration date in VK

Registration date in VK profile

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            Registration date in VK
// @name:ru         Дата регистрации в VK
// @namespace       FIX
// @version         0.1
// @description     Registration date in VK profile
// @description:ru  Показ даты регистрации в профиле VK
// @author          raletag
// @copyright       2016, raletag
// @include         *://vk.com/*
// @exclude         *://vk.com/notifier.php*
// @exclude         *://vk.com/*widget*.php*
// @grant           GM_xmlhttpRequest
// @run-at          document-end
// ==/UserScript==

(function() {
    'use strict';
    var pn, month = ['0', 'января', 'ферваля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'];
    function f () {
        if (window.location.pathname === pn) return;
        pn = window.location.pathname;
        var a = document.body.querySelector('a.page_actions_item[onclick*="abuse"]'), b = document.body.querySelector('a.stats[href*="/stats"]'), c = document.body.querySelector('#profile_short'), d, id;
        id = ((a && a.getAttribute('onclick').match(/oid: (\d+)}/i))||(b && b.href.match(/mid=(\d+)/i))||[])[1];
        if (!id||!c) return;
        d = new XMLHttpRequest();
        d.onload = function () {
            var xd = (this.responseText.match(/ya:created dc:date="(.+)T/i)||[])[1], ad, div;
            if (xd) {
                ad = xd.split('-');
                div = document.createElement ('div');
                div.className = 'clear_fix profile_info_row';
                div.innerHTML = '<div class="label fl_l">Дата регистрации:</div><div class="labeled">' + ad[2] + ' ' + month[parseInt(ad[1])] + ' ' + ad[0] + ' г.</div>';
                c.insertBefore(div, c.firstChild);
            } else error ();
        };
        d.onerror = error;
        d.timeout = 10000;
        d.open('GET', '/foaf.php?id=' + id, true);
        d.send();
    }
    function error () {
        console.error('GET registration date in VK ERROR!');
    }
    f();
    new MutationObserver(f).observe(document.body, {childList: true, subtree: true});
})();