Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
Brave selectors fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
kartkand committed Jul 4, 2022
1 parent 3a2fdc8 commit 0421622
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/content-scripts/serp-scripts/brave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ const serpScript = function () {
*/
function getSearchAreaTopHeight(): number {
try {
const element = document.querySelector(".navbar-row") as HTMLElement;
return getElementBottomHeight(element);
return getElementTopHeight(document.querySelector("#results"));
} catch (error) {
return null;
}
Expand All @@ -62,8 +61,8 @@ const serpScript = function () {
*/
function getSearchAreaBottomHeight(): number {
try {
const element = document.querySelector(".pagination").previousElementSibling as HTMLElement;
return getElementBottomHeight(element);
const resultsElements = document.querySelectorAll("#results > *:not(#pagination)");
return getElementBottomHeight(resultsElements[resultsElements.length - 1]);
} catch (error) {
return null;
}
Expand All @@ -85,7 +84,7 @@ const serpScript = function () {
*/
function getInternalLink(target: Element): string {
if (target.matches("#search-main *")) {
if (!target.matches(".footer *, #pagination #")) {
if (!(target.matches(".footer *, #pagination *"))) {
const hrefElement = target.closest("[href]");
if (hrefElement) {
const href = (hrefElement as any).href;
Expand Down

0 comments on commit 0421622

Please sign in to comment.