Skip to content

Commit

Permalink
Support more Google layouts (could not render when the three dots wer…
Browse files Browse the repository at this point in the history
…e not present) (#38)
  • Loading branch information
philipp-classen authored Nov 12, 2021
1 parent 3d415cd commit 7afb21e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions extension-manifest-v3/src/content_scripts/wtm-report/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,20 @@ function renderWheel(anchor, stats) {
const parent = anchor.parentElement;
parent.style.position = 'relative';
const threeDotsElement = parent.querySelector('div[jsslot] div[aria-haspopup], div[jsaction] div[role=button] span');

const container = document.createElement('div');
container.classList.add('wtm-tracker-wheel-container');
if (isMobile) {
container.style.left = threeDotsElement.getBoundingClientRect().left - parent.getBoundingClientRect().left - 50 + 'px';
container.style.top = 15 + 'px';
} else {
} else if (threeDotsElement) {
// default path on Safari (Desktop)
container.style.left = threeDotsElement.getBoundingClientRect().right - parent.getBoundingClientRect().left + 5 + 'px';
} else {
// default path in Chrome
const arrowDown = parent.querySelector('span.gTl8xb');
const elem = arrowDown || parent.querySelector('cite > span');
const offset = arrowDown ? 10 : 5;
container.style.left = elem.getBoundingClientRect().right - parent.getBoundingClientRect().left + offset + 'px';
}

container.addEventListener('click', (ev) => {
Expand Down

0 comments on commit 7afb21e

Please sign in to comment.