Skip to content

Commit fcd605c

Browse files
authored
chore: add readme for site-specific-feature (#799)
1 parent bd05a56 commit fcd605c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

docs/site-specific-feature.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## `src/site-specific-feature.js`
2+
3+
The [site-specific-feature.js](https://github.com/duckduckgo/duckduckgo-autofill/blob/main/src/site-specific-feature.js) module provides APIs to find elements on a document, based on settings specified in the `siteSpecificFixes` feature in [privacy-configuration](https://github.com/duckduckgo/privacy-configuration). These are used during scanning, input matching or form creation to apply site specific fixes, which is useful when the default algorithm fails to identify elements algorithmically. It extends the [ConfigFeature](https://github.com/duckduckgo/content-scope-scripts/blob/main/injected/src/config-feature.js) class from content-scope-scripts, which provides APIs to read remote config settings.
4+
5+
Currently, it supports following type of fixes:
6+
7+
### Input type
8+
Force an input element on the page to be a specific type.
9+
10+
- `inputTypeSettings`: This is an array of objects that contain the following properties:
11+
- `selector`: A string that matches the input type.
12+
- `type`: The type of input to apply - `login`, `signup`, or `hybrid`.
13+
14+
Example setting in remote config:
15+
```json
16+
{
17+
"inputTypeSettings": [
18+
{
19+
"selector": "input[type='email']",
20+
"type": "identities.emailAddress"
21+
}
22+
]
23+
}
24+
```
25+
26+
27+
### Form boundary
28+
Force the form boundary to be a specific element on the page.
29+
- `formBoundarySelector`: A string that matches the form on the page.
30+
31+
Example setting in remote config:
32+
```json
33+
{
34+
"formBoundarySelector": "form[name='login']"
35+
}
36+
```
37+
38+
### Form type
39+
Force a form on a page to be a specific type.
40+
- `selector`: A string that matches the form we want to fix.
41+
- `type`: The type of form to apply, this matches the [SupportedTypes](https://github.com/duckduckgo/duckduckgo-autofill/blob/main/src/Form/matching.js#L755) we have in the code.
42+
43+
Example setting in remote config:
44+
```json
45+
{
46+
"formTypeSettings": [
47+
{
48+
"selector": "form[name='login']",
49+
"type": "identities.emailAddress"
50+
}
51+
]
52+
}
53+
```

0 commit comments

Comments
 (0)