VK: Friend Requests Bulk Operations

Manage your friend requests. Add all friends or cancel all subscriptions with just one button click.

目前為 2016-05-19 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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.
// @version      0.2
// @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();
    }

})();