Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Refactor stop words to lang file (#581)

Leendert de Borstb6c7e88000c2
diff --git a/browser-extension/src/entrypoints/contentScript/Filter.ts b/browser-extension/src/entrypoints/contentScript/Filter.ts
index f421485fe..c457f68e0 100644
--- a/browser-extension/src/entrypoints/contentScript/Filter.ts
+++ b/browser-extension/src/entrypoints/contentScript/Filter.ts
@@ -1,3 +1,4 @@
+import { CombinedStopWords } from "@/utils/formDetector/FieldPatterns";
import { Credential } from "../../utils/types/Credential";
/**
@@ -40,22 +41,11 @@ export function filterCredentials(credentials: Credential[], currentUrl: string,
// 3. Page title word match if still no matches
if (filtered.length === 0 && pageTitle.length > 0) {
- // TODO: make bad words list configurable per language.
- const badWords = new Set([
- 'login', 'signin', 'sign', 'register', 'signup', 'account',
- 'portal', 'dashboard', 'home', 'welcome', 'authentication',
- 'page', 'site', 'secure', 'password', 'access', 'member',
- 'user', 'profile', 'auth', 'session', 'inloggen',
- 'registreren', 'registratie', 'free', 'gratis', 'create',
- 'new', 'aanmelden', 'inschrijven', 'nieuwsbrief', 'schrijf',
- 'your', 'jouw'
- ]);
-
const titleWords = pageTitle.toLowerCase()
.split(/\s+/)
.filter(word =>
word.length > 3 && // Filter out words shorter than 4 characters
- !badWords.has(word.toLowerCase()) // Filter out generic words
+ !CombinedStopWords.has(word.toLowerCase()) // Filter out generic words
);
filtered = credentials.filter(cred =>
diff --git a/browser-extension/src/utils/formDetector/FieldPatterns.ts b/browser-extension/src/utils/formDetector/FieldPatterns.ts
index ee6a99289..2595e80a6 100644
--- a/browser-extension/src/utils/formDetector/FieldPatterns.ts
+++ b/browser-extension/src/utils/formDetector/FieldPatterns.ts
@@ -69,6 +69,42 @@ export const EnglishDateOptionPatterns: DateOptionPatterns = {
],
};
+/**
+ * English words to filter out from page titles during autofill matching to
+ * prevent generic words from causing false positives.
+ */
+export const EnglishStopWords = new Set([
+ // Authentication related
+ 'login', 'signin', 'sign', 'register', 'signup', 'account',
+ 'authentication', 'password', 'access', 'auth', 'session',
+ 'authenticate', 'credentials', 'logout', 'signout',
+
+ // Navigation/Site sections
+ 'portal', 'dashboard', 'home', 'welcome', 'page', 'site',
+ 'secure', 'member', 'user', 'profile', 'settings', 'menu',
+ 'overview', 'index', 'main', 'start', 'landing',
+
+ // Marketing/Promotional
+ 'free', 'create', 'new', 'your', 'special', 'offer',
+ 'deal', 'discount', 'promotion',
+
+ // Common website sections
+ 'help', 'support', 'contact', 'about', 'faq', 'terms',
+ 'privacy', 'cookie', 'service', 'services', 'products',
+ 'shop', 'store', 'cart', 'checkout',
+
+ // Generic descriptors
+ 'online', 'web', 'digital', 'mobile', 'my', 'personal',
+ 'private', 'general', 'default', 'standard',
+
+ // System/Technical
+ 'system', 'admin', 'administrator', 'platform', 'portal',
+ 'gateway', 'api', 'interface', 'console',
+
+ // Time-related
+ 'today', 'now', 'current', 'latest', 'newest', 'recent'
+]);
+
/**
* Dutch field patterns used to detect Dutch form fields.
*/
@@ -105,6 +141,42 @@ export const DutchDateOptionPatterns: DateOptionPatterns = {
],
};
+/**
+ * Dutch words to filter out from page titles during autofill matching to
+ * prevent generic words from causing false positives.
+ */
+export const DutchStopWords = new Set([
+ // Authentication related
+ 'inloggen', 'registreren', 'registratie', 'aanmelden',
+ 'inschrijven', 'uitloggen', 'wachtwoord', 'toegang',
+ 'authenticatie', 'account',
+
+ // Navigation/Site sections
+ 'portaal', 'overzicht', 'startpagina', 'welkom', 'pagina',
+ 'beveiligd', 'lid', 'gebruiker', 'profiel', 'instellingen',
+ 'menu', 'begin', 'hoofdpagina',
+
+ // Marketing/Promotional
+ 'gratis', 'nieuw', 'jouw', 'schrijf', 'nieuwsbrief',
+ 'aanbieding', 'korting', 'speciaal', 'actie',
+
+ // Common website sections
+ 'hulp', 'ondersteuning', 'contact', 'over', 'voorwaarden',
+ 'privacy', 'cookie', 'dienst', 'diensten', 'producten',
+ 'winkel', 'bestellen', 'winkelwagen',
+
+ // Generic descriptors
+ 'online', 'web', 'digitaal', 'mobiel', 'mijn', 'persoonlijk',
+ 'privé', 'algemeen', 'standaard',
+
+ // System/Technical
+ 'systeem', 'beheer', 'beheerder', 'platform', 'portaal',
+ 'interface', 'console',
+
+ // Time-related
+ 'vandaag', 'nu', 'huidig', 'recent', 'nieuwste'
+]);
+
/**
* Combined field patterns which includes all supported languages.
*/
@@ -148,4 +220,13 @@ export const CombinedDateOptionPatterns: DateOptionPatterns = {
...EnglishDateOptionPatterns.months,
...DutchDateOptionPatterns.months
],
-};
\ No newline at end of file
+};
+
+/**
+ * Combined stop words from all supported languages. These are used to filter out generic words from page titles
+ * during autofill matching to prevent generic words from causing false positives.
+ */
+export const CombinedStopWords = new Set([
+ ...EnglishStopWords,
+ ...DutchStopWords
+]);