New-password Ruleset

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

 import { dom, element, out, rule, ruleset, score, type } from "fathom-web";
 import { euclidean } from "fathom-web/clusters";
 import {
   identity,
   isVisible,
   min,
   setDefault,
 } from "fathom-web/utilsForFrontend";

 // Whether this is running in the Vectorizer, rather than in-application, in a
 // privileged Chrome context
 const DEVELOPMENT = true;

 // Run me with confidence cutoff = 0.75.
 const coefficients = {
   new: [
     ["hasNewLabel", 2.5705015659332275],
     ["hasConfirmLabel", 1.968616247177124],
     ["hasCurrentLabel", -2.0171477794647217],
     ["closestLabelMatchesNew", 2.5639004707336426],
     ["closestLabelMatchesConfirm", 2.0995113849639893],
     ["closestLabelMatchesCurrent", -2.6844682693481445],
     ["hasNewAriaLabel", 2.6036999225616455],
     ["hasConfirmAriaLabel", 1.6274890899658203],
     ["hasCurrentAriaLabel", -0.5365085005760193],
     ["hasNewPlaceholder", 1.2246830463409424],
     ["hasConfirmPlaceholder", 1.7248882055282593],
     ["hasCurrentPlaceholder", -2.9133150577545166],
     ["forgotPasswordInFormLinkTextContent", -0.5529725551605225],
     ["forgotPasswordInFormLinkHref", -1.314806342124939],
     ["forgotPasswordInFormLinkTitle", -2.088702917098999],
     ["forgotInFormLinkTextContent", -0.9314834475517273],
     ["forgotInFormLinkHref", 0.2886754274368286],
     ["forgotPasswordInFormButtonTextContent", -1.3742481470108032],
     ["forgotPasswordOnPageLinkTextContent", -0.8459364175796509],
     ["forgotPasswordOnPageLinkHref", 0.11753738671541214],
     ["forgotPasswordOnPageLinkTitle", -0.6204848289489746],
     ["forgotPasswordOnPageButtonTextContent", -0.7494243383407593],
     ["elementAttrsMatchNew", 2.5985605716705322],
     ["elementAttrsMatchConfirm", 1.632151484489441],
     ["elementAttrsMatchCurrent", -3.041818857192993],
     ["elementAttrsMatchPassword1", 1.6156086921691895],
     ["elementAttrsMatchPassword2", 1.3372191190719604],
     ["elementAttrsMatchLogin", 1.423768401145935],
     ["formAttrsMatchRegister", 1.827048420906067],
     ["formHasRegisterAction", 1.8044408559799194],
     ["formButtonIsRegister", 3.0288844108581543],
     ["formAttrsMatchLogin", -0.7580564022064209],
     ["formHasLoginAction", -0.47973933815956116],
     ["formButtonIsLogin", -2.0724077224731445],
     ["hasAutocompleteCurrentPassword", -0.06478194147348404],
     ["formHasRememberMeCheckbox", 0.7470659613609314],
     ["formHasRememberMeLabel", 0.05482526868581772],
     ["formHasNewsletterCheckbox", 1.4263468980789185],
     ["formHasNewsletterLabel", 1.7910864353179932],
     ["closestHeaderAboveIsLoginy", -1.9214844703674316],
     ["closestHeaderAboveIsRegistery", 1.7715871334075928],
     ["nextInputIsConfirmy", 2.340878486633301],
     ["formHasMultipleVisibleInput", 2.9857382774353027],
   ],
 };

 const biases = [["new", -0.9879590272903442]];

 const passwordStringRegex = /password|passwort|رمز عبور|mot de passe|パスワード|비밀번호|암호|wachtwoord|senha|Пароль|parol|密码|contraseña|heslo|كلمة السر|kodeord|Κωδικός|pass code|Kata sandi|hasło|รหัสผ่าน|Şifre/i;
 const passwordAttrRegex = /pw|pwd|passwd|pass/i;
 const newStringRegex = /new|erstellen|create|choose|設定|신규|Créer/i;
 const newAttrRegex = /new/i;
 const confirmStringRegex = /wiederholen|wiederholung|confirm|repeat|confirmation|verify|retype|repite|確認|の確認|تکرار|re-enter|확인|bevestigen|confirme|Повторите|tassyklamak|再次输入|ještě jednou|gentag|re-type|confirmar|Répéter|conferma|Repetaţi|again|reenter/i;
 const confirmAttrRegex = /confirm|retype/i;
 const currentAttrAndStringRegex = /current|old/i;
 const forgotStringRegex = /vergessen|vergeten|forgot|oublié|dimenticata|Esqueceu|esqueci|Забыли|忘记|找回|Zapomenuté|lost|忘れた|忘れられた|忘れの方|재설정|찾기|help|فراموشی| را فراموش کرده اید|Восстановить|Unuttu|perdus|重新設定|reset|recover|change|remind|find|request|restore|trouble/i;
 const forgotHrefRegex = /forgot|reset|recover|change|lost|remind|find|request|restore/i;
 const password1Regex = /pw1|pwd1|pass1|passwd1|password1|pwone|pwdone|passone|passwdone|passwordone|pwfirst|pwdfirst|passfirst|passwdfirst|passwordfirst/i;
 const password2Regex = /pw2|pwd2|pass2|passwd2|password2|pwtwo|pwdtwo|passtwo|passwdtwo|passwordtwo|pwsecond|pwdsecond|passsecond|passwdsecond|passwordsecond/i;
 const loginRegex = /login|log in|log on|log-on|Войти|sign in|sigin|sign\/in|sign-in|sign on|sign-on|ورود|登录|Přihlásit se|Přihlaste|Авторизоваться|Авторизация|entrar|ログイン|로그인|inloggen|Συνδέσου|accedi|ログオン|Giriş Yap|登入|connecter|connectez-vous|Connexion|Вход/i;
 const loginFormAttrRegex = /login|log in|log on|log-on|sign in|sigin|sign\/in|sign-in|sign on|sign-on/i;
 const registerStringRegex = /create[a-zA-Z\s]+account|activate[a-zA-Z\s]+account|Zugang anlegen|Angaben prüfen|Konto erstellen|register|sign up|ثبت نام|登録|注册|cadastr|Зарегистрироваться|Регистрация|Bellige alynmak|تسجيل|ΕΓΓΡΑΦΗΣ|Εγγραφή|Créer mon compte|Créer un compte|Mendaftar|가입하기|inschrijving|Zarejestruj się|Deschideți un cont|Создать аккаунт|ร่วม|Üye Ol|registr|new account|ساخت حساب کاربری|Schrijf je|S'inscrire/i;
 const registerActionRegex = /register|signup|sign-up|create-account|account\/create|join|new_account|user\/create|sign\/up|membership\/create/i;
 const registerFormAttrRegex = /signup|join|register|regform|registration|new_user|AccountCreate|create_customer|CreateAccount|CreateAcct|create-account|reg-form|newuser|new-reg|new-form|new_membership/i;
 const rememberMeAttrRegex = /remember|auto_login|auto-login|save_mail|save-mail|ricordami|manter|mantenha|savelogin|auto login/i;
 const rememberMeStringRegex = /remember me|keep me logged in|keep me signed in|save email address|save id|stay signed in|ricordami|次回からログオンIDの入力を省略する|メールアドレスを保存する|を保存|아이디저장|아이디 저장|로그인 상태 유지|lembrar|manter conectado|mantenha-me conectado|Запомни меня|запомнить меня|Запомните меня|Не спрашивать в следующий раз|下次自动登录|记住我/i;
 const newsletterStringRegex = /newsletter|ニュースレター/i;
 const passwordStringAndAttrRegex = new RegExp(
   passwordStringRegex.source + "|" + passwordAttrRegex.source,
   "i"
 );

 function makeRuleset(coeffs, biases) {
   // HTMLElement => (selector => Array<HTMLElement>) nested map to cache querySelectorAll calls.
   let elementToSelectors;
   // We want to clear the cache each time the model is executed to get the latest DOM snapshot
   // for each classification.
   function clearCache() {
     // WeakMaps do not have a clear method
     elementToSelectors = new WeakMap();
   }

   function hasLabelMatchingRegex(element, regex) {
     // Check element.labels
     const labels = element.labels;
     // TODO: Should I be concerned with multiple labels?
     if (labels !== null && labels.length) {
       return regex.test(labels[0].textContent);
     }

     // Check element.aria-labelledby
     let labelledBy = element.getAttribute("aria-labelledby");
     if (labelledBy !== null) {
       labelledBy = labelledBy
         .split(" ")
         .map(id => element.getRootNode().getElementById(id))
         .filter(el => el);
       if (labelledBy.length === 1) {
         return regex.test(labelledBy[0].textContent);
       } else if (labelledBy.length > 1) {
         return regex.test(
           min(labelledBy, node => euclidean(node, element)).textContent
         );
       }
     }

     const parentElement = element.parentElement;
     // Bug 1634819: element.parentElement is null if element.parentNode is a ShadowRoot
     if (!parentElement) {
       return false;
     }
     // Check if the input is in a <td>, and, if so, check the textContent of the containing <tr>
     if (parentElement.tagName === "TD" && parentElement.parentElement) {
       // TODO: How bad is the assumption that the <tr> won't be the parent of the <td>?
       return regex.test(parentElement.parentElement.textContent);
     }

     // Check if the input is in a <dd>, and, if so, check the textContent of the preceding <dt>
     if (
       parentElement.tagName === "DD" &&
       // previousElementSibling can be null
       parentElement.previousElementSibling
     ) {
       return regex.test(parentElement.previousElementSibling.textContent);
     }
     return false;
   }

   function closestLabelMatchesRegex(element, regex) {
     const previousElementSibling = element.previousElementSibling;
     if (
       previousElementSibling !== null &&
       previousElementSibling.tagName === "LABEL"
     ) {
       return regex.test(previousElementSibling.textContent);
     }

     const nextElementSibling = element.nextElementSibling;
     if (nextElementSibling !== null && nextElementSibling.tagName === "LABEL") {
       return regex.test(nextElementSibling.textContent);
     }

     const closestLabelWithinForm = closestSelectorElementWithinElement(
       element,
       element.form,
       "label"
     );
     return containsRegex(
       regex,
       closestLabelWithinForm,
       closestLabelWithinForm => closestLabelWithinForm.textContent
     );
   }

   function containsRegex(regex, thingOrNull, thingToString = identity) {
     return thingOrNull !== null && regex.test(thingToString(thingOrNull));
   }

   function closestSelectorElementWithinElement(
     toElement,
     withinElement,
     querySelector
   ) {
     if (withinElement !== null) {
       let nodeList = Array.from(withinElement.querySelectorAll(querySelector));
       if (nodeList.length) {
         return min(nodeList, node => euclidean(node, toElement));
       }
     }
     return null;
   }

   function hasAriaLabelMatchingRegex(element, regex) {
     return containsRegex(regex, element.getAttribute("aria-label"));
   }

   function hasPlaceholderMatchingRegex(element, regex) {
     return containsRegex(regex, element.getAttribute("placeholder"));
   }

   function testRegexesAgainstAnchorPropertyWithinElement(
     property,
     element,
     ...regexes
   ) {
     return hasSomeMatchingPredicateForSelectorWithinElement(
       element,
       "a",
       anchor => {
         const propertyValue = anchor[property];
         return regexes.every(regex => regex.test(propertyValue));
       }
     );
   }

   function testFormButtonsAgainst(element, stringRegex) {
     const form = element.form;
     if (form !== null) {
       let inputs = Array.from(
         form.querySelectorAll("input[type=submit],input[type=button]")
       );
       inputs = inputs.filter(input => {
         return stringRegex.test(input.value);
       });
       if (inputs.length) {
         return true;
       }

       return hasSomeMatchingPredicateForSelectorWithinElement(
         form,
         "button",
         button => {
           return (
             stringRegex.test(button.value) ||
             stringRegex.test(button.textContent) ||
             stringRegex.test(button.id) ||
             stringRegex.test(button.title)
           );
         }
       );
     }
     return false;
   }

   function hasAutocompleteCurrentPassword(fnode) {
     return fnode.element.autocomplete === "current-password";
   }

   // Check cache before calling querySelectorAll on element
   function getElementDescendants(element, selector) {
     // Use the element to look up the selector map:
     const selectorToDescendants = setDefault(
       elementToSelectors,
       element,
       () => new Map()
     );

     // Use the selector to grab the descendants:
     return setDefault(
       selectorToDescendants, // eslint-disable-line prettier/prettier
       selector,
       () => Array.from(element.querySelectorAll(selector))
     );
   }

   /**
    * Return whether the form element directly after this one looks like a
    * confirm-password input.
    */
   function nextInputIsConfirmy(fnode) {
     const form = fnode.element.form;
     const me = fnode.element;
     if (form !== null) {
       let afterMe = false;
       for (const formEl of form.elements) {
         if (formEl === me) {
           afterMe = true;
         } else if (afterMe) {
           if (
             formEl.type === "password" &&
             !formEl.disabled &&
             formEl.getAttribute("aria-hidden") !== "true"
           ) {
             // Now we're looking at a passwordy, visible input[type=password]
             // directly after me.
             return elementAttrsMatchRegex(formEl, confirmAttrRegex);
             // We could check other confirmy smells as well. Balance accuracy
             // against time and complexity.
           }
           // We look only at the very next element, so we may be thrown off by
           // Hide buttons and such.
           break;
         }
       }
     }
     return false;
   }

   /**
    * Returns true when the number of visible input found in the form is over
    * the given threshold.
    *
    * Since the idea in the signal is based on the fact that registration pages
    * often have multiple inputs, this rule only selects inputs whose type is
    * either email, password, text, tel or empty, which are more likely a input
    * field for users to fill their information.
    */
   function formHasMultipleVisibleInput(element, selector, threshold) {
     let form = element.form;
     if (!form) {
       // For password fields don't have an associated form, we apply an heuristic
       // to find a "form" for it. The heuristic works as follow:
       // 1. Locate the closest preceding input.
       // 2. Find the lowest common ancestor of the password field and the closet
       //    preceding input.
       // 3. Assume the common ancestor is the "form" of the password input.
       const previous = closestElementAbove(element, selector);
       if (!previous) {
         return false;
       }
       form = findLowestCommonAncestor(previous, element);
       if (!form) {
         return false;
       }
     }
     const inputs = Array.from(form.querySelectorAll(selector));
     for (const input of inputs) {
       // don't need to check visibility for the element we're testing against
       if (element === input || isVisible(input)) {
         threshold--;
         if (threshold === 0) {
           return true;
         }
       }
     }
     return false;
   }

   function hasSomeMatchingPredicateForSelectorWithinElement(
     element,
     selector,
     matchingPredicate
   ) {
     if (element === null) {
       return false;
     }
     const elements = getElementDescendants(element, selector);
     return elements.some(matchingPredicate);
   }

   function textContentMatchesRegexes(element, ...regexes) {
     const textContent = element.textContent;
     return regexes.every(regex => regex.test(textContent));
   }

   function closestHeaderAboveMatchesRegex(element, regex) {
     const closestHeader = closestElementAbove(
       element,
       "h1,h2,h3,h4,h5,h6,div[class*=heading],div[class*=header],div[class*=title],legend"
     );
     if (closestHeader !== null) {
       return regex.test(closestHeader.textContent);
     }
     return false;
   }

   function closestElementAbove(element, selector) {
     let elements = Array.from(element.ownerDocument.querySelectorAll(selector));
     for (let i = elements.length - 1; i >= 0; --i) {
       if (
         element.compareDocumentPosition(elements[i]) &
         Node.DOCUMENT_POSITION_PRECEDING
       ) {
         return elements[i];
       }
     }
     return null;
   }

   function findLowestCommonAncestor(elementA, elementB) {
     // Walk down the ancestor chain of both elements and compare whether the
     // ancestors in the depth are the same. If they are not the same, the
     // ancestor in the previous run is the lowest common ancestor.
     function getAncestorChain(element) {
       let ancestors = [];
       let p = element.parentNode;
       while (p) {
         ancestors.push(p);
         p = p.parentNode;
       }
       return ancestors;
     }

     let aAncestors = getAncestorChain(elementA);
     let bAncestors = getAncestorChain(elementB);
     let posA = aAncestors.length - 1;
     let posB = bAncestors.length - 1;
     for (; posA >= 0 && posB >= 0; posA--, posB--) {
       if (aAncestors[posA] != bAncestors[posB]) {
         return aAncestors[posA + 1];
       }
     }
     return null;
   }

   function elementAttrsMatchRegex(element, regex) {
     if (element !== null) {
       return (
         regex.test(element.id) ||
         regex.test(element.name) ||
         regex.test(element.className)
       );
     }
     return false;
   }

   /**
    * Let us compactly represent a collection of rules that all take a single
    * type with no .when() clause and have only a score() call on the right-hand
    * side.
    */
   function* simpleScoringRulesTakingType(inType, ruleMap) {
     for (const [name, scoringCallback] of Object.entries(ruleMap)) {
       yield rule(type(inType), score(scoringCallback), { name });
     }
   }

   return ruleset(
     [
       rule(
         DEVELOPMENT
           ? dom(
               "input[type=password]:not([disabled]):not([aria-hidden=true]"
             ).when(isVisible)
           : element("input"),
         type("new").note(clearCache)
       ),
       ...simpleScoringRulesTakingType("new", {
         hasNewLabel: fnode =>
           hasLabelMatchingRegex(fnode.element, newStringRegex),
         hasConfirmLabel: fnode =>
           hasLabelMatchingRegex(fnode.element, confirmStringRegex),
         hasCurrentLabel: fnode =>
           hasLabelMatchingRegex(fnode.element, currentAttrAndStringRegex),
         closestLabelMatchesNew: fnode =>
           closestLabelMatchesRegex(fnode.element, newStringRegex),
         closestLabelMatchesConfirm: fnode =>
           closestLabelMatchesRegex(fnode.element, confirmStringRegex),
         closestLabelMatchesCurrent: fnode =>
           closestLabelMatchesRegex(fnode.element, currentAttrAndStringRegex),
         hasNewAriaLabel: fnode =>
           hasAriaLabelMatchingRegex(fnode.element, newStringRegex),
         hasConfirmAriaLabel: fnode =>
           hasAriaLabelMatchingRegex(fnode.element, confirmStringRegex),
         hasCurrentAriaLabel: fnode =>
           hasAriaLabelMatchingRegex(fnode.element, currentAttrAndStringRegex),
         hasNewPlaceholder: fnode =>
           hasPlaceholderMatchingRegex(fnode.element, newStringRegex),
         hasConfirmPlaceholder: fnode =>
           hasPlaceholderMatchingRegex(fnode.element, confirmStringRegex),
         hasCurrentPlaceholder: fnode =>
           hasPlaceholderMatchingRegex(fnode.element, currentAttrAndStringRegex),
         forgotPasswordInFormLinkTextContent: fnode =>
           testRegexesAgainstAnchorPropertyWithinElement(
             "textContent",
             fnode.element.form,
             passwordStringRegex,
             forgotStringRegex
           ),
         forgotPasswordInFormLinkHref: fnode =>
           testRegexesAgainstAnchorPropertyWithinElement(
             "href",
             fnode.element.form,
             passwordStringAndAttrRegex,
             forgotHrefRegex
           ),
         forgotPasswordInFormLinkTitle: fnode =>
           testRegexesAgainstAnchorPropertyWithinElement(
             "title",
             fnode.element.form,
             passwordStringRegex,
             forgotStringRegex
           ),
         forgotInFormLinkTextContent: fnode =>
           testRegexesAgainstAnchorPropertyWithinElement(
             "textContent",
             fnode.element.form,
             forgotStringRegex
           ),
         forgotInFormLinkHref: fnode =>
           testRegexesAgainstAnchorPropertyWithinElement(
             "href",
             fnode.element.form,
             forgotHrefRegex
           ),
         forgotPasswordInFormButtonTextContent: fnode =>
           hasSomeMatchingPredicateForSelectorWithinElement(
             fnode.element.form,
             "button",
             button =>
               textContentMatchesRegexes(
                 button,
                 passwordStringRegex,
                 forgotStringRegex
               )
           ),
         forgotPasswordOnPageLinkTextContent: fnode =>
           testRegexesAgainstAnchorPropertyWithinElement(
             "textContent",
             fnode.element.ownerDocument,
             passwordStringRegex,
             forgotStringRegex
           ),
         forgotPasswordOnPageLinkHref: fnode =>
           testRegexesAgainstAnchorPropertyWithinElement(
             "href",
             fnode.element.ownerDocument,
             passwordStringAndAttrRegex,
             forgotHrefRegex
           ),
         forgotPasswordOnPageLinkTitle: fnode =>
           testRegexesAgainstAnchorPropertyWithinElement(
             "title",
             fnode.element.ownerDocument,
             passwordStringRegex,
             forgotStringRegex
           ),
         forgotPasswordOnPageButtonTextContent: fnode =>
           hasSomeMatchingPredicateForSelectorWithinElement(
             fnode.element.ownerDocument,
             "button",
             button =>
               textContentMatchesRegexes(
                 button,
                 passwordStringRegex,
                 forgotStringRegex
               )
           ),
         elementAttrsMatchNew: fnode =>
           elementAttrsMatchRegex(fnode.element, newAttrRegex),
         elementAttrsMatchConfirm: fnode =>
           elementAttrsMatchRegex(fnode.element, confirmAttrRegex),
         elementAttrsMatchCurrent: fnode =>
           elementAttrsMatchRegex(fnode.element, currentAttrAndStringRegex),
         elementAttrsMatchPassword1: fnode =>
           elementAttrsMatchRegex(fnode.element, password1Regex),
         elementAttrsMatchPassword2: fnode =>
           elementAttrsMatchRegex(fnode.element, password2Regex),
         elementAttrsMatchLogin: fnode =>
           elementAttrsMatchRegex(fnode.element, loginRegex),
         formAttrsMatchRegister: fnode =>
           elementAttrsMatchRegex(fnode.element.form, registerFormAttrRegex),
         formHasRegisterAction: fnode =>
           containsRegex(
             registerActionRegex,
             fnode.element.form,
             form => form.action
           ),
         formButtonIsRegister: fnode =>
           testFormButtonsAgainst(fnode.element, registerStringRegex),
         formAttrsMatchLogin: fnode =>
           elementAttrsMatchRegex(fnode.element.form, loginFormAttrRegex),
         formHasLoginAction: fnode =>
           containsRegex(loginRegex, fnode.element.form, form => form.action),
         formButtonIsLogin: fnode =>
           testFormButtonsAgainst(fnode.element, loginRegex),
         hasAutocompleteCurrentPassword,
         formHasRememberMeCheckbox: fnode =>
           hasSomeMatchingPredicateForSelectorWithinElement(
             fnode.element.form,
             "input[type=checkbox]",
             checkbox =>
               rememberMeAttrRegex.test(checkbox.id) ||
               rememberMeAttrRegex.test(checkbox.name)
           ),
         formHasRememberMeLabel: fnode =>
           hasSomeMatchingPredicateForSelectorWithinElement(
             fnode.element.form,
             "label",
             label => rememberMeStringRegex.test(label.textContent)
           ),
         formHasNewsletterCheckbox: fnode =>
           hasSomeMatchingPredicateForSelectorWithinElement(
             fnode.element.form,
             "input[type=checkbox]",
             checkbox =>
               checkbox.id.includes("newsletter") ||
               checkbox.name.includes("newsletter")
           ),
         formHasNewsletterLabel: fnode =>
           hasSomeMatchingPredicateForSelectorWithinElement(
             fnode.element.form,
             "label",
             label => newsletterStringRegex.test(label.textContent)
           ),
         closestHeaderAboveIsLoginy: fnode =>
           closestHeaderAboveMatchesRegex(fnode.element, loginRegex),
         closestHeaderAboveIsRegistery: fnode =>
           closestHeaderAboveMatchesRegex(fnode.element, registerStringRegex),
         nextInputIsConfirmy,
         formHasMultipleVisibleInput: fnode =>
           formHasMultipleVisibleInput(
             fnode.element,
             "input[type=email],input[type=password],input[type=text],input[type=tel]",
             3
           ),
       }),
       rule(type("new"), out("new")),
     ],
     coeffs,
     biases
   );
 }

 const trainees = new Map();
 const VIEWPORT_SIZE = {
   width: 1366,
   height: 768,
 };

 const FEATURES = ["new"];
 for (const feature of FEATURES) {
   const trainee = {
     coeffs: new Map(coefficients[feature]),
     viewportSize: VIEWPORT_SIZE,
     vectorType: feature,
     rulesetMaker: () => makeRuleset([...coefficients.new], biases),
     isTarget: fnode =>
       fnode.element.dataset.fathom === "new" ||
       fnode.element.dataset.fathom === "confirm",
   };
   trainees.set(feature, trainee);
 }

 export default trainees;