From 8bb0f680498653b189720f507db5b272f7c13974 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 23 Nov 2024 18:58:29 +0900 Subject: [PATCH] Update the search engines --- lib/http.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/http.js b/lib/http.js index 3eb802d..4261f89 100644 --- a/lib/http.js +++ b/lib/http.js @@ -1,6 +1,6 @@ // http.js // HTTP REST Client for WelsonJS framework -// Namhyeon Go (Catswords Research) +// Namhyeon Go (Catswords Research) // https://github.com/gnh1201/welsonjs var SYS = require("lib/system"); var FILE = require("lib/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]);