Add a checkbox to only copy password into clipboard from popup (and a default behaviour from options)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
<body>
|
||||
<form id="passwordForm" autocomplete="off">
|
||||
Username <input type="text" id="gPassUsername" autofocus></input><br/> Master key <input type="password" id="gPassMasterKey"/><br/>
|
||||
Copy password into clipboard <input id="clipboard" type="checkbox"/><br />
|
||||
<input id="getButton" type="submit" value="Get"/> <a id="serverLink" href="">Your server</a>
|
||||
</form>
|
||||
<script src="misc.js"></script>
|
||||
|
@@ -17,7 +17,52 @@
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var username_filled = false
|
||||
var username_filled = false;
|
||||
|
||||
function _server_response(response, tabs, do_submit, force_copy)
|
||||
{
|
||||
debug("Get Response");
|
||||
if (response.value == SERVER.OK)
|
||||
{
|
||||
/* Only copy */
|
||||
if (document.getElementById("clipboard").checked)
|
||||
{
|
||||
navigator.clipboard.writeText(response.password).then(function() {
|
||||
notify("Password pasted into clipboard", "");
|
||||
window.close();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Fill + optional copy */
|
||||
parameters = {
|
||||
"type":"setPassword",
|
||||
"password":response.password,
|
||||
"submit":do_submit
|
||||
};
|
||||
send_tab_message(tabs[0].id, parameters,
|
||||
function(arg)
|
||||
{
|
||||
debug("Response to setPassword " + arg);
|
||||
if (arg === "" || force_copy)
|
||||
{
|
||||
navigator.clipboard.writeText(response.password).then(function() {
|
||||
notify("Password pasted into clipboard", "");
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
notify("Password filled", "");
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function _query_tabs_get_password(tabs)
|
||||
{
|
||||
@@ -55,38 +100,11 @@ function _query_tabs_get_password(tabs)
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response)
|
||||
{
|
||||
debug("Get Response");
|
||||
if (response.value == SERVER.OK)
|
||||
{
|
||||
parameters = {
|
||||
"type":"setPassword",
|
||||
"password":response.password,
|
||||
"submit":do_submit
|
||||
};
|
||||
send_tab_message(tabs[0].id, parameters,
|
||||
function(arg)
|
||||
{
|
||||
debug("Response to setPassword " + arg);
|
||||
if (arg === "" || force_copy)
|
||||
{
|
||||
navigator.clipboard.writeText(response.password).then(function() {
|
||||
notify("Password pasted into clipboard", "");
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
notify("Password filled", "");
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
function (response)
|
||||
{
|
||||
return _server_response(response, tabs, do_submit, force_copy);
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -129,9 +147,22 @@ function _query_tabs_init(tabs)
|
||||
}
|
||||
});
|
||||
|
||||
/* Clipboard copy */
|
||||
parameters = {
|
||||
"type":"getPopupClipboard"
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response)
|
||||
{
|
||||
document.getElementById("clipboard").checked = response.value;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
/* Setup server link address */
|
||||
parameters = {
|
||||
type:"getServerAddress"
|
||||
"type":"getServerAddress"
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
|
Reference in New Issue
Block a user