https://git.jolheiser.com/js-spectre.git
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
<!doctype html> <head> <script type="module" src="../lib/spectre.js"></script> <link rel="stylesheet" href="sakura.css" /> <style> input { width: 50%; } </style> </head> <body> <input id="userKey" type="text" placeholder="Robert Lee Mitchell" /><br /> <input id="userSecret" type="text" placeholder="banana colored duckling" /><br /> <input id="siteKey" type="text" placeholder="masterpasswordapp.com" /><br /> <strong id="result"></strong> </body> <script> const $userKey = document.getElementById("userKey"); const $userSecret = document.getElementById("userSecret"); const $siteKey = document.getElementById("siteKey"); const $result = document.getElementById("result"); $userKey.addEventListener("change", onChange); $userSecret.addEventListener("change", onChange); $siteKey.addEventListener("keyup", generate); let s = null; function onChange() { s = null; if ($userKey.value === "" || $userSecret.value === "") return; s = new spectre.Spectre($userKey.value, $userSecret.value); generate(); } function generate() { if (s === null || $siteKey.value === "") return; const pw = s.site($siteKey.value); $result.innerText = pw; } </script>