-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Yahoo! JAPAN as search engine (#236)
* empty commit * Add TODO comments * Add Yahoo! JAPAN * Update styles
- Loading branch information
Showing
8 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import type { SerpHandler } from '../types'; | ||
import { handleSerp } from './helpers'; | ||
|
||
const webHandler = handleSerp({ | ||
globalStyle: { | ||
'[data-ub-blocked="visible"]': { | ||
backgroundColor: 'var(--ub-block-color, rgba(255, 192, 192, 0.5))', | ||
}, | ||
'.ub-button': { | ||
color: 'var(--ub-link-color, var(--color-link, #000d99))', | ||
textDecoration: 'underline', | ||
}, | ||
'.ub-button:hover': { | ||
color: '#cc3434', | ||
}, | ||
}, | ||
controlHandlers: [ | ||
{ | ||
target: '.Hits__item', | ||
style: { | ||
color: '#666', | ||
marginLeft: '8px', | ||
}, | ||
}, | ||
], | ||
entryHandlers: [ | ||
{ | ||
target: '.sw-CardBase', | ||
url: '.sw-Card__titleInner', | ||
title: '.sw-Card__titleMain', | ||
actionTarget: '.sw-Card__floatContainer', | ||
actionStyle: { | ||
fontSize: '1.4rem', | ||
lineHeight: 1.4, | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
const handlers: Readonly<Record<string, SerpHandler | undefined>> = { | ||
// Web | ||
'/search': webHandler, | ||
}; | ||
|
||
export const getDesktopSerpHandler = (path: string): SerpHandler | null => { | ||
return handlers[path] ?? null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { SerpHandler } from '../types'; | ||
import { handleSerp } from './helpers'; | ||
|
||
const webHandler = handleSerp({ | ||
globalStyle: { | ||
'[data-ub-blocked="visible"]': { | ||
backgroundColor: 'var(--ub-block-color, rgba(255, 192, 192, 0.5))', | ||
}, | ||
'.ub-button': { | ||
color: 'var(--ub-link-color, var(--color-link, #000d99))', | ||
}, | ||
}, | ||
controlHandlers: [ | ||
{ | ||
target: '.SearchTool', | ||
style: { | ||
color: '#666', | ||
}, | ||
}, | ||
], | ||
entryHandlers: [ | ||
{ | ||
target: '.sw-CardBase', | ||
url: '.sw-Card__space', | ||
title: '.sw-Card__titleMain', | ||
actionTarget: '.sw-Card__floatContainer', | ||
actionStyle: { | ||
fontSize: '12px', | ||
lineHeight: 1.6, | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
const handlers: Readonly<Record<string, SerpHandler | undefined>> = { | ||
// Web | ||
'/search': webHandler, | ||
}; | ||
|
||
export const getMobileSerpHandler = (path: string): SerpHandler | null => { | ||
return handlers[path] ?? null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import mobile from 'is-mobile'; | ||
import { SEARCH_ENGINES } from '../../common/search-engines'; | ||
import type { SearchEngine } from '../types'; | ||
import { getDesktopSerpHandler } from './yahoo-japan-desktop'; | ||
import { getMobileSerpHandler } from './yahoo-japan-mobile'; | ||
|
||
export const yahooJapan: Readonly<SearchEngine> = { | ||
...SEARCH_ENGINES.yahooJapan, | ||
getSerpHandler() { | ||
const { pathname } = new URL(window.location.href); | ||
return mobile({ tablet: false }) | ||
? getMobileSerpHandler(pathname) | ||
: getDesktopSerpHandler(pathname); | ||
}, | ||
}; |