Skip to content

Commit

Permalink
Merge pull request #2 from duckduckgo/develop
Browse files Browse the repository at this point in the history
Release 1.0.1
  • Loading branch information
GioSensation authored May 17, 2021
2 parents 350eb8b + b28bcdc commit 5a61a9e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# DuckDuckGo Autofill

This code is imported as a subrepo by our [extension](https://github.com/duckduckgo/duckduckgo-privacy-extension) and native apps ([iOS](https://github.com/duckduckgo/iOS) and [Android](https://github.com/duckduckgo/Android)).
This code is installed using `npm` in our [extension](https://github.com/duckduckgo/duckduckgo-privacy-extension) and as a git submodule by native apps ([iOS](https://github.com/duckduckgo/iOS) and [Android](https://github.com/duckduckgo/Android)).

DuckDuckGo Autofill is distributed under the Apache 2.0 [License](LICENSE.md).

## How to add this repo to another project
## How to develop and test within the context of the extensions

To simplify development workflows, you can use [`npm-link`](https://docs.npmjs.com/cli/v6/commands/npm-link). `npm-link` creates a symlink to the source repo and links it to local package usages. It's a two-step process.

1. In the source repo (this folder), run `npm link`. This must be done only once.
1. In the client repo (the extension folder), run `npm link @duckduckgo/autofill`. Do this every time you start working on the extension repo.

Now you can run `npm start` in this repo and the changes will be picked up automatically in the client 🎉.

## How to add this as a subrepo to another project
###### [See the docs](https://git-scm.com/book/en/v2/Git-Tools-Submodules#_starting_submodules)

To add this repo as a submodule, run:
Expand Down
16 changes: 11 additions & 5 deletions dist/autofill.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ var createAttachTooltip = function createAttachTooltip(getAutofillData, refreshA
window.addEventListener('mousedown', form.removeTooltip, {
capture: true
});
window.addEventListener('input', form.removeTooltip, {
once: true
});
}
};
};
Expand Down Expand Up @@ -790,8 +793,10 @@ var Form = /*#__PURE__*/function () {
if (e.button !== 0) return;

if (_this2.shouldOpenTooltip(e, e.target)) {
e.preventDefault();
e.stopImmediatePropagation();
if (isEventWithinDax(e, e.target)) {
e.preventDefault();
e.stopImmediatePropagation();
}

_this2.touched.add(e.target);

Expand Down Expand Up @@ -882,7 +887,7 @@ var FormAnalyzer = /*#__PURE__*/function () {
_ref$shouldBeConserva = _ref.shouldBeConservative,
shouldBeConservative = _ref$shouldBeConserva === void 0 ? false : _ref$shouldBeConserva;
var negativeRegex = new RegExp(/sign(ing)?.?in(?!g)|log.?in/i);
var positiveRegex = new RegExp(/sign(ing)?.?up|join|regist(er|ration)|newsletter|subscri(be|ption)|contact|create|start|settings|preferences|profile|update|checkout|guest|purchase|buy|order/i);
var positiveRegex = new RegExp(/sign(ing)?.?up|join|regist(er|ration)|newsletter|subscri(be|ption)|contact|create|start|settings|preferences|profile|update|checkout|guest|purchase|buy|order|schedule|estimate/i);
var conservativePositiveRegex = new RegExp(/sign.?up|join|register|newsletter|subscri(be|ption)|settings|preferences|profile|update/i);
var strictPositiveRegex = new RegExp(/sign.?up|join|register|settings|preferences|profile|update/i);
var matchesNegative = string.match(negativeRegex); // Check explicitly for unified login/signup forms. They should always be negative, so we increase signal
Expand Down Expand Up @@ -912,12 +917,13 @@ var FormAnalyzer = /*#__PURE__*/function () {
var signalStrength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
var isInput = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
Array.from(el.attributes).forEach(function (attr) {
var attributeString = "".concat(attr.nodeName, "=").concat(attr.nodeValue);
if (attr.name === 'style') return;
var attributeString = "".concat(attr.name, "=").concat(attr.value);

_this.updateSignal({
string: attributeString,
strength: signalStrength,
signalType: "".concat(el.nodeName, " attr: ").concat(attributeString),
signalType: "".concat(el.name, " attr: ").concat(attributeString),
shouldCheckUnifiedForm: isInput
});
});
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@duckduckgo/autofill",
"version": "1.0.0",
"version": "1.0.1",
"main": "dist/autofill.js",
"engines": {
"node": "^14",
Expand Down
1 change: 1 addition & 0 deletions src/DeviceInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const createAttachTooltip = (getAutofillData, refreshAlias, addresses) => (form,
form.tooltip = new DDGAutofill(input, form, getAutofillData, refreshAlias, addresses)
form.intObs.observe(input)
window.addEventListener('mousedown', form.removeTooltip, {capture: true})
window.addEventListener('input', form.removeTooltip, {once: true})
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ class Form {
if (e.button !== 0) return

if (this.shouldOpenTooltip(e, e.target)) {
e.preventDefault()
e.stopImmediatePropagation()
if (isEventWithinDax(e, e.target)) {
e.preventDefault()
e.stopImmediatePropagation()
}

this.touched.add(e.target)
this.attachTooltip(this, e.target)
Expand Down
8 changes: 5 additions & 3 deletions src/FormAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FormAnalyzer {
}) {
const negativeRegex = new RegExp(/sign(ing)?.?in(?!g)|log.?in/i)
const positiveRegex = new RegExp(
/sign(ing)?.?up|join|regist(er|ration)|newsletter|subscri(be|ption)|contact|create|start|settings|preferences|profile|update|checkout|guest|purchase|buy|order/i
/sign(ing)?.?up|join|regist(er|ration)|newsletter|subscri(be|ption)|contact|create|start|settings|preferences|profile|update|checkout|guest|purchase|buy|order|schedule|estimate/i
)
const conservativePositiveRegex = new RegExp(/sign.?up|join|register|newsletter|subscri(be|ption)|settings|preferences|profile|update/i)
const strictPositiveRegex = new RegExp(/sign.?up|join|register|settings|preferences|profile|update/i)
Expand All @@ -61,11 +61,13 @@ class FormAnalyzer {

evaluateElAttributes (el, signalStrength = 3, isInput = false) {
Array.from(el.attributes).forEach(attr => {
const attributeString = `${attr.nodeName}=${attr.nodeValue}`
if (attr.name === 'style') return

const attributeString = `${attr.name}=${attr.value}`
this.updateSignal({
string: attributeString,
strength: signalStrength,
signalType: `${el.nodeName} attr: ${attributeString}`,
signalType: `${el.name} attr: ${attributeString}`,
shouldCheckUnifiedForm: isInput
})
})
Expand Down

0 comments on commit 5a61a9e

Please sign in to comment.