Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get closest contiguous clickable element for hints to reduce duplicat… #1469

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions content_scripts/hints.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,9 @@ div.hint-scrollable {
} else {
if (cssSelector === "") {
elements = getVisibleElements(function(e, v) {
if (isElementClickable(e)) {
v.push(e);
var closestClickable = getFurthestContiguousClickable(e);
if (closestClickable) {
v.push(closestClickable);
}
});
elements = filterOverlapElements(elements);
Expand Down
9 changes: 9 additions & 0 deletions content_scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ function isElementClickable(e) {
|| e.closest("a, *[onclick], *[contenteditable=true], *.jfk-button, *.goog-flat-menu-button") !== null;
}

function getFurthestContiguousClickable(e) {
var clickable = isElementClickable(e);
var parent = e.parentElement;
if(clickable){
return getFurthestContiguousClickable(parent) || e;
}
return clickable;
}

function dispatchMouseEvent(element, events, shiftKey) {
events.forEach(function(eventName) {
var mouseButton = shiftKey ? 1 : 0;
Expand Down