Skip to content

Commit

Permalink
optionally submit form after password inject
Browse files Browse the repository at this point in the history
Issue #37
  • Loading branch information
ttyridal committed Mar 7, 2017
1 parent 7932c12 commit 1c46684
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ext/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ function store_get() {
'defaulttype': prefs.defaulttype,
'passwdtimeout': prefs.pass_clear_delay,
'pass_store': prefs.pass_store,
'pass_to_clipboard': false, //prefs.pass_to_clipboard,
'pass_to_clipboard': prefs.pass_to_clipboard,
'auto_submit_pass': prefs.auto_submit_pass,
'hotkeycombo': prefs.hotkeycombo,
'max_alg_version': global_prefs.get('extensions.' + self.id + '.max_alg_version', 3),
};
Expand Down
3 changes: 3 additions & 0 deletions ext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
{
"name":"pass_to_clipboard", "title":"Copy password to clipboard", "type": "bool", "value": true
},
{
"name":"auto_submit_pass", "title":"Submit after password inject", "type": "bool", "value": false
},
{ "name":"sdk.console.logLevel", "title":"Log level", "type":"menulist", "value":"error", "options": [
{"label":"Error", "value":"error"},
{"label":"Warnings & Errors", "value":"warn"},
Expand Down
8 changes: 7 additions & 1 deletion ext/webextension/src/bg/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function store_get(keys) {
'passwdtimeout': xul.passwdtimeout,
'pass_store': xul.pass_store,
'pass_to_clipboard': xul.pass_to_clipboard,
'auto_submit_pass': xul.auto_submit_pass,
'hotkeycombo': xul.hotkeycombo,
'max_alg_version': xul.max_alg_version
};
Expand All @@ -143,6 +144,7 @@ function store_get(keys) {
case 'passwdtimeout':
case 'pass_store':
case 'pass_to_clipboard':
case 'auto_submit_pass':
case 'hotkeycombo':
case 'max_alg_version':
r[k] = settings[k];
Expand Down Expand Up @@ -238,8 +240,12 @@ function update_page_password(pass, allow_subframe) {
if (!allow_subframe && r.frameId)
throw new Update_pass_failed("Not pasting to subframe");

let code = 'document.activeElement.value = ' + JSON.stringify(pass) + '; document.activeElement.dispatchEvent(new Event("change", {bubbles: true, cancelable: true}));';
if (settings.auto_submit_pass)
code += '(document.activeElement.form && window.setTimeout(()=>{document.activeElement.form.dispatchEvent(new Event("submit", {bubbles: true, cancelable: true}));},20));';

return chrome.tabs.executeScript(r.tab.id, {
code: 'document.activeElement.value = ' + JSON.stringify(pass) + '; document.activeElement.dispatchEvent(new Event("change", {bubbles: true, cancelable: true}));',
code: code,
frameId: r.frameId,
matchAboutBlank: true
});
Expand Down

0 comments on commit 1c46684

Please sign in to comment.