Greasy Fork is available in English.

VK: Hide Typing

look @name

Verze ze dne 22. 10. 2020. Zobrazit nejnovější verzi.

// ==UserScript==
// @name           VK: Hide Typing
// @name:ru        ВК: Скрыть набор текста
// @description    look @name
// @description:ru Смотри @name:ru 
// @namespace      hidetyping.user.js
// @version        0.4
// @match          https://*.vk.com/*
// ==/UserScript==

'use strict';

const PROXY = {
    XMLHttpRequest: () => {
        const { send } = XMLHttpRequest.prototype;

        XMLHttpRequest.prototype.send = function (data) {

            if (/typing|audiomessage/.test(data)) this.abort();

            send.call(this, data);
        };
    },
    fetch: () => {
        const _fetch = window.fetch;

        window.fetch = (input, init = {}) => {

            const _input = input.clone();

            return input
                .formData()
                .then(x => [...x.values()].includes('typing'))
                .then(isTyping => isTyping ? new Promise(() => null) : _fetch(_input, init));
        }
    }

};

const IS_MOBILE = new RegExp(/m.vk.com/);

const { href } = location;

const TYPE_PROXY = IS_MOBILE.test(href) ? 'fetch' : 'XMLHttpRequest';

const script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.textContent = `(${PROXY[TYPE_PROXY].toString()})()`;
document.head.append(script);