Skip to content

Commit

Permalink
Version 1.0.0
Browse files Browse the repository at this point in the history
- Fix bugs
  • Loading branch information
Alessandro committed May 5, 2022
1 parent 0dd5869 commit 6e69625
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 97 deletions.
2 changes: 0 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ <h2>Generate all password you want!</h2>
<select class="size elem-with-background" name="size" id="size">
<option value="">-- Please choose an option --</option>
<option value="">-- Weak --</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
Expand Down
40 changes: 0 additions & 40 deletions manifest-chrome.json

This file was deleted.

40 changes: 0 additions & 40 deletions manifest-firefox.json

This file was deleted.

22 changes: 18 additions & 4 deletions script/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ browser.menus.create({

browser.menus.onClicked.addListener((info, tab) => {
if (info.editable) {

payload = `browser.menus.getTargetElement(${info.targetElementId}).value = `
payload += "\"" + generateRandomStrongPassword() + "\";"

browser.tabs.executeScript(tab.id, {
frameId: info.frameId,
code: payload
Expand All @@ -28,6 +28,20 @@ function generateRandomStrongPassword() {
Array.from(crypto.getRandomValues(new Uint32Array(length)))
.map((x) => wishlist[x % wishlist.length])
.join('');

return generatePassword();

specialChars = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
numbersChars = /[0123456789]/;
lowChars = /[abcdefghijklmnopqrstuvwxyz]/;
uppChars = /[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/;
while (true) {
password = generatePassword();

if (specialChars.test(password) &&
numbersChars.test(password) &&
lowChars.test(password) &&
uppChars.test(password)) {
break;
}
}
return password;
}
43 changes: 32 additions & 11 deletions script/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,54 @@
function generateRandomStrongPassword() {

let size = document.getElementById('size').value;
if(Number(size) == false) { return "Choose a number of size!"; }
if (Number(size) == false) { return "Choose a number of size!"; }

charapters = "";
symbols = "~!@-_#$\"[]{}.:,;<>£%&/\\|()=?^\'";
numbers = "0123456789";
low = "abcdefghijklmnopqrstuvwxyz";
upp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

if(document.getElementById("symbols").checked == true) { charapters = charapters.concat(symbols); }
symbolsFlag = document.getElementById("symbols").checked;
numbersFlag = document.getElementById("numbers").checked;
lowFlag = document.getElementById("low").checked;
uppFlag = document.getElementById("upp").checked;

if(document.getElementById("numbers").checked == true) { charapters = charapters.concat(numbers); }
if (symbolsFlag == true) { charapters = charapters.concat(symbols); }

if(document.getElementById("low").checked == true) { charapters = charapters.concat(low); }

if(document.getElementById("upp").checked == true) { charapters = charapters.concat(upp); }
if (numbersFlag == true) { charapters = charapters.concat(numbers); }

if (lowFlag == true) { charapters = charapters.concat(low); }

if (uppFlag == true) { charapters = charapters.concat(upp); }

if (charapters == "") { return "Select at least 1 option!"; }

if(charapters == "") { return "Select at least 1 option!"; }

var generatePassword = (
length = size,
wishlist = charapters
) =>
Array.from(crypto.getRandomValues(new Uint32Array(length)))
.map((x) => wishlist[x % wishlist.length])
.join('')

return generatePassword();
.join('');

specialChars = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
numbersChars = /[0123456789]/;
lowChars = /[abcdefghijklmnopqrstuvwxyz]/;
uppChars = /[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/;
retry = true;
while (retry) {
password = generatePassword();

if ((specialChars.test(password) == symbolsFlag) &&
(numbersChars.test(password) == numbersFlag) &&
(lowChars.test(password) == lowFlag) &&
(uppChars.test(password) == uppFlag) ||
(size < 8)) {
break;
}
}
return password;
}

function generatePassword() {
Expand Down
4 changes: 4 additions & 0 deletions style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
--little-black: #1C1C1C;
}



html {
text-align: center;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
Expand All @@ -12,6 +14,8 @@ html {
margin-left: 10%;
}



h1 {
color: var(--primary);
font-size: x-large;
Expand Down

0 comments on commit 6e69625

Please sign in to comment.