mirror of
https://github.com/S2-/pwgen.git
synced 2025-08-03 01:00:04 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
6c773377b1 | |||
b0932baeea | |||
81d5bbb055 | |||
c26eba33c0 | |||
42838040d2 | |||
8ab06aa554 | |||
07b558eeb7 | |||
be3046051a | |||
17c92ce99a |
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 68 KiB |
@@ -2,7 +2,7 @@
|
||||
"description": "Just a toolbar button that generates a password and copies it to your clipboard.",
|
||||
"manifest_version": 2,
|
||||
"name": "pwgen reloaded",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.7",
|
||||
"homepage_url": "https://github.com/S2-/pwgen",
|
||||
"icons": {
|
||||
"48": "icons/lock-48.png"
|
||||
|
@@ -2,6 +2,10 @@ body {
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
div {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
-moz-appearance: none;
|
||||
color: var(--in-content-text-color);
|
||||
|
@@ -2,10 +2,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="chrome://global/skin/global.css" type="text/css" />
|
||||
<link rel="stylesheet" href="chrome://global/skin/in-content/common.css" type="text/css" />
|
||||
<link rel="stylesheet" href="chrome://mozapps/content/extensions/extensions.css" type="text/css" />
|
||||
<link rel="stylesheet" href="resource://gre-resources/forms.css" type="text/css" />
|
||||
|
||||
<link rel="stylesheet" href="pwgen.css"/>
|
||||
</head>
|
||||
|
@@ -1,12 +1,17 @@
|
||||
function randPassword(length, includeSpecial) {
|
||||
let pwdChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
|
||||
let pwdChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
if (includeSpecial) {
|
||||
pwdChars += '°^!"§$%&/()=?`´\\}][{²³€|<>-.,;:*+_µ@~';
|
||||
}
|
||||
let randPassword = Array(length).fill(pwdChars).map(function(x) {
|
||||
return x[Math.floor(Math.random() * x.length)]
|
||||
}).join('');
|
||||
return randPassword;
|
||||
|
||||
let randValues = new Uint32Array(length);
|
||||
let randPwd = '';
|
||||
window.crypto.getRandomValues(randValues);
|
||||
for(i=0; i<length; i++)
|
||||
{
|
||||
randPwd += pwdChars[randValues[i] % pwdChars.length];
|
||||
}
|
||||
return randPwd;
|
||||
}
|
||||
|
||||
function getParams() {
|
||||
@@ -30,30 +35,34 @@ function saveOptions(options) {
|
||||
}
|
||||
|
||||
function copypasstoclippboard() {
|
||||
setTimeout(function() {
|
||||
var copyText = document.getElementById('pw');
|
||||
copyText.select();
|
||||
document.execCommand('copy');
|
||||
}, 100);
|
||||
}
|
||||
|
||||
document.getElementById('new').addEventListener('click', (ev) => {
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
document.getElementById('new').addEventListener('click', (ev) => {
|
||||
ev.preventDefault();
|
||||
var params = getParams();
|
||||
document.getElementById('pw').value = randPassword(params.length, params.special);
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById('copy').addEventListener('click', (ev) => {
|
||||
document.getElementById('copy').addEventListener('click', (ev) => {
|
||||
ev.preventDefault();
|
||||
copypasstoclippboard();
|
||||
});
|
||||
});
|
||||
|
||||
var list = document.getElementsByTagName('input');
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var list = document.getElementsByTagName('input');
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
list[i].addEventListener('change', (ev) => {
|
||||
saveOptions(getParams());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
loadOptions().then((options) => {
|
||||
loadOptions().then((options) => {
|
||||
document.getElementById('length').value = options.length;
|
||||
document.getElementById('special').checked = options.special;
|
||||
document.getElementById('directcopy').checked = options.directcopy;
|
||||
@@ -62,4 +71,7 @@ loadOptions().then((options) => {
|
||||
if (options.directcopy) {
|
||||
copypasstoclippboard();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user