Vk Recent Smiles Panel

USABILITY

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Vk Recent Smiles Panel
// @namespace    https://vk.com
// @version      0.1
// @description  USABILITY
// @author       Efog
// @match        https://vk.com/*
// @unmatch      https://vk.com/notifier.php*
// @require      https://code.jquery.com/jquery-2.2.4.min.js
// @grant        none
// ==/UserScript==

(() => {
    'use strict';

    setInterval(() => {
        if (/\/notifier.php/.test(location.href))
            return;

        if (!/\/im\?sel/.test(location.href))
            return;

        var panel = $('#recent-smiles');
        if (panel.length === 0) {
            console.info('Adding recent smiles...');

            var btn = $('._emoji_btn');

            panel = $('<div id="recent-smiles"></div>').appendTo($('.im-chat-input--txt-wrap'));
            Emoji.show(btn[0], null);

            setTimeout(() => {
                Emoji.hide(btn[0], null);

                setTimeout(() => {
                    smile(panel);

                    panel.css({
                        float: 'right',
                        marginTop: '10px'
                    });
                });
            }, 50);
        }
    }, 100);

    setInterval(() => {
        if (/\/notifier.php/.test(location.href))
            return;

        var panel = $('#recent-smiles');
        if (panel.length) {
            smile(panel);
        }
    }, 5000);

    function smile(panel) {
        var recent = $('.emoji_cat_title_helper[data-id="-1"]').eq(0).next('.emoji_smiles_row').children();

        setTimeout(() => {
            if (!/\/im\?sel/.test(location.href))
                return;

            var recent = $('.emoji_cat_title_helper[data-id="-1"]').eq(0).next('.emoji_smiles_row').children().clone(true);
            recent.each((i, emoji) => {
                emoji = $(emoji);
                emoji.attr('onmousedown', 'Emoji.shownId = data(domPN($(".emoji_smile._emoji_btn")[0]), "optId"); ' + emoji.attr('onmousedown').replace('return cancelEvent(event);', 'Emoji.shownId = false; return cancelEvent(event);'));
            });

            panel.html('').append(recent.slice(0, 10));
        });
    }
})();