add search.json

This commit is contained in:
James Feng Cao 2024-06-19 21:58:58 +08:00
parent 2e2b048336
commit 9acd6f4a24
4 changed files with 44 additions and 13 deletions

View file

@ -35,7 +35,10 @@ Copyright (C) 2024 Richard Hao Cao
let lastKeys_millis = 0;
fs.readFile(path.join(__dirname,'search.json'), 'utf8', (err, jsonString) => {
if (err) return;
if (err) {
coloncommand(":js fetch2file(repositoryurl,'search.json')");
return;
}
initSearchEngines(jsonString,false);
});
fs.readFile(path.join(__dirname,'mapkeys.json'), 'utf8', (err, jsonStr) => {

View file

@ -1,7 +1,13 @@
{"version":"1.0.27",
{"version":"1.0.28",
"name": "ebrowser",
"description": "The keyboard-friendly minimal suckless web browser",
"main": "webview.js",
"files": [
"webview.js",
"index.html",
"package.json",
"README.md"
],
"scripts": {
"release": "electron-builder"
},
@ -16,12 +22,6 @@
"appId": "torapp.eweb",
"publish": "github",
"asar": false,
"files": [
"webview.js",
"index.html",
"package.json",
"README.md"
],
"directories": {
"output": "release"
},

21
misc/ebrowser/search.json Normal file
View file

@ -0,0 +1,21 @@
{
"b":"https://www.bing.com/search?q=%s",
"bdic":"http://cn.bing.com/dict/search?q=%s",
"ms":"https://metaso.cn?q=%s",
"gc":"https://gitcode.com/aisearch?q=%s",
"ta":"https://thinkany.so/search?q=%s",
"ks":"https://kaisouai.com?q=%s",
"exa":"https://exa.ai/search?c=all&q=%s",
"andi":"https://andisearch.com/?q=%s",
"ph":"https://phind-ai.com/search?q=%s",
"gf":"https://greasyfork.org/en/scripts?filter_locale=0&sort=updated&q=%s",
"dev":"https://devv.ai/search?agentMode=false&q=%s",
"you":"https://you.com/search?tbm=youchat&q=%s",
"p":"https://www.perplexity.ai/?q=%s",
"brave":"https://search.brave.com/search?q=%s",
"g":"https://google.com/search?q=%s",
"git":"https://github.com/search?type=Repositories&q=%s",
"gt":"https://kkgithub.com/search?type=Repositories&q=%s",
"360":"https://so.360.com/s?q=%s",
"bd":"https://m.baidu.com/s?wd=%s"
}

View file

@ -24,6 +24,7 @@ else {
}
topMenu();
const repositoryurl = "https://gitlab.com/jamesfengcao/uweb/-/raw/master/misc/ebrowser/";
const fs = require('fs');
const readline = require('readline');
const path = require('path')
@ -188,6 +189,9 @@ function addrCommand(cmd){
else
gredirect_disable();
return;
case "js"://exetute js
eval(cmd.slice(4));
return;
case "nc":
bForwardCookie = false;
msgbox_info("Cookie forwarding disabled");
@ -232,7 +236,7 @@ function addrCommand(cmd){
case "update":
let updateurl;
if(1==args.length)
updateurl = "https://gitlab.com/jamesfengcao/uweb/-/raw/master/misc/ebrowser/";
updateurl = repositoryurl;
else {
updateurl = args[1];
if(!updateurl.endsWith("/")) updateurl = updateurl +"/";
@ -579,21 +583,24 @@ async function updateApp(url){//url must ending with "/"
})
}
async function fetch2file(urlFolder, filename){
async function fetch2file(urlFolder, filename, bOverwritten=true){
let pathname=path.join(__dirname,filename);
if(!bOverwritten && fs.existsSync(pathname)) return;
let res = await fetch(urlFolder+filename);
let str = await res.text();
writeFile(filename, str);
writeFile(pathname, str);
}
async function writeFile(filename, str){
let pathname=path.join(__dirname,filename+".new");
let pathname=filename+".new";
fs.writeFile(pathname, str, (err) => {
if(err) throw "Fail to write";
fs.rename(pathname,path.join(__dirname,filename),(e1)=>{
fs.rename(pathname,filename,(e1)=>{
if(e1) throw "Fail to rename";
});
});
}
function help(){
const readme = "README.md";
const htmlFN = path.join(__dirname,readme+".html");