Skip to content

Commit

Permalink
fix(bing): don't block www.bing.com itself
Browse files Browse the repository at this point in the history
  • Loading branch information
iorate committed Sep 18, 2022
1 parent 4d6f290 commit d548cc6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/scripts/search-engines/bing-desktop.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as S from 'microstruct';
import { CSSAttribute, css } from '../styles';
import { SerpHandler } from '../types';
import { makeAltURL } from '../utilities';
import { getParentElement, handleSerp } from './helpers';

const globalStyle: CSSAttribute = {
Expand Down Expand Up @@ -37,7 +38,18 @@ const serpHandlers: Readonly<Record<string, SerpHandler | undefined>> = {
entryHandlers: [
{
target: '.b_algo',
url: 'h2 > a',
url: root => {
const url = root.querySelector<HTMLAnchorElement>('h2 > a')?.href;
if (!url) {
return null;
}
const u = makeAltURL(url);
if (!u || u.host === 'www.bing.com') {
// "Open links from search results in a new tab or window" is turned on
return null;
}
return url;
},
title: 'h2',
actionTarget: '.b_attribution',
actionStyle: {
Expand Down

0 comments on commit d548cc6

Please sign in to comment.