Skip to content

Commit

Permalink
Refactor searching
Browse files Browse the repository at this point in the history
  • Loading branch information
kewbish committed Jan 21, 2023
1 parent 65c2c9a commit c00b793
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/pages/Content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@ if (monetizationTag) {
let bodyText = null;
for (const patternString of Object.keys(websiteMap)) {
const hostName = patternString.split("/")[0];
if (hostName === reducedHostName) {
let pathname = undefined;
if (patternString.includes("/")) {
pathname = "/" + patternString.split("/").slice(1).join("/");
}
// @ts-expect-error
const pattern = new URLPattern({ pathname });
if (pattern.match(url)) {
bodyText = document.querySelectorAll(websiteMap[patternString])[0]
?.textContent;
break;
}
if (hostName !== reducedHostName) {
continue;
}
let pathname = undefined;
if (patternString.includes("/")) {
pathname = "/" + patternString.split("/").slice(1).join("/");
}
// @ts-expect-error
const pattern = new URLPattern({ pathname });
if (pattern.test(url)) {
bodyText = document.querySelectorAll(websiteMap[patternString])[0]
?.textContent;
break;
}
}
if (bodyText === null) {
Expand Down

0 comments on commit c00b793

Please sign in to comment.