Skip to content

Commit

Permalink
fix(yandex): update URLs (#466)
Browse files Browse the repository at this point in the history
* yandex: update URLs

yandex.ru redirects to dzen.ru.
The original search service is served at ya.ru.

* yandex: update link colors to match dark mode
  • Loading branch information
iorate authored May 19, 2024
1 parent abdea24 commit 4a9a5e0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 90 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This extension is available in the below search engines.
| SearX \*2 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Startpage | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: |
| Yahoo! JAPAN | :heavy_check_mark: | | | |
| Yandex | :heavy_check_mark: | | | :heavy_check_mark: |
| Yandex | :heavy_check_mark: | | | |

\*1 Only if "Always play videos on Qwant.com" is turned off<br>
\*2 Only certain public instances are supported. If you want to add support for your own SearX/SearXNG search engine, edit `src/common/search-engines.ts` and build the extension manually<br>
Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
| SearX \*3 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Startpage | :heavy_check_mark: | | :heavy_check_mark: | :heavy_check_mark: |
| Yahoo! JAPAN | :heavy_check_mark: | | | |
| Yandex | :heavy_check_mark: | | | :heavy_check_mark: |
| Yandex | :heavy_check_mark: | | | |

\*1 仅当 "Always play videos on Qwant.com" 关闭时<br>
\*2 仅支持某些公共实例,如果您想将自己的 SearX/SearXNG 添加到支持列表,你需要前往`src/common/search-engines.ts`,并手动将您的搜索引擎添加到列表中,然后手动进行构建。
Expand Down
55 changes: 18 additions & 37 deletions src/common/search-engines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,43 +551,24 @@ export const SEARCH_ENGINES: Readonly<
{
matches: [
// Web
"https://yandex.com/search/?*",
"https://yandex.ru/search/?*",
"https://yandex.ua/search/?*",
"https://yandex.by/search/?*",
"https://yandex.kz/search/?*",
"https://yandex.uz/search/?*",
"https://yandex.com.tr/search/?*",
"https://yandex.fr/search/?*",
"https://yandex.az/search/?*",
"https://yandex.com.ge/search/?*",
"https://yandex.com.am/search/?*",
"https://yandex.co.il/search/?*",
"https://yandex.lv/search/?*",
"https://yandex.lt/search/?*",
"https://yandex.ee/search/?*",
"https://yandex.md/search/?*",
"https://yandex.tm/search/?*",
"https://yandex.tj/search/?*",
// News
"https://newssearch.yandex.com/news/search?*",
"https://newssearch.yandex.ru/news/search?*",
"https://newssearch.yandex.ua/news/search?*",
"https://newssearch.yandex.by/news/search?*",
"https://newssearch.yandex.kz/news/search?*",
"https://newssearch.yandex.uz/news/search?*",
"https://newssearch.yandex.com.tr/news/search?*",
"https://newssearch.yandex.fr/news/search?*",
"https://newssearch.yandex.az/news/search?*",
"https://newssearch.yandex.com.ge/news/search?*",
"https://newssearch.yandex.com.am/news/search?*",
"https://newssearch.yandex.co.il/news/search?*",
"https://newssearch.yandex.lv/news/search?*",
"https://newssearch.yandex.lt/news/search?*",
"https://newssearch.yandex.ee/news/search?*",
"https://newssearch.yandex.md/news/search?*",
"https://newssearch.yandex.tm/news/search?*",
"https://newssearch.yandex.tj/news/search?*",
"https://ya.ru/search*",
"https://yandex.com/search*",
"https://yandex.ua/search*",
"https://yandex.by/search*",
"https://yandex.kz/search*",
"https://yandex.uz/search*",
"https://yandex.com.tr/search*",
"https://yandex.fr/search*",
"https://yandex.az/search*",
"https://yandex.com.ge/search*",
"https://yandex.com.am/search*",
"https://yandex.co.il/search*",
"https://yandex.lv/search*",
"https://yandex.lt/search*",
"https://yandex.ee/search*",
"https://yandex.md/search*",
"https://yandex.tm/search*",
"https://yandex.tj/search*",
],
runAt: "document_idle",
},
Expand Down
78 changes: 27 additions & 51 deletions src/scripts/search-engines/yandex.ts
Original file line number Diff line number Diff line change
@@ -1,76 +1,52 @@
import { SEARCH_ENGINES } from "../../common/search-engines.ts";
import type { CSSAttribute } from "../styles.ts";
import type { SearchEngine, SerpHandler } from "../types.ts";
import { handleSerp } from "./helpers.ts";
import { getDialogThemeFromBody, handleSerp } from "./helpers.ts";

const globalStyle: CSSAttribute = {
'[data-ub-blocked="visible"]': {
backgroundColor:
"var(--ub-block-color, rgba(255, 192, 192, 0.5)) !important",
},
".ub-button": {
color: "var(--ub-link-color, rgba(84, 96, 122, .68))",
color: "var(--ub-link-color, var(--depot-color-link))",
fontSize: "14px",
lineHeight: "17px",
},
".ub-button:hover": {
color: "var(--ub-link-color, rgba(62, 70, 94, .8))",
color: "var(--ub-link-color, var(--depot-color-link-hovered))",
},
};

const serpHandlers: Readonly<Record<string, SerpHandler | undefined>> = {
"/search/": handleSerp({
globalStyle,
controlHandlers: [
{
target: ".content__left",
position: "beforebegin",
style: {
display: "block",
marginBottom: "20px",
},
const serpHandler: SerpHandler = handleSerp({
globalStyle,
controlHandlers: [
{
target: ".content__left",
position: "beforebegin",
style: {
display: "block",
marginBottom: "20px",
},
],
entryHandlers: [
{
target: "li.serp-item",
url: ".organic__url",
title: ".organic__title",
actionTarget: ".organic__subtitle",
actionStyle: {
marginLeft: "2px",
},
},
],
entryHandlers: [
{
target: "li.serp-item",
url: ".organic__url",
title: ".organic__title",
actionTarget: ".organic__subtitle",
actionStyle: {
marginLeft: "2px",
},
],
}),
"/news/search": handleSerp({
globalStyle,
controlHandlers: [
{
target: ".news-app__content",
position: "afterbegin",
style: {
display: "block",
marginLeft: "15px",
marginBottom: "5px",
},
},
],
entryHandlers: [
{
target: "article.news-search-story",
url: ".mg-snippet__url",
title: ".mg-snippet__title",
actionTarget: ".mg-snippet__agency-info",
},
],
}),
};
},
],
getDialogTheme: getDialogThemeFromBody(),
});

export const yandex: Readonly<SearchEngine> = {
...SEARCH_ENGINES.yandex,
getSerpHandler() {
const path = new URL(window.location.href).pathname;
return serpHandlers[path] || null;
return serpHandler;
},
};

0 comments on commit 4a9a5e0

Please sign in to comment.