Seems to work okay

This commit is contained in:
Neale Pickett 2017-03-12 20:05:02 -06:00
commit 8cb222ce09
20 changed files with 372 additions and 0 deletions

19
LICENSE.md Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2017 Neale Pickett <neale@woozle.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The software is provided "as is", without warranty of any kind, express or
implied, including but not limited to the warranties of merchantability,
fitness for a particular purpose and noninfringement. In no event shall the
authors or copyright holders be liable for any claim, damages or other
liability, whether in an action of contract, tort or otherwise, arising from,
out of or in connection with the software or the use or other dealings in the
software.

10
_locales/en/messages.json Normal file
View File

@ -0,0 +1,10 @@
{
"extName": {
"message": "PWGen: Simple password generator",
"description": "Extension name"
},
"extDescription": {
"message": "Simple password generator using material design",
"description": "Extension description"
}
}

8
css/material.min.css vendored Normal file

File diff suppressed because one or more lines are too long

0
css/style.css Normal file
View File

BIN
img/lock-128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
img/lock-16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

BIN
img/lock-48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
img/lock-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

10
js/material.min.js vendored Normal file

File diff suppressed because one or more lines are too long

65
js/popup.js Normal file
View File

@ -0,0 +1,65 @@
var letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var numbers = "0123456789";
var symbols = "!@#$^&*()~+-=_";
function randint(range) {
let a = new Uint32Array(1);
window.crypto.getRandomValues(a);
return (a % range);
}
function choice(items) {
let n = randint(items.length);
return items[n];
}
function shuffle(items) {
for (let i = 0; i < items.length; i += 1) {
let p = randint(items.length);
let c = items[p];
items[p] = items[i];
items[i] = c;
}
}
function regen() {
let num = document.getElementById('num').checked;
let sym = document.getElementById('sym').checked;
let len = document.getElementById('len').value;
let pw = document.getElementById('password');
let chars = [];
let nnums = num?(randint(len/3)+1):0;
let nsyms = sym?(randint(len/5)+1):0;
for (let i = 0; i < nnums; i += 1) {
chars.push(choice(numbers));
}
for (let i = 0; i < nsyms; i += 1) {
chars.push(choice(symbols));
}
for (let i = chars.length; i < len; i += 1) {
chars.push(choice(letters));
}
shuffle(chars);
password.value = chars.join("");
// Put it on the clipboard
let range = document.createRange();
range.selectNode(pw);
window.getSelection().addRange(range);
document.execCommand('copy');
window.getSelection().removeAllRanges();
document.getElementById('lentxt').textContent = len;
}
function setup() {
document.getElementById('regen').addEventListener('click', regen);
document.getElementById('num').addEventListener('change', regen);
document.getElementById('sym').addEventListener('change', regen);
document.getElementById('len').addEventListener('input', regen);
regen();
}
document.addEventListener('DOMContentLoaded', setup);

19
manifest.json Normal file
View File

@ -0,0 +1,19 @@
{
"manifest_version": 2,
"name": "__MSG_extName__",
"short_name": "PWGen",
"author": "Neale Pickett <neale@woozle.org>",
"version": "1.0",
"default_locale": "en",
"description": "__MSG_extDescription__",
"icons": {
"128": "img/lock-128.png",
"16": "img/lock-16.png",
"48": "img/lock-48.png"
},
"browser_action": {
"default_icon": "img/lock-icon.png",
"default_popup": "popup.html"
}
}

44
popup.html Normal file
View File

@ -0,0 +1,44 @@
<!doctype html>
<html>
<head>
<title>PWGen</title>
<link rel="stylesheet" href="css/material.min.css">
<script src="js/material.min.js"></script>
<script src="js/popup.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body style="width:26em;">
<div class="mdl-card">
<!--
<div class="mdl-card__title">
<h1 class="mdl-card__title-text" id="title">PWGen</h1>
</div>
-->
<div class="mdl-card__supporting-text">
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="num">
<input type="checkbox" id="num" class="mdl-checkbox__input" checked>
<span class="mdl-checkbox__label">Numbers</span>
</label>
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="sym">
<input type="checkbox" id="sym" class="mdl-checkbox__input" checked>
<span class="mdl-checkbox__label">Symbols</span>
</label>
<label for="len">
<input class="mdl-slider mdl-js-slider" type="range" min="4" max="26" value="12" tabindex="0" id="len">
<span>Length: <span id="lentxt"></span></span>
</label>
<div class="mdl-textfield mdl-js-textfield">
<input class="mdl-textfield__input" type="text" id="password">
<!-- <label class="mdl-textfield__label" for="password">Password</label> -->
</div>
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored" id="regen">
rebuild
</button>
<p>Password is in your clipboard</p>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
res/lock-tile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

136
res/lock-tile.svg Normal file
View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="440"
height="280"
viewBox="0 0 440 280"
enable-background="new 0 0 196 197"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="lock-tile.svg"><metadata
id="metadata3244"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs3242" /><sodipodi:namedview
pagecolor="#122e29"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1016"
id="namedview3240"
showgrid="false"
inkscape:snap-bbox="true"
inkscape:snap-intersection-paths="true"
fit-margin-top="10"
fit-margin-left="10"
fit-margin-right="10"
fit-margin-bottom="10"
inkscape:zoom="1.4142136"
inkscape:cx="155.66874"
inkscape:cy="121.31836"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" /><text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:30px;line-height:100%;font-family:'URW Gothic L';-inkscape-font-specification:'URW Gothic L, Normal';text-align:start;letter-spacing:3.41000009px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#efefef;fill-opacity:0.30638302;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="120.75469"
y="1.2595966"
id="text3146"
sodipodi:linespacing="100%"
transform="matrix(0.93200991,-0.36243278,0.36243278,0.93200991,0,0)"><tspan
sodipodi:role="line"
id="tspan3148"
x="120.75469"
y="1.2595966" /><tspan
sodipodi:role="line"
x="120.75469"
y="31.259596"
id="tspan3150">Xql_C^v2MlYD</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="61.259594"
id="tspan3156">346_APtarl)a</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="91.259598"
id="tspan3160">Dqy$M2du@=pq</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="121.2596"
id="tspan3164">98prN4~@!oUo</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="151.2596"
id="tspan3168">X$)#h3L#2IhV</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="181.2596"
id="tspan3172">!$wnunu2H!ud</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="211.2596"
id="tspan3176">2Y8$O*25WVjy</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="241.2596"
id="tspan3259">4dv&amp;1BFE@ic1</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="271.25961"
id="tspan3184">p*9IsR6Ev!M5</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="301.25961"
id="tspan3271">7N^nkOI)9v2)</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="331.25961"
id="tspan3279">Qqspy7Av8#)8</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="361.25961"
id="tspan3287">*=F2+W)Sf3nZ</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="391.25961"
id="tspan3291">CkZ!(38EPm7v</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="421.25961"
id="tspan3295">(7f($5AY#zb0</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="451.25961"
id="tspan3299">)DgL5XRf-E_b</tspan><tspan
sodipodi:role="line"
x="120.75469"
y="481.25961"
id="tspan3283" /></text>
<g
id="g3186"
transform="matrix(1.3381286,0,0,1.3381286,-346.22184,-27.659424)"><path
sodipodi:nodetypes="sscccccccccccs"
inkscape:connector-curvature="0"
id="path3269"
d="M 340.49902,29.087891 C 311.7888,29.087789 288.51454,52.36205 288.51464,81.07227 l 0,12.29492 23.48633,0 0,-12.29492 -0.0371,0 c -3.4e-4,-15.75968 12.77548,-28.5355 28.53516,-28.53516 15.75968,-3.5e-4 28.5355,12.77548 28.53516,28.53516 l -0.0332,0 0,12.29492 23.48438,0 0,-12.29492 -0.002,0 C 392.4835,52.36204 369.20924,29.087787 340.49902,29.087891 Z"
style="opacity:1;fill:#800080;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1.33161473;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><path
inkscape:connector-curvature="0"
id="rect3248"
d="M 288.17773,103.56836 C 276.44514,103.56836 267,113.0135 267,124.74609 l 0,75.57618 c 0,11.73259 9.44514,21.17773 21.17773,21.17773 l 104.64454,0 C 404.55486,221.5 414,212.05486 414,200.32227 l 0,-75.57618 c 0,-11.73259 -9.44514,-21.17773 -21.17773,-21.17773 l -104.64454,0 z m 53.09961,37.57032 a 15.322605,15.322605 0 0 1 15.32422,15.32226 15.322605,15.322605 0 0 1 -6.46093,12.47656 l 0,16.60547 c 0,5.01652 -3.83798,9.05469 -8.60352,9.05469 -4.76554,0 -8.60156,-4.03817 -8.60156,-9.05469 l 0,-16.24609 a 15.322605,15.322605 0 0 1 -6.98047,-12.83594 15.322605,15.322605 0 0 1 15.32226,-15.32226 z"
style="opacity:1;fill:#800080;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1.29999995;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /></g></svg>

After

Width:  |  Height:  |  Size: 5.8 KiB

61
res/lock.svg Normal file
View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="194"
height="194"
viewBox="0 0 194 194"
enable-background="new 0 0 196 197"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="lock.svg"
inkscape:export-filename="/home/neale/src/chrome-pwgen/img/lock-icon.png"
inkscape:export-xdpi="59.381443"
inkscape:export-ydpi="59.381443"><metadata
id="metadata3244"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs3242" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1366"
inkscape:window-height="704"
id="namedview3240"
showgrid="false"
inkscape:snap-bbox="true"
inkscape:snap-intersection-paths="true"
fit-margin-top="0"
fit-margin-left="10"
fit-margin-right="10"
fit-margin-bottom="0"
inkscape:zoom="1.4142136"
inkscape:cx="14.094092"
inkscape:cy="87.525349"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" /><path
style="opacity:1;fill:#800080;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1.33161473;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
d="M 96.999019,0.93788578 C 68.288797,0.93778468 45.01454,24.212041 45.014641,52.92226 l 0,12.294922 23.486328,0 0,-12.294922 -0.03711,0 c -3.43e-4,-15.759674 12.775483,-28.5355 28.53516,-28.535156 15.759681,-3.46e-4 28.535501,12.77548 28.535161,28.535156 l -0.0332,0 0,12.294922 23.48438,0 0,-12.294922 -0.002,0 C 148.9835,24.212039 125.70924,0.93778198 96.999019,0.93788578 Z"
id="path3269"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sscccccccccccs" /><path
style="opacity:1;fill:#800080;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1.29999995;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
d="M 44.677734,75.418354 C 32.945142,75.418354 23.5,84.863495 23.5,96.596084 l 0,75.576186 c 0,11.73259 9.445142,21.17773 21.177734,21.17773 l 104.644536,0 c 11.73259,0 21.17773,-9.44514 21.17773,-21.17773 l 0,-75.576186 c 0,-11.732589 -9.44514,-21.17773 -21.17773,-21.17773 l -104.644536,0 z M 97.77734,112.98868 a 15.322605,15.322605 0 0 1 15.32422,15.32226 15.322605,15.322605 0 0 1 -6.46093,12.47656 l 0,16.60547 c 0,5.01652 -3.83798,9.05469 -8.60352,9.05469 -4.76554,0 -8.601563,-4.03817 -8.601563,-9.05469 l 0,-16.24609 A 15.322605,15.322605 0 0 1 82.455078,128.31094 15.322605,15.322605 0 0 1 97.77734,112.98868 Z"
id="rect3248"
inkscape:connector-curvature="0" /></svg>

After

Width:  |  Height:  |  Size: 3.3 KiB