vshih / Google Docs - dismiss "signed in as"

// ==UserScript==
// @name        Google Docs - dismiss "signed in as"
// @namespace   https://blog.vicshih.com
// @version     0.4
// @description Dismiss the "You're currently signed in as" pop-up.
// @author      Victor Shih
// @match       https://docs.google.com/*
// @match       https://drive.google.com/*
// @grant       none
// @license     GPL-3.0-or-later
// ==/UserScript==

(function () {
  'use strict';

  let tries = 0;

  let intervalId = window.setInterval(
    function () {
      let ok = document.querySelector('button[name="ok"]');
      if (ok) {
        ok.click();
      }

      if (ok || ++tries > 60) {
        // Succeeded or failed after too many tries, in which case give up.
        window.clearInterval(intervalId);
      }
    },
    500
  );
})();