kirillorgazm / PW (pw.mail.ru) cabinet pin code auto-click script

// ==UserScript==
// @name         PW (pw.mail.ru) cabinet pin code auto-click script
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Enters pin-code and apply it to the first account (if many). You should be logged into
// @author       You
// @match        https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo
// @icon         https://www.google.com/s2/favicons?domain=google.com
// @grant        none
// @license     MIT
// @include     https://pw.mail.ru/pin.php
// @updateURL   https://openuserjs.org/meta/kirillorgazm/PW_(pw.mail.ru)_cabinet_pin_code_auto-click_script.meta.js
// @downloadURL https://openuserjs.org/install/kirillorgazm/PW_(pw.mail.ru)_cabinet_pin_code_auto-click_script.user.js
// @copyright   2021, kirillorgazm (https://openuserjs.org/users/kirillorgazm)
// ==/UserScript==

(function () {
  'use strict';

  // Your code here...
  const errorBox = document.getElementsByClassName('m_error')[0];
  const pinBox = document.getElementsByClassName('pin_code_input')[0];
  const pinButton = document.getElementsByClassName('pin_code_input')[1];

  navigator.clipboard.readText()
    .then(text => {
      console.log('Pasted content: ', text);
      if (!errorBox) {
        pinBox.value = text;
        pinButton.click();
      }

    })
    .catch(err => {
      console.error('Failed to read clipboard contents: ', err);
    });

})();