// ==UserScript== // @name VK: Friends w/o History // @description Adds "Without History" filter to Friends page. Handy, if you have lots of friends and you want to *spam* only those, who don't have chat history with you yet. // @version 0.1 // @date 2015-02-24 // @author vipaware // @namespace https://greasyfork.org/en/users/9103-vipaware // @match *vk.com/friends* // @grant none // @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js // @license MIT License // @downloadURL none // ==/UserScript== (function($){ "use strict"; var monitorID = 0, divsProcessed = 0; function AddButton() { $("#sections_block .friends_fltr").append('Без истории'); $("#friends_remove_with_history").click(ToggleMonitor); } function ToggleMonitor() { var cn = "cur_section", el = $(this); if (el.hasClass(cn)) clearInterval(monitorID); else { RemoveFriends(); monitorID = setInterval(RemoveFriends, 1000); } el.toggleClass(cn) } function ProcessDiv(div) { var ubs = $(".user_block", div); ubs.each(function(index, el){ var id = $(this).attr("id").replace("user_block", ""); $.get("/im", {sel: id}, function(data) { if ($("#im_log" + id + " tr", data).length) $(el).hide("fast"); }); }); } function RemoveFriends() { var divs = $("#list_content > div"); var i = divsProcessed; divsProcessed = divs.length; for (; i < divs.length; i++) { setTimeout(ProcessDiv, 0, divs[i]); } } AddButton(); }(jQuery));