diff --git a/misc/ebrowser/index.html b/misc/ebrowser/index.html
index 77ae33b..6eee6da 100644
--- a/misc/ebrowser/index.html
+++ b/misc/ebrowser/index.html
@@ -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) => {
diff --git a/misc/ebrowser/package.json b/misc/ebrowser/package.json
index 88a3d0c..d6a941a 100644
--- a/misc/ebrowser/package.json
+++ b/misc/ebrowser/package.json
@@ -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"
},
diff --git a/misc/ebrowser/search.json b/misc/ebrowser/search.json
new file mode 100644
index 0000000..5b2ca89
--- /dev/null
+++ b/misc/ebrowser/search.json
@@ -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"
+}
diff --git a/misc/ebrowser/webview.js b/misc/ebrowser/webview.js
index 28bc78e..82e7807 100644
--- a/misc/ebrowser/webview.js
+++ b/misc/ebrowser/webview.js
@@ -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");