Remove Sidebar

Remove the suggested call sidebar from Google Voice

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Remove Sidebar
// @namespace    htt*://voice.google.*
// @version      2.0
// @description  Remove the suggested call sidebar from Google Voice
// @author       Ian
// @match        https://voice.google.com/u/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// @license      MIT
// ==/UserScript==

function getElementByXpath(path) {
    return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

function waitForElm(selector) {
    return new Promise(resolve => {
        if (getElementByXpath(selector)) {
            return resolve(getElementByXpath(selector));
        }

        const observer = new MutationObserver(mutations => {
            if (getElementByXpath(selector)) {
                resolve(getElementByXpath(selector));
                observer.disconnect();
            }
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}

(async function() {
    'use strict';

    var sidebar = getElementByXpath("//*[@id=\"gvPageRoot\"]/div[2]/gv-side-panel/mat-sidenav-container/mat-sidenav-content/div/div[2]/gv-call-sidebar");
    sidebar.remove(); // Remove the sidebar!

    window.onkeypress = async function(event) {
        if (event.keyCode == 96) { // Keycode 96 is ` (back quote)
            console.log("Keypress");
            while (getElementByXpath("//div[contains(@aria-label, 'Unread')]")) {
                console.log("Started loop");
                var unread = await waitForElm("//div[contains(@aria-label, 'Unread')]"); // Search for the newest unread message
                unread.click(); // Click on the message to mark it as read
            }
            console.log("Ended loop");
        }
    }
})();