Compare commits

..

2 commits

Author SHA1 Message Date
James Feng Cao
052cb9dad1 ebrowser 1.0.29 2024-06-19 22:41:21 +08:00
James Feng Cao
9acd6f4a24 add search.json 2024-06-19 21:58:58 +08:00
4 changed files with 45 additions and 14 deletions

View file

@ -35,7 +35,10 @@ Copyright (C) 2024 Richard Hao Cao
let lastKeys_millis = 0; let lastKeys_millis = 0;
fs.readFile(path.join(__dirname,'search.json'), 'utf8', (err, jsonString) => { 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); initSearchEngines(jsonString,false);
}); });
fs.readFile(path.join(__dirname,'mapkeys.json'), 'utf8', (err, jsonStr) => { fs.readFile(path.join(__dirname,'mapkeys.json'), 'utf8', (err, jsonStr) => {

View file

@ -1,7 +1,13 @@
{"version":"1.0.27", {"version":"1.0.29",
"name": "ebrowser", "name": "ebrowser",
"description": "The keyboard-friendly minimal suckless web browser", "description": "The keyboard-friendly minimal suckless web browser",
"main": "webview.js", "main": "webview.js",
"files": [
"webview.js",
"index.html",
"package.json",
"README.md"
],
"scripts": { "scripts": {
"release": "electron-builder" "release": "electron-builder"
}, },
@ -16,12 +22,6 @@
"appId": "torapp.eweb", "appId": "torapp.eweb",
"publish": "github", "publish": "github",
"asar": false, "asar": false,
"files": [
"webview.js",
"index.html",
"package.json",
"README.md"
],
"directories": { "directories": {
"output": "release" "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(); topMenu();
const repositoryurl = "https://gitlab.com/jamesfengcao/uweb/-/raw/master/misc/ebrowser/";
const fs = require('fs'); const fs = require('fs');
const readline = require('readline'); const readline = require('readline');
const path = require('path') const path = require('path')
@ -52,8 +53,8 @@ fs.readFile(path.join(__dirname,'redirect.json'), 'utf8', (err, jsonString) => {
}); });
async function createWindow () { async function createWindow () {
let json = await fs.promises.readFile(path.join(__dirname,'uas.json'), 'utf8');
try { try {
let json = await fs.promises.readFile(path.join(__dirname,'uas.json'), 'utf8');
useragents = JSON.parse(json); useragents = JSON.parse(json);
} catch (e){console.log(e)} } catch (e){console.log(e)}
@ -188,6 +189,9 @@ function addrCommand(cmd){
else else
gredirect_disable(); gredirect_disable();
return; return;
case "js"://exetute js
eval(cmd.slice(4));
return;
case "nc": case "nc":
bForwardCookie = false; bForwardCookie = false;
msgbox_info("Cookie forwarding disabled"); msgbox_info("Cookie forwarding disabled");
@ -232,7 +236,7 @@ function addrCommand(cmd){
case "update": case "update":
let updateurl; let updateurl;
if(1==args.length) if(1==args.length)
updateurl = "https://gitlab.com/jamesfengcao/uweb/-/raw/master/misc/ebrowser/"; updateurl = repositoryurl;
else { else {
updateurl = args[1]; updateurl = args[1];
if(!updateurl.endsWith("/")) updateurl = updateurl +"/"; 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 res = await fetch(urlFolder+filename);
let str = await res.text(); let str = await res.text();
writeFile(filename, str); writeFile(pathname, str);
} }
async function writeFile(filename, str){ async function writeFile(filename, str){
let pathname=path.join(__dirname,filename+".new"); let pathname=filename+".new";
fs.writeFile(pathname, str, (err) => { fs.writeFile(pathname, str, (err) => {
if(err) throw "Fail to write"; 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"; if(e1) throw "Fail to rename";
}); });
}); });
} }
function help(){ function help(){
const readme = "README.md"; const readme = "README.md";
const htmlFN = path.join(__dirname,readme+".html"); const htmlFN = path.join(__dirname,readme+".html");