Fix Bitwarden compatibility

Make login/password boxes on selected sites compatible with Bitwarden auto-fill

目前為 2022-06-15 提交的版本,檢視 最新版本

// ==UserScript==
// @name          Fix Bitwarden compatibility
// @description   Make login/password boxes on selected sites compatible with Bitwarden auto-fill
// @author        MK
// @namespace     max44
// @homepage      https://greasyfork.org/en/users/309172-max44
// @match         https://account.kyivstar.ua/cas/login*
// @match         https://next.privat24.ua/*
// @match         https://login-widget.privat24.ua/*
// @icon          https://vault.bitwarden.com/images/favicon-32x32.png
// @version       1.0
// @license       MIT
// @require       https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @run-at        document-idle
// ==/UserScript==

(function() {
  'use strict';

  function kyivstarAddIdUsername(input) {
    if (input.getAttribute("id") == null) {
      input.setAttribute("id", "username");
    }
  }

  function kyivstarAddIdPUK2(input) {
    if (input.getAttribute("id") == null) {
      if (window.location.href.indexOf("#puk2:") !== -1) {
        input.setAttribute("id", "puk2");
      }
    }
  }

  function privat24AddIdUsername(input) {
    console.log(input);
    if (input.getAttribute("id") == null) {
      input.setAttribute("id", "username");
    }
  }

  if (window.location.href.indexOf("https://account.kyivstar.ua/cas/login") == 0) {
    setInterval (function () {
      document.querySelectorAll("input[type='tel']").forEach(kyivstarAddIdUsername);
      document.querySelectorAll("input[type='password']").forEach(kyivstarAddIdPUK2);
    }, 500);
  }

  if (window.location.href.indexOf("https://login-widget.privat24.ua/") == 0) {
    setInterval (function () {
      document.querySelectorAll("input[type='tel']").forEach(privat24AddIdUsername);
    }, 500);
  }

})();