Rahul-RB / Remove Google Meet link in Gmail Sidebar

/* Install TamperMonkey
 * Click on extension, create new script
 * Copy paste the script from line 6 till end.
 * Enjoy!
 */

// ==UserScript==
// @name         Remove Google Meet link in Gmail Sidebar
// @namespace    https://github.com/Rahul-RB
// @version      0.1.5
// @description  Remove the annoyingly large "Meet" links on sidebar of your gmail.
// @author       Rahul R Bharadwaj
// @match        https://mail.google.com/*
// @grant        none
// @license      MIT
// @copyright    2020, Rahul-RB (https://openuserjs.org/users/Rahul-RB)
// @updateURL    https://openuserjs.org/meta/Rahul-RB/Remove_Google_Meet_link_in_Gmail_Sidebar.meta.js
// @downloadURL  https://openuserjs.org/install/Rahul-RB/Remove_Google_Meet_link_in_Gmail_Sidebar.user.js
// ==/UserScript==

window.addEventListener('load', function() {
    'use strict';
    function removeLink(linkName){
        var k = document.getElementsByTagName("a");
        var p = null;
        for(var i=0;i<k.length;i++){
          if(k[i].textContent == linkName)
              p=k[i];
        }
        function findUpTag(el) {
            while (el.parentNode) {
                el = el.parentNode;
                for(var i=0; i<el.childNodes.length; i++){
                    if(el.childNodes[i].textContent !== undefined && el.childNodes[i].textContent.includes("Meet") && el.childNodes[i].textContent != "Start a meeting" && el.childNodes[i].textContent != "Join a meeting")
                            return el.childNodes[i];
                }
            }
            return null;
        }
        if(p!==null && p!==undefined){
            findUpTag(p).parentNode.remove();
        }
        else{
            console.log("Unable to find the mail links for", linkName);
        }        
    }
    
    var linkNames = ["New meeting", "Start a meeting"];
    for (var i=0; i<linkNames.length; i++)
        removeLink(linkNames[i]);
        
}, false);