diff --git a/background.js b/background.js index 518c42b..aac4d81 100644 --- a/background.js +++ b/background.js @@ -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() diff --git a/manifest.json b/manifest.json index 7a37d1c..c5586b8 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Private Keyboard", - "version": "1.6", + "version": "1.8", "description": "Protect against keyboard biometrics", diff --git a/settings/options.css b/settings/options.css new file mode 100644 index 0000000..35b5e58 --- /dev/null +++ b/settings/options.css @@ -0,0 +1,3 @@ +body{ + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; +} diff --git a/settings/options.html b/settings/options.html index 6142c64..41d76a1 100644 --- a/settings/options.html +++ b/settings/options.html @@ -3,12 +3,15 @@ + -

Trusted domains (comma delimited)

+ + +

Trusted domains (comma delimited)



@@ -16,6 +19,8 @@ +

+ diff --git a/settings/options.js b/settings/options.js index 61381dc..8f57b4f 100644 --- a/settings/options.js +++ b/settings/options.js @@ -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 = '
Saved' + setTimeout(function(){ + document.getElementById('saved').innerHTML = '
' + }, 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);