-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowPassword.js
70 lines (56 loc) · 1.95 KB
/
showPassword.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Filename: showPassword.js
* Author_: a1618@love.com
* Modified By: Olivier Sirol <czo@free.fr>
* License: GPL-2.0 (http://www.gnu.org/copyleft)
* File Created: mars 2020
* Last Modified: Saturday 13 July 2024, 17:09
* Edit Time: 1:22:32
* Description:
* Extension for chromium and firefox
* Show password when double-clicking over password fields.
* Same as https://chrome.google.com/webstore/detail/showpassword/bbiclfnbhommljbjcoelobnnnibemabl
* but only whith double-click.
* I made a clone because when there is a non-personal automatic update, I don’t want my passwords stolen.
*
* Copyright: (C) 2020-2024 Olivier Sirol <czo@free.fr>
*/
(function (win) {
'use strict';
var KEY_ENTER = 13;
var KEY_CTRL = 17;
function mouseDblClick(tar) {
tar.addEventListener('dblclick', function () {
if (tar.type === 'password') {
tar.type = 'text';
} else {
tar.type = 'password';
}
}, false);
tar.addEventListener('blur', function () {
tar.type = 'password';
}, false);
tar.addEventListener('keydown', function (e) {
if (e.keyCode === KEY_ENTER)
tar.type = 'password';
}, false);
}
var doc = win.document;
var MutationObserver = win.MutationObserver || win.WebKitMutationObserver;
function modifyInputs() {
var passwordInputs = doc.querySelectorAll('input[type=password]');
for (var j = 0; j < passwordInputs.length; j++) {
var passwordInput = passwordInputs[j];
if (!passwordInput.ready) {
mouseDblClick(passwordInput);
passwordInput.ready = true; //mark as modified
}
}
}
modifyInputs();
var observer = new MutationObserver(modifyInputs);
observer.observe(doc.documentElement, {
childList: true,
subtree: true
});
})(this);