added lan/loopback whitelist option
This commit is contained in:
parent
7b3fc58f8d
commit
fc96e8daee
@ -66,13 +66,44 @@ let appCode = function (){
|
||||
if (e.key.startsWith('Arrow') || e.key.startsWith('Page')){
|
||||
return true;
|
||||
}
|
||||
pausecomp(down); we
|
||||
pausecomp(down);
|
||||
return true;
|
||||
})
|
||||
|
||||
|
||||
}, 100)
|
||||
}
|
||||
function checkForLANThenRun(){
|
||||
|
||||
let lan = browser.storage.sync.get("keyboardprivacylan");
|
||||
lan.then(function(val){
|
||||
|
||||
if (! val['keyboardprivacylan']){
|
||||
mainKeyboardPrivacy()
|
||||
}
|
||||
else{
|
||||
let hostname = document.location.hostname
|
||||
if (/^(10)\.(.*)\.(.*)\.(.*)$/.test(hostname)){
|
||||
//10.x.x.x
|
||||
}else if (/^(172)\.(1[6-9]|2[0-9]|3[0-1])\.(.*)\.(.*)$/.test(hostname)){
|
||||
//172.16.x.x - 172.31.255.255
|
||||
}else if (/^(192)\.(168)\.(.*)\.(.*)$/.test(hostname)){
|
||||
//192.168.x.x
|
||||
}else if (/^(127)\.(.*)\.(.*)\.(.*)$/.test(hostname)){
|
||||
}
|
||||
else if (hostname == '[::1]'){
|
||||
}
|
||||
else {
|
||||
mainKeyboardPrivacy()
|
||||
return
|
||||
}
|
||||
|
||||
console.debug("Not running private keyboard because lan/loopback hostname")
|
||||
}
|
||||
|
||||
}, function(val){mainKeyboardPrivacy()})
|
||||
|
||||
}
|
||||
function shouldRunKeyboardPrivacy(value){
|
||||
if (typeof value.keyboardprivacywhitelist === 'undefined'){
|
||||
mainKeyboardPrivacy()
|
||||
@ -85,7 +116,8 @@ let appCode = function (){
|
||||
return
|
||||
}
|
||||
}
|
||||
mainKeyboardPrivacy()
|
||||
checkForLANThenRun()
|
||||
|
||||
}
|
||||
function noKeyboardPrivacySettings(value){
|
||||
mainKeyboardPrivacy()
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "Private Keyboard",
|
||||
"version": "1.6",
|
||||
"version": "1.8",
|
||||
|
||||
|
||||
"description": "Protect against keyboard biometrics",
|
||||
|
3
settings/options.css
Normal file
3
settings/options.css
Normal file
@ -0,0 +1,3 @@
|
||||
body{
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
}
|
@ -3,12 +3,15 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="options.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>Trusted domains (comma delimited)</h1>
|
||||
<form>
|
||||
<input type="checkbox" id="whitelistLAN">
|
||||
<label for="whitelistLAN">Whitelist private IP + localhost range hostnames (e.g. routers)</label>
|
||||
<h1>Trusted domains (comma delimited)</h1>
|
||||
<textarea id="whitelist" cols=50 rows=10></textarea>
|
||||
<br><br>
|
||||
<button type="submit">Save</button>
|
||||
@ -16,6 +19,8 @@
|
||||
|
||||
<script src="options.js"></script>
|
||||
|
||||
<div id="saved"><br></div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@ -17,27 +17,40 @@
|
||||
|
||||
*/
|
||||
function saveOptions(e) {
|
||||
e.preventDefault();
|
||||
e.preventDefault()
|
||||
browser.storage.sync.set({
|
||||
keyboardprivacywhitelist: document.querySelector("#whitelist").value
|
||||
});
|
||||
})
|
||||
browser.storage.sync.set({
|
||||
keyboardprivacylan: document.querySelector("#whitelistLAN").checked
|
||||
})
|
||||
document.getElementById('saved').innerHTML = '<br><b>Saved</b>'
|
||||
setTimeout(function(){
|
||||
document.getElementById('saved').innerHTML = '<br>'
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
function restoreOptions() {
|
||||
|
||||
function setCurrentChoice(result) {
|
||||
function setCurrentWhitelist(result) {
|
||||
if (result['keyboardprivacywhitelist']){
|
||||
document.querySelector("#whitelist").value = result['keyboardprivacywhitelist']
|
||||
}
|
||||
|
||||
}
|
||||
function setCurrentLAN(result){
|
||||
document.querySelector("#whitelistLAN").checked = result['keyboardprivacylan']
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
let getting = browser.storage.sync.get("keyboardprivacywhitelist");
|
||||
getting.then(setCurrentChoice, onError);
|
||||
getting.then(setCurrentWhitelist, onError);
|
||||
|
||||
let gettingLAN = browser.storage.sync.get("keyboardprivacylan");
|
||||
gettingLAN.then(setCurrentLAN, onError);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", restoreOptions);
|
||||
|
Loading…
Reference in New Issue
Block a user