VK: Friend Requests Bulk Operations

Manage your friend requests. Add all friends or cancel all subscriptions with just one button click. Very handy if you are a public person or a YouTube star with VK account for publicity, like my wife :3

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         VK: Friend Requests Bulk Operations
// @description  Manage your friend requests. Add all friends or cancel all subscriptions with just one button click. Very handy if you are a public person or a YouTube star with VK account for publicity, like my wife :3
// @version      0.3
// @date         2016-05-19
// @author       vipaware
// @namespace    https://greasyfork.org/en/users/9103-vipaware
// @match        *vk.com/*
// @grant        none
// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js
// @require      https://greasyfork.org/scripts/386-waituntilexists/code/waitUntilExists.js?version=5026
// @license      MIT License
// ==/UserScript==

(function() {
    'use strict';

    var friendstab,
        hideall,
        addall,
        cancelall;

    $("#friends").waitUntilExists(function () {
        friendstab = $("#friends_req_tabs");
        if (!friendstab.length) return;

        hideall = $("#friends_hide_all");
        if (!hideall.length) return;

        hideall.text("Оставить всех");

        addall = $('<button class="flat_button fl_r" style="display: none; margin: 5px; background-color: #639EA8;">Добавить всех</button>').appendTo(friendstab);
        cancelall = $('<button class="flat_button fl_r" style="display: none; margin: 5px; background-color: #A1A863;">Отменить все заявки</button>').appendTo(friendstab);

        friendstab.find(".summary_tab_sel a, .summary_tab a").click(onTabClick);
        onTabClick();

        $(addall).click(buttonClick);
        $(cancelall).click(buttonClick);
    });

    function onTabClick() {
        var curtab = friendstab.find(".summary_tab_sel a").attr("id");
        if ("sum_tab_out_requests" == curtab) {
            addall.hide();
            cancelall.show();
        }
        else {
            addall.show();
            cancelall.hide();
        }
    }

    function buttonClick() {
        $(".user_block .flat_button").click();
    }

})();