Add a checkbox to only copy password into clipboard from popup (and a default behaviour from options)
This commit is contained in:
parent
354ddbbba9
commit
7f95b19264
|
@ -380,6 +380,14 @@ function extension_load()
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (request.type == "getPopupClipboard")
|
||||||
|
{
|
||||||
|
get_preference("popup_clipboard").then(
|
||||||
|
function (value) {
|
||||||
|
sendResponse({"value" : value});
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else if (request.type == "is_gpass_enabled")
|
else if (request.type == "is_gpass_enabled")
|
||||||
{
|
{
|
||||||
browser.tabs.query({active:true, currentWindow:true},
|
browser.tabs.query({active:true, currentWindow:true},
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
var default_preferences = {"pbkdf2_level": 1000,
|
var default_preferences = {"pbkdf2_level": 1000,
|
||||||
"account_url": "https://gpass-demo.soutade.fr/demo",
|
"account_url": "https://gpass-demo.soutade.fr/demo",
|
||||||
"always_disabled":false
|
"always_disabled":false,
|
||||||
|
"popup_clipboard":false
|
||||||
};
|
};
|
||||||
|
|
||||||
function get_preference(key)
|
function get_preference(key)
|
||||||
|
|
|
@ -10,8 +10,9 @@
|
||||||
<br/>
|
<br/>
|
||||||
<b>PBKDF2 level</b> Number of iterations used to derivate master key <input id="pbkdf2_level" type="number"/><br />
|
<b>PBKDF2 level</b> Number of iterations used to derivate master key <input id="pbkdf2_level" type="number"/><br />
|
||||||
<br/>
|
<br/>
|
||||||
|
<b>Always disabled</b> Disable gPass for all websites. You can still use popup, but no hook is attached to login forms <input id="always_disabled" type="checkbox"/><br />
|
||||||
<br/>
|
<br/>
|
||||||
<b>Always disabled</b> Disable gPass for all websites. You can still use popup, but no hook is attached to login forms<input id="always_disabled" type="checkbox"/><br />
|
<b>Popup clipboard copy</b> Copy password into clipboard (by default) when using popup <input id="popup_clipboard" type="checkbox"/><br />
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<input type="button" id="save" value="Save"/>
|
<input type="button" id="save" value="Save"/>
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
var default_preferences = {"pbkdf2_level": 1000,
|
var default_preferences = {"pbkdf2_level": 1000,
|
||||||
"account_url": "https://gpass-demo.soutade.fr/demo",
|
"account_url": "https://gpass-demo.soutade.fr/demo",
|
||||||
"always_disabled":false
|
"always_disabled":false,
|
||||||
|
"popup_clipboard":false
|
||||||
};
|
};
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
var account_url = document.getElementById('account_url').value;
|
var account_url = document.getElementById('account_url').value;
|
||||||
var pbkdf2_level = document.getElementById('pbkdf2_level').value;
|
var pbkdf2_level = document.getElementById('pbkdf2_level').value;
|
||||||
var always_disabled = document.getElementById('always_disabled').checked;
|
var always_disabled = document.getElementById('always_disabled').checked;
|
||||||
|
var popup_clipboard = document.getElementById('popup_clipboard').checked;
|
||||||
|
|
||||||
chrome.storage.local.set({
|
chrome.storage.local.set({
|
||||||
'account_url': account_url,
|
'account_url': account_url,
|
||||||
'pbkdf2_level': pbkdf2_level,
|
'pbkdf2_level': pbkdf2_level,
|
||||||
'always_disabled': always_disabled,
|
'always_disabled': always_disabled,
|
||||||
|
'popup_clipboard': popup_clipboard,
|
||||||
}, function() {
|
}, function() {
|
||||||
alert('Saved');
|
alert('Saved');
|
||||||
});
|
});
|
||||||
|
@ -37,6 +40,7 @@ chrome.storage.local.get(null, function(prefs) {
|
||||||
restoreOption(prefs, 'account_url');
|
restoreOption(prefs, 'account_url');
|
||||||
restoreOption(prefs, 'pbkdf2_level');
|
restoreOption(prefs, 'pbkdf2_level');
|
||||||
restoreOption(prefs, 'always_disabled');
|
restoreOption(prefs, 'always_disabled');
|
||||||
|
restoreOption(prefs, 'popup_clipboard');
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('save').addEventListener("click", save);
|
document.getElementById('save').addEventListener("click", save);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<body>
|
<body>
|
||||||
<form id="passwordForm" autocomplete="off">
|
<form id="passwordForm" autocomplete="off">
|
||||||
Username <input type="text" id="gPassUsername" autofocus></input><br/> Master key <input type="password" id="gPassMasterKey"/><br/>
|
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>
|
<input id="getButton" type="submit" value="Get"/> <a id="serverLink" href="">Your server</a>
|
||||||
</form>
|
</form>
|
||||||
<script src="misc.js"></script>
|
<script src="misc.js"></script>
|
||||||
|
|
|
@ -17,7 +17,52 @@
|
||||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
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)
|
function _query_tabs_get_password(tabs)
|
||||||
{
|
{
|
||||||
|
@ -55,38 +100,11 @@ function _query_tabs_get_password(tabs)
|
||||||
};
|
};
|
||||||
|
|
||||||
browser.runtime.sendMessage(parameters, {},
|
browser.runtime.sendMessage(parameters, {},
|
||||||
function (response)
|
function (response)
|
||||||
{
|
{
|
||||||
debug("Get Response");
|
return _server_response(response, tabs, do_submit, force_copy);
|
||||||
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;
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
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 */
|
/* Setup server link address */
|
||||||
parameters = {
|
parameters = {
|
||||||
type:"getServerAddress"
|
"type":"getServerAddress"
|
||||||
};
|
};
|
||||||
|
|
||||||
browser.runtime.sendMessage(parameters, {},
|
browser.runtime.sendMessage(parameters, {},
|
||||||
|
|
|
@ -380,6 +380,14 @@ function extension_load()
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (request.type == "getPopupClipboard")
|
||||||
|
{
|
||||||
|
get_preference("popup_clipboard").then(
|
||||||
|
function (value) {
|
||||||
|
sendResponse({"value" : value});
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else if (request.type == "is_gpass_enabled")
|
else if (request.type == "is_gpass_enabled")
|
||||||
{
|
{
|
||||||
browser.tabs.query({active:true, currentWindow:true},
|
browser.tabs.query({active:true, currentWindow:true},
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
var default_preferences = {"pbkdf2_level": 1000,
|
var default_preferences = {"pbkdf2_level": 1000,
|
||||||
"account_url": "https://gpass-demo.soutade.fr/demo",
|
"account_url": "https://gpass-demo.soutade.fr/demo",
|
||||||
"always_disabled":false
|
"always_disabled":false,
|
||||||
|
"popup_clipboard":false
|
||||||
};
|
};
|
||||||
|
|
||||||
function get_preference(key)
|
function get_preference(key)
|
||||||
|
|
|
@ -10,8 +10,9 @@
|
||||||
<br/>
|
<br/>
|
||||||
<b>PBKDF2 level</b> Number of iterations used to derivate master key <input id="pbkdf2_level" type="number"/><br />
|
<b>PBKDF2 level</b> Number of iterations used to derivate master key <input id="pbkdf2_level" type="number"/><br />
|
||||||
<br/>
|
<br/>
|
||||||
|
<b>Always disabled</b> Disable gPass for all websites. You can still use popup, but no hook is attached to login forms <input id="always_disabled" type="checkbox"/><br />
|
||||||
<br/>
|
<br/>
|
||||||
<b>Always disabled</b> Disable gPass for all websites. You can still use popup, but no hook is attached to login forms<input id="always_disabled" type="checkbox"/><br />
|
<b>Popup clipboard copy</b> Copy password into clipboard (by default) when using popup <input id="popup_clipboard" type="checkbox"/><br />
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<input type="button" id="save" value="Save"/>
|
<input type="button" id="save" value="Save"/>
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
var default_preferences = {"pbkdf2_level": 1000,
|
var default_preferences = {"pbkdf2_level": 1000,
|
||||||
"account_url": "https://gpass-demo.soutade.fr/demo",
|
"account_url": "https://gpass-demo.soutade.fr/demo",
|
||||||
"always_disabled":false
|
"always_disabled":false,
|
||||||
|
"popup_clipboard":false
|
||||||
};
|
};
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
var account_url = document.getElementById('account_url').value;
|
var account_url = document.getElementById('account_url').value;
|
||||||
var pbkdf2_level = document.getElementById('pbkdf2_level').value;
|
var pbkdf2_level = document.getElementById('pbkdf2_level').value;
|
||||||
var always_disabled = document.getElementById('always_disabled').checked;
|
var always_disabled = document.getElementById('always_disabled').checked;
|
||||||
|
var popup_clipboard = document.getElementById('popup_clipboard').checked;
|
||||||
|
|
||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
"account_url":account_url,
|
"account_url":account_url,
|
||||||
"pbkdf2_level":pbkdf2_level,
|
"pbkdf2_level":pbkdf2_level,
|
||||||
"always_disabled": always_disabled,
|
"always_disabled": always_disabled,
|
||||||
|
"popup_clipboard": popup_clipboard,
|
||||||
})
|
})
|
||||||
.then(function ok() { alert("Saved"); },
|
.then(function ok() { alert("Saved"); },
|
||||||
function err() { alert("Cannot save your preferences");}
|
function err() { alert("Cannot save your preferences");}
|
||||||
|
@ -42,6 +45,7 @@ function restoreOptions()
|
||||||
restoreOption(prefs, 'account_url');
|
restoreOption(prefs, 'account_url');
|
||||||
restoreOption(prefs, 'pbkdf2_level');
|
restoreOption(prefs, 'pbkdf2_level');
|
||||||
restoreOption(prefs, 'always_disabled');
|
restoreOption(prefs, 'always_disabled');
|
||||||
|
restoreOption(prefs, 'popup_clipboard');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<body>
|
<body>
|
||||||
<form id="passwordForm" autocomplete="off">
|
<form id="passwordForm" autocomplete="off">
|
||||||
Username <input type="text" id="gPassUsername" autofocus></input><br/> Master key <input type="password" id="gPassMasterKey"/><br/>
|
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>
|
<input id="getButton" type="submit" value="Get"/> <a id="serverLink" href="">Your server</a>
|
||||||
</form>
|
</form>
|
||||||
<script src="misc.js"></script>
|
<script src="misc.js"></script>
|
||||||
|
|
|
@ -17,7 +17,52 @@
|
||||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
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)
|
function _query_tabs_get_password(tabs)
|
||||||
{
|
{
|
||||||
|
@ -55,38 +100,11 @@ function _query_tabs_get_password(tabs)
|
||||||
};
|
};
|
||||||
|
|
||||||
browser.runtime.sendMessage(parameters, {},
|
browser.runtime.sendMessage(parameters, {},
|
||||||
function (response)
|
function (response)
|
||||||
{
|
{
|
||||||
debug("Get Response");
|
return _server_response(response, tabs, do_submit, force_copy);
|
||||||
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;
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
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 */
|
/* Setup server link address */
|
||||||
parameters = {
|
parameters = {
|
||||||
type:"getServerAddress"
|
"type":"getServerAddress"
|
||||||
};
|
};
|
||||||
|
|
||||||
browser.runtime.sendMessage(parameters, {},
|
browser.runtime.sendMessage(parameters, {},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user