Disable whereby knocking

disables knocking on https://whereby.com/

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Disable whereby knocking
// @namespace    http://31337.it/
// @version      0.1
// @description  disables knocking on https://whereby.com/
// @author       Simon
// @match        https://whereby.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var checkExist = function(selector, cb) {
        return setInterval(function() {
            var el = document.querySelectorAll(selector);
            if (el.length) {
                cb(el[0]);
            }
        }, 100);
    }


    var setEverytingUpTimer;
    var setEverytingUp = function() {
        var disableText = 'disable knocking';
        var enableText = 'enable knocking';
        var timer;

        var addLinkBefore = document.querySelectorAll('.NavButton-2kvr.IconButton-2aoD')[0];
        var toggleLink = document.createElement('a');
        toggleLink.appendChild(document.createTextNode(enableText));
        toggleLink.href = 'javascript:///';
        toggleLink.addEventListener('click', function(el) {
            if (toggleLink.innerHTML === enableText) {
                clearInterval(timer);
                toggleLink.innerHTML = disableText;
            } else {
                timer = checkExist('.BaseNotification-2Lci', function(el) {
                    el.setAttribute('style', 'display: none;');
                });
                toggleLink.innerHTML = enableText;
            }
        });

        var parentNode = addLinkBefore.parentElement;
        parentNode.insertBefore(toggleLink, addLinkBefore);

        //start
        timer = checkExist('.BaseNotification-2Lci', function(el) {
            el.setAttribute('style', 'display: none;');
        });

    }

    setEverytingUpTimer = checkExist('.jstest-room-header', function() {
        clearInterval(setEverytingUpTimer);
        setEverytingUp();
    });

})();