diff --git a/ext/lib/main.js b/ext/lib/main.js index 5890e52..ff6301a 100644 --- a/ext/lib/main.js +++ b/ext/lib/main.js @@ -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), }; diff --git a/ext/package.json b/ext/package.json index 58ff177..c992a3e 100644 --- a/ext/package.json +++ b/ext/package.json @@ -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"}, diff --git a/ext/webextension/src/bg/background.js b/ext/webextension/src/bg/background.js index 2b32ecf..12bff0a 100644 --- a/ext/webextension/src/bg/background.js +++ b/ext/webextension/src/bg/background.js @@ -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 }; @@ -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]; @@ -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 });