mirror of
https://github.com/S2-/pwgen.git
synced 2025-08-03 01:00:04 +02:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
6c773377b1 | |||
b0932baeea | |||
81d5bbb055 | |||
c26eba33c0 | |||
42838040d2 | |||
8ab06aa554 | |||
07b558eeb7 | |||
be3046051a | |||
17c92ce99a | |||
9cf67b5dec | |||
736367738f |
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.",
|
"description": "Just a toolbar button that generates a password and copies it to your clipboard.",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "pwgen reloaded",
|
"name": "pwgen reloaded",
|
||||||
"version": "1.1.3",
|
"version": "1.1.7",
|
||||||
"homepage_url": "https://github.com/S2-/pwgen",
|
"homepage_url": "https://github.com/S2-/pwgen",
|
||||||
"icons": {
|
"icons": {
|
||||||
"48": "icons/lock-48.png"
|
"48": "icons/lock-48.png"
|
||||||
|
@@ -1,4 +1,26 @@
|
|||||||
body {
|
body {
|
||||||
cursor: default;
|
margin: 15px;
|
||||||
font: caption;
|
}
|
||||||
}
|
|
||||||
|
div {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="number"] {
|
||||||
|
-moz-appearance: none;
|
||||||
|
color: var(--in-content-text-color);
|
||||||
|
border: 1px solid var(--in-content-box-border-color);
|
||||||
|
-moz-border-top-colors: none !important;
|
||||||
|
-moz-border-right-colors: none !important;
|
||||||
|
-moz-border-bottom-colors: none !important;
|
||||||
|
-moz-border-left-colors: none !important;
|
||||||
|
border-radius: 2px;
|
||||||
|
background-color: var(--in-content-box-background);
|
||||||
|
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
padding: 5px 10px;
|
||||||
|
}
|
||||||
|
input[type="checkbox"] {
|
||||||
|
margin-bottom: -7px;
|
||||||
|
}
|
||||||
|
@@ -2,30 +2,41 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<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="pwgen.css"/>
|
<link rel="stylesheet" href="pwgen.css"/>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<form>
|
<form>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for"length">length</label>
|
<label for"length">length <input type="number" id="length" value="14" min="0" name="length"></label>
|
||||||
<input type="number" id="length" value="14" min="0" name="length">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for"special">include special chars</label>
|
|
||||||
<input type="checkbox" id="special" checked="checked" name="special">
|
<input type="checkbox" id="special" checked="checked" name="special">
|
||||||
|
<label for"special">include special chars</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for"pw">your password</label>
|
<label for="pw">your password</label>
|
||||||
<input type="text" id="pw" name="pw">
|
<input type="text" id="pw" name="pw">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button id="copy">copy to clipboard</button><button id="new">give me an other one</button>
|
<button id="copy" style="margin-left: 0;">copy to clipboard</button><button id="new">give me an other one</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for"directcopy">direct copy</label>
|
|
||||||
<input type="checkbox" id="directcopy" name="directcopy" title="next time when i click the button, copy the new password immediately to the clipboard">
|
<input type="checkbox" id="directcopy" name="directcopy" title="next time when i click the button, copy the new password immediately to the clipboard">
|
||||||
|
<label for="directcopy">direct copy</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
<script src="pwgen.js"></script>
|
<script src="pwgen.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
@@ -1,12 +1,17 @@
|
|||||||
function randPassword(length, includeSpecial) {
|
function randPassword(length, includeSpecial) {
|
||||||
let pwdChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
|
let pwdChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
if (includeSpecial) {
|
if (includeSpecial) {
|
||||||
pwdChars += '°^!"§$%&/()=?`´\\}][{²³€|<>-.,;:*+_µ@~';
|
pwdChars += '°^!"§$%&/()=?`´\\}][{²³€|<>-.,;:*+_µ@~';
|
||||||
}
|
}
|
||||||
let randPassword = Array(length).fill(pwdChars).map(function(x) {
|
|
||||||
return x[Math.floor(Math.random() * x.length)]
|
let randValues = new Uint32Array(length);
|
||||||
}).join('');
|
let randPwd = '';
|
||||||
return randPassword;
|
window.crypto.getRandomValues(randValues);
|
||||||
|
for(i=0; i<length; i++)
|
||||||
|
{
|
||||||
|
randPwd += pwdChars[randValues[i] % pwdChars.length];
|
||||||
|
}
|
||||||
|
return randPwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getParams() {
|
function getParams() {
|
||||||
@@ -30,36 +35,43 @@ function saveOptions(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function copypasstoclippboard() {
|
function copypasstoclippboard() {
|
||||||
var copyText = document.getElementById('pw');
|
setTimeout(function() {
|
||||||
copyText.select();
|
var copyText = document.getElementById('pw');
|
||||||
document.execCommand('copy');
|
copyText.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('new').addEventListener('click', (ev) => {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
ev.preventDefault();
|
|
||||||
var params = getParams();
|
|
||||||
document.getElementById('pw').value = randPassword(params.length, params.special);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('copy').addEventListener('click', (ev) => {
|
document.getElementById('new').addEventListener('click', (ev) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
copypasstoclippboard();
|
var params = getParams();
|
||||||
});
|
document.getElementById('pw').value = randPassword(params.length, params.special);
|
||||||
|
|
||||||
var list = document.getElementsByTagName('input');
|
|
||||||
for (var i = 0; i < list.length; i++) {
|
|
||||||
list[i].addEventListener('change', (ev) => {
|
|
||||||
saveOptions(getParams());
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
loadOptions().then((options) => {
|
document.getElementById('copy').addEventListener('click', (ev) => {
|
||||||
document.getElementById('length').value = options.length;
|
ev.preventDefault();
|
||||||
document.getElementById('special').checked = options.special;
|
|
||||||
document.getElementById('directcopy').checked = options.directcopy;
|
|
||||||
document.getElementById('pw').value = randPassword(getParams().length, getParams().special);
|
|
||||||
|
|
||||||
if (options.directcopy) {
|
|
||||||
copypasstoclippboard();
|
copypasstoclippboard();
|
||||||
|
});
|
||||||
|
|
||||||
|
var list = document.getElementsByTagName('input');
|
||||||
|
for (var i = 0; i < list.length; i++) {
|
||||||
|
list[i].addEventListener('change', (ev) => {
|
||||||
|
saveOptions(getParams());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadOptions().then((options) => {
|
||||||
|
document.getElementById('length').value = options.length;
|
||||||
|
document.getElementById('special').checked = options.special;
|
||||||
|
document.getElementById('directcopy').checked = options.directcopy;
|
||||||
|
document.getElementById('pw').value = randPassword(getParams().length, getParams().special);
|
||||||
|
|
||||||
|
if (options.directcopy) {
|
||||||
|
copypasstoclippboard();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user