diff --git a/README.md b/README.md index f1730a8..43103c2 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ There are spy libraries that can determine how long keys are held down and the t This addon was created to skew the key press timing by limiting the speed of presses. The speed is changed randomly on each page load, with a min of 150ms and a max of 300ms. -It uses a less than ideal thread locking solution, as simply buffering text does not stop event listeners from spies. +It uses a less than ideal thread locking solution, as simply buffering text does not stop event listeners from spies. **Now it also has a non-default setting to use prompt() on non-password single line input elements. This reduces CPU usage and increase typing speed while offering better protection than the delay approach.** You can whitelist domains that you trust on the addon settings page, but it was decided not to support changing the key speed manually as that would add another fingerprinting avenue. diff --git a/background.js b/background.js index b737499..adeb678 100644 --- a/background.js +++ b/background.js @@ -19,6 +19,13 @@ const defaultHosts = ""; let appCode = function (){ + let popupEnabled = false + let popupGetter = browser.storage.sync.get("keyboardprivacyprompt") + popupGetter.then(function(val){ + popupEnabled = val['keyboardprivacyprompt'] + console.debug(popupEnabled) + }, function(){}) + let clearSelect = function() { if (window.getSelection) {window.getSelection().removeAllRanges()} @@ -45,13 +52,10 @@ let appCode = function (){ if (! inputType){ text = prompt("[PrivateKeyboard]\n\nEnter text for the text field:", e.target.value) } - else if (! ["text", "search", "email", "password", "number"].includes(inputType.toLowerCase())){ + else if (! ["text", "search", "email", "number"].includes(inputType.toLowerCase())){ return } else{ - if (inputType == "password"){ - inputType = "password (SHOWN IN PLAIN TEXT)" - } text = prompt("[PrivateKeyboard]\n\nEnter text for the " + inputType + " field:", e.target.value) } if (text !== null) { @@ -66,8 +70,9 @@ let appCode = function (){ let popupMode = function(){ - - document.addEventListener('focusin', doPopup, true) + if (popupEnabled){ + document.addEventListener('focusin', doPopup, true) + } } @@ -124,11 +129,12 @@ let appCode = function (){ return true; } else{ - console.debug(e.key) } - setTimeout( - function(){doPopup(e)}, 10) + if (popupEnabled){ + setTimeout( + function(){doPopup(e)}, 10) + } pausecomp(down); return true; diff --git a/settings/options.html b/settings/options.html index b5efcbe..e4b6e4e 100644 --- a/settings/options.html +++ b/settings/options.html @@ -10,7 +10,7 @@
- +
diff --git a/settings/options.js b/settings/options.js index 8f57b4f..175ef0b 100644 --- a/settings/options.js +++ b/settings/options.js @@ -24,6 +24,9 @@ function saveOptions(e) { browser.storage.sync.set({ keyboardprivacylan: document.querySelector("#whitelistLAN").checked }) + browser.storage.sync.set({ + keyboardprivacyprompt: document.querySelector("#usePrompt").checked + }) document.getElementById('saved').innerHTML = '
Saved' setTimeout(function(){ document.getElementById('saved').innerHTML = '
' @@ -42,6 +45,10 @@ function saveOptions(e) { document.querySelector("#whitelistLAN").checked = result['keyboardprivacylan'] } + function setCurrentPrompt(result){ + document.querySelector("#usePrompt").checked = result['keyboardprivacyprompt'] + } + function onError(error) { console.log(`Error: ${error}`); } @@ -51,6 +58,9 @@ function saveOptions(e) { let gettingLAN = browser.storage.sync.get("keyboardprivacylan"); gettingLAN.then(setCurrentLAN, onError); + + let gettingPrompt = browser.storage.sync.get("keyboardprivacyprompt"); + gettingPrompt.then(setCurrentPrompt, onError); } document.addEventListener("DOMContentLoaded", restoreOptions);