Update the search engines

This commit is contained in:
Namhyeon Go 2024-11-23 18:58:29 +09:00
parent d3743e206c
commit 8bb0f68049

View File

@ -8,6 +8,7 @@ var SHELL = require("lib/shell");
var RAND = require("lib/rand");
var BASE64 = require("lib/base64");
var PipeIPC = require("lib/pipe-ipc");
var JsonRpc2 = require("lib/jsonrpc2");
var OS_NAME = SYS.getOS();
var OS_ARCH = SYS.getArch();
@ -38,19 +39,19 @@ var AVAILABLE_PROXIES = [
{
"type": "serp",
"provider": "librey",
"url": "https://serp.catswords.net/api.php?q={q}&p=1&t=0",
"url": "https://farside.link/librex/api.php?q={q}&p=1&t=0",
"documentation": "https://github.com/Ahwxorg/LibreY"
},
{
"type": "serp",
"provider": "invidious",
"url": "https://invidious.example.org/api/v1/search?q={q}",
"url": "https://farside.link/invidious/api/v1/search?q={q}",
"documentation": "https://docs.invidious.io/"
},
{
"type": "stateless-jsonrpc2",
"provider": "gnh1201/caterpillar",
"url": "http://localhost:5555",
"url": "http://localhost:8080",
"documentation": "https://github.com/gnh1201/caterpillar"
},
{
@ -511,20 +512,22 @@ var HTTPObject = function(engine) {
this.parseSerpUrl = function(url) {
var getEngine = function(url) {
var match = url.match(/(?:https?:\/\/)?(?:www\.)?(google|youtube|bing|baidu|amazon|naver|daum)\.\w+/), result;
var match = url.match(/(?:https?:\/\/)?(?:www\.)?(google|youtube|bing|baidu|amazon|duckduckgo|naver|daum|aliexpress|temu|coupang)|\.\w+/), engine;
if (match) {
result = match[1];
if (result == "naver" || result == "daum") {
result = "google";
engine = match[1];
if (["naver", "daum"].indexOf(engine) > -1) {
engine = "google";
} else if (["aliexpress", "temu", "coupang"].indexOf(engine) > -1) {
engine = "google_shopping";
}
} else {
result = "google";
engine = "google";
}
return result;
return engine;
};
var getKeyword = function(url) {
var regex = /[?&](q|wd|query|search_query|k)=([^&]*)/g;
var regex = /[?&](q|wd|query|search_query|k|SearchText|search_key)=([^&]*)/g;
var match, keywords = [];
while ((match = regex.exec(url)) !== null) {
keywords.push(match[2]);