Skip to content

Commit

Permalink
Better rules for finding input boxes
Browse files Browse the repository at this point in the history
Google maps doesn't use a [type=text], or any kind of type attribute for
its search box. Plus it also has a [aria-hidden=true] input box that
Browsh was detecting and covering the actual active search box.
  • Loading branch information
tombh committed Jun 5, 2018
1 parent 8d958b0 commit 707a433
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions webext/src/dom/text_builder.js
Expand Up @@ -364,10 +364,7 @@ export default class extends utils.mixins(CommonMixin) {
let dom_rect, styles, font_rgb;
let parsed_input_boxes = {};
let raw_input_boxes = document.querySelectorAll(
'input[type="text"], ' +
'input[type="email"], ' +
'input[type="password"], ' +
'input[type="tel"], ' +
'input, ' +
'textarea, ' +
'[role="textbox"]'
);
Expand All @@ -385,6 +382,7 @@ export default class extends utils.mixins(CommonMixin) {
}
styles = window.getComputedStyle(i);
font_rgb = styles['color'].replace(/[^\d,]/g, '').split(',').map((i) => parseInt(i));
if (this._isUnwantedInboxBox(i, styles)) { return }
parsed_input_boxes[i.getAttribute('data-browsh-id')] = {
id: i.getAttribute('data-browsh-id'),
x: utils.snap(dom_rect.left * this.dimensions.scale_factor.width),
Expand All @@ -405,6 +403,12 @@ export default class extends utils.mixins(CommonMixin) {
}
}

_isUnwantedInboxBox(input_box, styles) {
if (styles.display === 'none' || styles.visibility === 'hidden') { return true }
if (input_box.getAttribute('aria-hidden') == 'true') { return true }
return false;
}

_sendRawText() {
let payload = {
body: this._serialiseRawText()
Expand Down

0 comments on commit 707a433

Please sign in to comment.