VK-friends-parser

Parsing "vk-friends" page

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

Advertisement:

// ==UserScript==
// @name            VK-friends-parser
// @version         0.3
// @description     Parsing "vk-friends" page
// @author          Max Donchenko (https://github.com/goodwin64/)
// @match           http://tampermonkey.net/
// @include         https://vk.com/*
// @name:ru
// @namespace https://greasyfork.org/users/25920
// ==/UserScript==
/* jshint -W097 */
'use strict';

window.onload = function parse(){
        var globalFriendsMap = globalFriendsMap || {};
	var friends = document.getElementsByClassName("user_block clear_fix");
	var friendsCount = 27;

	for (var i = 0; i < friendsCount; i++){
		var friend = friends[i];
		var avatar = friend.getElementsByClassName("friends_photo_img")[0].src;
		var friendFullName = friend.getElementsByClassName("friends_field")[0].childNodes[0].text.split(" ");
		var friendName = friendFullName[0];
		var friendSurname = friendFullName[1];
		var link = friend.getElementsByClassName("friends_act")[0].href; // https://vk.com/write12345678
		var id = link.slice( link.indexOf("write") + 5 );
		globalFriendsMap[id] = [friendName, friendSurname, avatar, link];
	}

	return globalFriendsMap;
};