From fbb6e804cfc5648fbd08d854a7b272960ab65c7c Mon Sep 17 00:00:00 2001 From: Kevin F Date: Tue, 10 Aug 2021 05:02:49 +0000 Subject: [PATCH] fixed www check in whitelist, randomize each keystroke instead of per load --- background.js | 20 ++++++++------------ manifest.json | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/background.js b/background.js index 3080c80..94f6bd7 100644 --- a/background.js +++ b/background.js @@ -19,7 +19,8 @@ const defaultHosts = ""; let appCode = function (){ - const maxValue = 100 + const maxValue = 150 + const minValue = 25 let mainKeyboardPrivacy = function(){ @@ -28,20 +29,15 @@ let appCode = function (){ while (true){ window.crypto.getRandomValues(buf); - if (buf[0] <= maxValue){ - break + if (buf[0] <= maxValue && buf[0] >= minValue){ + break; } buf = new Uint8Array(1); } return buf[0]; } - - let dwellTime = getRandNum() - let gapTime = getRandNum() console.debug('Protecting keyboard biometrics on ' + document.location.href) - console.debug("dwell time " + dwellTime) - console.debug("gap time " + gapTime) function pausecomp(millis) { @@ -60,7 +56,7 @@ let appCode = function (){ if (e.key.startsWith('Arrow') || e.key.startsWith('Page')){ return true; } - pausecomp(dwellTime); + pausecomp(getRandNum()); return true; }, ) @@ -68,7 +64,7 @@ let appCode = function (){ if (e.key.startsWith('Arrow') || e.key.startsWith('Page')){ return true; } - pausecomp(gapTime); + pausecomp(getRandNum()); return true; }) @@ -76,13 +72,13 @@ let appCode = function (){ }, 100) } function shouldRunKeyboardPrivacy(value){ - if (typeof value.keyboardprivacywhitelist !== undefined){ + if (typeof value.keyboardprivacywhitelist == undefined){ mainKeyboardPrivacy() return } let vals = value.keyboardprivacywhitelist.split(',') for (i = 0; i < vals.length; i++){ - if (vals[i] === document.location.hostname || vals[i] === 'www.' + document.location.hostname){ + if (vals[i] === document.location.hostname || 'www.' + vals[i] === document.location.hostname){ console.debug(document.location.hostname + ' whitelisted for no keyboard privacy') return } diff --git a/manifest.json b/manifest.json index a9147a3..846d6f0 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Private Keyboard", - "version": "1.3", + "version": "1.4", "description": "Protect against keyboard biometrics",