Greasy Fork

Greasy Fork is available in English.

VK: Friends w/o History

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.

目前为 2015-02-24 提交的版本,查看 最新版本

// ==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    http://greasyfork.icu/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
// ==/UserScript==

(function($){
  "use strict";
  
  var monitorID = 0,
      divsProcessed = 0;
  
  function AddButton() {
    $("#sections_block .friends_fltr").append('<a id="friends_remove_with_history" class="side_filter">Без истории</a>');
    $("#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));