diff --git a/misc/ebrowser/index.html b/misc/ebrowser/index.html index 6eee6da..77ae33b 100644 --- a/misc/ebrowser/index.html +++ b/misc/ebrowser/index.html @@ -35,10 +35,7 @@ Copyright (C) 2024 Richard Hao Cao let lastKeys_millis = 0; fs.readFile(path.join(__dirname,'search.json'), 'utf8', (err, jsonString) => { - if (err) { - coloncommand(":js fetch2file(repositoryurl,'search.json')"); - return; - } + if (err) 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 1936482..88a3d0c 100644 --- a/misc/ebrowser/package.json +++ b/misc/ebrowser/package.json @@ -1,13 +1,7 @@ -{"version":"1.0.29", +{"version":"1.0.27", "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" }, @@ -22,6 +16,12 @@ "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 deleted file mode 100644 index 5b2ca89..0000000 --- a/misc/ebrowser/search.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "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 1184896..28bc78e 100644 --- a/misc/ebrowser/webview.js +++ b/misc/ebrowser/webview.js @@ -24,7 +24,6 @@ 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') @@ -53,8 +52,8 @@ fs.readFile(path.join(__dirname,'redirect.json'), 'utf8', (err, jsonString) => { }); async function createWindow () { + let json = await fs.promises.readFile(path.join(__dirname,'uas.json'), 'utf8'); try { - let json = await fs.promises.readFile(path.join(__dirname,'uas.json'), 'utf8'); useragents = JSON.parse(json); } catch (e){console.log(e)} @@ -189,9 +188,6 @@ 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"); @@ -236,7 +232,7 @@ function addrCommand(cmd){ case "update": let updateurl; if(1==args.length) - updateurl = repositoryurl; + updateurl = "https://gitlab.com/jamesfengcao/uweb/-/raw/master/misc/ebrowser/"; else { updateurl = args[1]; if(!updateurl.endsWith("/")) updateurl = updateurl +"/"; @@ -583,24 +579,21 @@ async function updateApp(url){//url must ending with "/" }) } -async function fetch2file(urlFolder, filename, bOverwritten=true){ - let pathname=path.join(__dirname,filename); - if(!bOverwritten && fs.existsSync(pathname)) return; +async function fetch2file(urlFolder, filename){ let res = await fetch(urlFolder+filename); let str = await res.text(); - writeFile(pathname, str); + writeFile(filename, str); } async function writeFile(filename, str){ - let pathname=filename+".new"; + let pathname=path.join(__dirname,filename+".new"); fs.writeFile(pathname, str, (err) => { if(err) throw "Fail to write"; - fs.rename(pathname,filename,(e1)=>{ + fs.rename(pathname,path.join(__dirname,filename),(e1)=>{ if(e1) throw "Fail to rename"; }); }); } - function help(){ const readme = "README.md"; const htmlFN = path.join(__dirname,readme+".html");