vshih / Google Docs - dismiss "signed in as"

// ==UserScript==
// @name        Google Docs - dismiss "signed in as"
// @namespace   https://blog.vicshih.com/2020/05/automatically-dismiss-google-docs-youre.html
// @version     0.5
// @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
// @updateURL   https://openuserjs.org/meta/vshih/Google_Docs_-_dismiss_signed_in_as.meta.js
// @downloadURL https://openuserjs.org/install/vshih/Google_Docs_-_dismiss_signed_in_as.user.js
// @copyright   2021, vshih (https://openuserjs.org/users/vshih)
// @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
  );
})();