Skip to content

Commit 1c46684

Browse files
committed
optionally submit form after password inject
Issue #37
1 parent 7932c12 commit 1c46684

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

ext/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ function store_get() {
9292
'defaulttype': prefs.defaulttype,
9393
'passwdtimeout': prefs.pass_clear_delay,
9494
'pass_store': prefs.pass_store,
95-
'pass_to_clipboard': false, //prefs.pass_to_clipboard,
95+
'pass_to_clipboard': prefs.pass_to_clipboard,
96+
'auto_submit_pass': prefs.auto_submit_pass,
9697
'hotkeycombo': prefs.hotkeycombo,
9798
'max_alg_version': global_prefs.get('extensions.' + self.id + '.max_alg_version', 3),
9899
};

ext/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
{
4646
"name":"pass_to_clipboard", "title":"Copy password to clipboard", "type": "bool", "value": true
4747
},
48+
{
49+
"name":"auto_submit_pass", "title":"Submit after password inject", "type": "bool", "value": false
50+
},
4851
{ "name":"sdk.console.logLevel", "title":"Log level", "type":"menulist", "value":"error", "options": [
4952
{"label":"Error", "value":"error"},
5053
{"label":"Warnings & Errors", "value":"warn"},

ext/webextension/src/bg/background.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ function store_get(keys) {
128128
'passwdtimeout': xul.passwdtimeout,
129129
'pass_store': xul.pass_store,
130130
'pass_to_clipboard': xul.pass_to_clipboard,
131+
'auto_submit_pass': xul.auto_submit_pass,
131132
'hotkeycombo': xul.hotkeycombo,
132133
'max_alg_version': xul.max_alg_version
133134
};
@@ -143,6 +144,7 @@ function store_get(keys) {
143144
case 'passwdtimeout':
144145
case 'pass_store':
145146
case 'pass_to_clipboard':
147+
case 'auto_submit_pass':
146148
case 'hotkeycombo':
147149
case 'max_alg_version':
148150
r[k] = settings[k];
@@ -238,8 +240,12 @@ function update_page_password(pass, allow_subframe) {
238240
if (!allow_subframe && r.frameId)
239241
throw new Update_pass_failed("Not pasting to subframe");
240242

243+
let code = 'document.activeElement.value = ' + JSON.stringify(pass) + '; document.activeElement.dispatchEvent(new Event("change", {bubbles: true, cancelable: true}));';
244+
if (settings.auto_submit_pass)
245+
code += '(document.activeElement.form && window.setTimeout(()=>{document.activeElement.form.dispatchEvent(new Event("submit", {bubbles: true, cancelable: true}));},20));';
246+
241247
return chrome.tabs.executeScript(r.tab.id, {
242-
code: 'document.activeElement.value = ' + JSON.stringify(pass) + '; document.activeElement.dispatchEvent(new Event("change", {bubbles: true, cancelable: true}));',
248+
code: code,
243249
frameId: r.frameId,
244250
matchAboutBlank: true
245251
});

0 commit comments

Comments
 (0)