Skip to content

Commit

Permalink
fix(google,ios): support a DOM structure without a.ping
Browse files Browse the repository at this point in the history
  • Loading branch information
iorate committed Jan 7, 2023
1 parent b2fdd6e commit 3963e6c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/scripts/search-engines/google-mobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import { handleSerp, hasDarkBackground, insertElement } from './helpers';
function getURLFromPing(selector: string): (root: HTMLElement) => string | null {
return root => {
const a = selector ? root.querySelector(selector) : root;
if (!(a instanceof HTMLAnchorElement) || !a.ping) {
if (!(a instanceof HTMLAnchorElement)) {
return null;
}
try {
return new URL(a.ping, window.location.href).searchParams.get('url');
} catch {
return null;
if (a.ping) {
try {
return new URL(a.ping, window.location.href).searchParams.get('url');
} catch {
return null;
}
} else {
return a.href;
}
};
}
Expand Down

0 comments on commit 3963e6c

Please sign in to comment.