Remove Sidebar

Removes annoying sidebar from the left side of the screen

  1. // ==UserScript==
  2. // @name Remove Sidebar
  3. // @namespace https://voice.google.com/
  4. // @version 1.0
  5. // @description Removes annoying sidebar from the left side of the screen
  6. // @author LikeToAccess
  7. // @match https://voice.google.com/u/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (async function() {
  14. 'use strict';
  15. // //*[@id="gvPageRoot"]/div[2]/gv-side-panel/mat-sidenav-container/mat-sidenav-content/div/div[2]/gv-call-sidebar
  16. function getElementByXpath(path) {
  17. return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  18. }
  19. function waitForElm(selector) {
  20. return new Promise(resolve => {
  21. if (getElementByXpath(selector)) {
  22. return resolve(getElementByXpath(selector));
  23. }
  24.  
  25. const observer = new MutationObserver(mutations => {
  26. if (getElementByXpath(selector)) {
  27. resolve(getElementByXpath(selector));
  28. observer.disconnect();
  29. }
  30. });
  31.  
  32. observer.observe(document.body, {
  33. childList: true,
  34. subtree: true
  35. });
  36. });
  37. }
  38. var elm = getElementByXpath("//*[@id=\"gvPageRoot\"]/div[2]/gv-side-panel/mat-sidenav-container/mat-sidenav-content/div/div[2]/gv-call-sidebar");
  39. elm.remove();
  40. window.onkeypress = async function(event) {
  41. if (event.keyCode == 96) {
  42. console.log("Keypress");
  43. while (await waitForElm("//div[contains(@aria-label, 'Unread')]")) {
  44. console.log("Started loop");
  45. var unread = await waitForElm("//div[contains(@aria-label, 'Unread')]");
  46. unread.click();
  47. }
  48. }
  49. }
  50. })();