Big update:
* Move all core functions from mains.js to background.js
* Use message interface for IPCs between main.js, background.js and popup.js
* Add popup interface :
* safest method to compute masterkey
* Direct access to our own gPass server with auto URL and username fill
* Add some specific menus :
* Access to gPass settings
* Allow to disable extension
* Update gPass icon when a password field has focus and gPass is ready to work
This commit is contained in:
1
chrome_addon/popup/compat.js
Symbolic link
1
chrome_addon/popup/compat.js
Symbolic link
@@ -0,0 +1 @@
|
||||
../compat.js
|
||||
1
chrome_addon/popup/misc.js
Symbolic link
1
chrome_addon/popup/misc.js
Symbolic link
@@ -0,0 +1 @@
|
||||
../lib/misc.js
|
||||
15
chrome_addon/popup/popup.html
Normal file
15
chrome_addon/popup/popup.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<form id="passwordForm" autocomplete="off">
|
||||
Username <input type="text" id="gPassUsername" autofocus></input><br/> Master key <input type="password" id="gPassMasterKey"/><br/>
|
||||
<input id="getButton" type="submit" value="Get"/> <a id="serverLink" href="">Your server</a>
|
||||
</form>
|
||||
<script src="misc.js"></script>
|
||||
<script src="compat.js"></script>
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
144
chrome_addon/popup/popup.js
Normal file
144
chrome_addon/popup/popup.js
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
Copyright (C) 2020 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var username_filled = false
|
||||
|
||||
function _query_tabs_get_password(tabs)
|
||||
{
|
||||
if (tabs.length <= 0) return;
|
||||
|
||||
var username = document.getElementById("gPassUsername").value;
|
||||
var mkey = document.getElementById("gPassMasterKey").value;
|
||||
|
||||
if (username == "" || mkey == "")
|
||||
return;
|
||||
|
||||
document.getElementById("gPassMasterKey").value = "";
|
||||
|
||||
var do_submit = !mkey.startsWith("@_") && username_filled;
|
||||
if (mkey.startsWith("@@") || mkey.startsWith("@_"))
|
||||
mkey = mkey.substring(2);
|
||||
|
||||
var domain = tabs[0].url;
|
||||
|
||||
var logins = new Array();
|
||||
logins.push(username);
|
||||
|
||||
parameters = {
|
||||
type:"password",
|
||||
logins:logins,
|
||||
domain:domain,
|
||||
mkey:mkey,
|
||||
options:{}
|
||||
};
|
||||
|
||||
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 == "")
|
||||
{
|
||||
navigator.clipboard.writeText(response.password);
|
||||
notify("Password pasted into clipboard", "");
|
||||
}
|
||||
else
|
||||
notify("Password filled", "");
|
||||
window.close();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_password(evt)
|
||||
{
|
||||
debug('get_password');
|
||||
|
||||
evt.preventDefault();
|
||||
|
||||
browser.tabs.query({active:true, currentWindow:true}, _query_tabs_get_password);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
pform = document.getElementById("passwordForm");
|
||||
|
||||
if (pform != null)
|
||||
pform.onsubmit = get_password;
|
||||
|
||||
function _query_tabs_init(tabs)
|
||||
{
|
||||
debug("_query_tabs_init");
|
||||
|
||||
if (tabs.length != 1) return;
|
||||
|
||||
/* Fill username */
|
||||
parameters = {
|
||||
"type":"getUsername"
|
||||
};
|
||||
|
||||
send_tab_message(tabs[0].id, parameters,
|
||||
function (response)
|
||||
{
|
||||
if (response !== undefined && response != "")
|
||||
{
|
||||
document.getElementById("gPassUsername").value = response;
|
||||
document.getElementById("gPassMasterKey").focus();
|
||||
username_filled = true;
|
||||
}
|
||||
});
|
||||
|
||||
/* Setup server link address */
|
||||
parameters = {
|
||||
type:"getServerAddress"
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response)
|
||||
{
|
||||
url = response.value;
|
||||
url = url.substring(0, url.lastIndexOf('/'));
|
||||
url += '?';
|
||||
url += 'url=' + encodeURI(tabs[0].url.split("?")[0]);
|
||||
url += '&user=' + document.getElementById("gPassUsername").value;
|
||||
link = document.getElementById("serverLink");
|
||||
link.href = url;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
browser.tabs.query({active:true, currentWindow:true}, _query_tabs_init);
|
||||
Reference in New Issue
Block a user