support ebrowser update

This commit is contained in:
James Feng Cao 2024-06-18 23:28:12 +08:00
parent 5f2116943f
commit c3173e0f97
13 changed files with 167 additions and 33 deletions

View file

@ -56,6 +56,7 @@ Later on, you can run "npm install electron" to update electron/chromium or "npm
- storage: clear site storage data. - storage: clear site storage data.
- {[options](https://www.electronjs.org/docs/latest/api/session#sescleardataoptions)} - {[options](https://www.electronjs.org/docs/latest/api/session#sescleardataoptions)}
- ext [extension path]: load unpacked Chrome extension. - ext [extension path]: load unpacked Chrome extension.
- gr [gredirect index]: global redirection with corresponding index. Use the first global redirection url if no argument. Disable global redirection with any index out of the range.
- nc/uc : No Cookie forwarding/Use Cookie forwarding with global redirection. - nc/uc : No Cookie forwarding/Use Cookie forwarding with global redirection.
- nh/uh for No/Use url history. - nh/uh for No/Use url history.
- nj/uj for No/Use external Javascript files. - nj/uj for No/Use external Javascript files.
@ -63,15 +64,16 @@ Later on, you can run "npm install electron" to update electron/chromium or "npm
- np : no proxy. - np : no proxy.
- up [proxyName] : use proxy. privous proxy or the first proxy in proxy.json w/o [proxyName]. ":up" command also disables global and domain redirections, which are not restored by ":np". - up [proxyName] : use proxy. privous proxy or the first proxy in proxy.json w/o [proxyName]. ":up" command also disables global and domain redirections, which are not restored by ":np".
- ua [useragentName] : set user agent for future tabs. default user agent w/o arguments. - ua [useragentName] : set user agent for future tabs. default user agent w/o arguments.
- update [updateurl] : update the app. updateurl is optional.
- pdf [filename w/o extension] {[options](https://www.electronjs.org/docs/latest/api/web-contents#contentsprinttopdfoptions)} : print to PDF file. All arguments are optional; empty option "{}" to capture long screenshot as vector graphics. - pdf [filename w/o extension] {[options](https://www.electronjs.org/docs/latest/api/web-contents#contentsprinttopdfoptions)} : print to PDF file. All arguments are optional; empty option "{}" to capture long screenshot as vector graphics.
- "!" address bar commands - "!" address bar commands
"!xx ..." evaluates "xx.js" with the whole address bar text as arguments[0]. "!xx ..." evaluates "xx.js" with the whole address bar text as arguments[0].
#### Commands in no-focus mode (this mode is similar to vi Normal mode) #### Commands in no-focus mode (this mode is similar to vi Normal mode)
Pressing "ESC" to enter no-focus mode if not sure. Pressing "ESC" to enter no-focus mode if not sure.
- ":" for address bar commands - ":" for address bar commands
- "/" for find-in-page with address bar - "/" for find-in-page with address bar
- "!" for ":!" address bar commands - "!" for "!" address bar commands
The other commands are defined in "mapkeys.json", which will map keys to address bar commands. The other commands are defined in "mapkeys.json", which will map keys to address bar commands.

View file

@ -102,6 +102,7 @@ npm install ebrowser
</ul> </ul>
</li> </li>
<li>ext [extension path]: load unpacked Chrome extension.</li> <li>ext [extension path]: load unpacked Chrome extension.</li>
<li>gr [gredirect index]: global redirection with corresponding index. Use the first global redirection url if no argument. Disable global redirection with any index out of the range.</li>
<li>nc/uc : No Cookie forwarding/Use Cookie forwarding with global redirection.</li> <li>nc/uc : No Cookie forwarding/Use Cookie forwarding with global redirection.</li>
<li>nh/uh for No/Use url history.</li> <li>nh/uh for No/Use url history.</li>
<li>nj/uj for No/Use external Javascript files.</li> <li>nj/uj for No/Use external Javascript files.</li>
@ -109,6 +110,7 @@ npm install ebrowser
<li>np : no proxy.</li> <li>np : no proxy.</li>
<li>up [proxyName] : use proxy. privous proxy or the first proxy in proxy.json w/o [proxyName]. &quot;:up&quot; command also disables global and domain redirections, which are not restored by &quot;:np&quot;.</li> <li>up [proxyName] : use proxy. privous proxy or the first proxy in proxy.json w/o [proxyName]. &quot;:up&quot; command also disables global and domain redirections, which are not restored by &quot;:np&quot;.</li>
<li>ua [useragentName] : set user agent for future tabs. default user agent w/o arguments.</li> <li>ua [useragentName] : set user agent for future tabs. default user agent w/o arguments.</li>
<li>update [updateurl] : update the app. updateurl is optional.</li>
<li>pdf [filename w/o extension] {<a href="https://www.electronjs.org/docs/latest/api/web-contents#contentsprinttopdfoptions">options</a>} : print to PDF file. All arguments are optional; empty option &quot;{}&quot; to capture long screenshot as vector graphics.</li> <li>pdf [filename w/o extension] {<a href="https://www.electronjs.org/docs/latest/api/web-contents#contentsprinttopdfoptions">options</a>} : print to PDF file. All arguments are optional; empty option &quot;{}&quot; to capture long screenshot as vector graphics.</li>
</ul> </ul>
</li> </li>
@ -120,7 +122,7 @@ npm install ebrowser
<ul> <ul>
<li>&quot;:&quot; for address bar commands</li> <li>&quot;:&quot; for address bar commands</li>
<li>&quot;/&quot; for find-in-page with address bar</li> <li>&quot;/&quot; for find-in-page with address bar</li>
<li>&quot;!&quot; for &quot;:!&quot; address bar commands</li> <li>&quot;!&quot; for &quot;!&quot; address bar commands</li>
</ul> </ul>
<p>The other commands are defined in &quot;mapkeys.json&quot;, which will map keys to address bar commands.</p> <p>The other commands are defined in &quot;mapkeys.json&quot;, which will map keys to address bar commands.</p>
<h4 id="configuration-files">Configuration files</h4> <h4 id="configuration-files">Configuration files</h4>

View file

@ -6,7 +6,7 @@
<description>Recent content on uweb browser: unlimited power</description> <description>Recent content on uweb browser: unlimited power</description>
<generator>Hugo</generator> <generator>Hugo</generator>
<language>en</language> <language>en</language>
<lastBuildDate>Tue, 18 Jun 2024 11:13:22 +0800</lastBuildDate> <lastBuildDate>Tue, 18 Jun 2024 23:24:23 +0800</lastBuildDate>
<atom:link href="/en/index.xml" rel="self" type="application/rss+xml" /> <atom:link href="/en/index.xml" rel="self" type="application/rss+xml" />
<item> <item>
<title>Text selection/processing</title> <title>Text selection/processing</title>
@ -223,7 +223,7 @@
<link>/en/mirrors/</link> <link>/en/mirrors/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate> <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/en/mirrors/</guid> <guid>/en/mirrors/</guid>
<description>Mirrors (for version 1040+) gitee&#xA;gitcode&#xA;gitcode&#xA;gitea&#xA;notabug&#xA;launchpad&#xA;framagit&#xA;agit&#xA;froggi&#xA;disroot&#xA;gitdab&#xA;pagure&#xA;bitbucket&#xA;jsdelivr&#xA;dagshub&#xA;gitgud&#xA;gitly&#xA;gitnet&#xA;palemoon&#xA;tilde&#xA;dotclear&#xA;mimetest&#xA;chapril&#xA;cryto&#xA;antopie&#xA;bgithub&#xA;nuaa&#xA;yzuu&#xA;Mirrors (for all versions) 试验1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 gitly gitnet palemoon tilde dotclear minetest chapril cryto antopie Repositories gitlab&#xA;sourceforge&#xA;github&#xA;bitbucket</description> <description>Mirrors (for version 1040+) gitee&#xA;gitcode&#xA;gitcode&#xA;gitea&#xA;notabug&#xA;launchpad&#xA;framagit&#xA;agit&#xA;froggi&#xA;disroot&#xA;gitdab&#xA;pagure&#xA;bitbucket&#xA;jsdelivr&#xA;dagshub&#xA;gitgud&#xA;gitly&#xA;gitnet&#xA;palemoon&#xA;tilde&#xA;dotclear&#xA;mimetest&#xA;chapril&#xA;cryto&#xA;antopie&#xA;bgithub&#xA;Mirrors (for all versions) 试验1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 gitly gitnet palemoon tilde dotclear minetest chapril cryto antopie Repositories gitlab&#xA;sourceforge&#xA;github&#xA;bitbucket&#xA;codeberg&#xA;gitee</description>
</item> </item>
<item> <item>
<title></title> <title></title>

View file

@ -26,8 +26,6 @@
[cryto](https://git.cryto.net/jamesfengcao/uweb/raw/branch/master/redirect.html#) [cryto](https://git.cryto.net/jamesfengcao/uweb/raw/branch/master/redirect.html#)
[antopie](https://code.antopie.org/jamesfengcao/uweb/raw/branch/master/redirect.html#) [antopie](https://code.antopie.org/jamesfengcao/uweb/raw/branch/master/redirect.html#)
[bgithub](https://bgithub.xyz/torappinfo/uweb/raw/master/redirect.html#) [bgithub](https://bgithub.xyz/torappinfo/uweb/raw/master/redirect.html#)
[nuaa](https://hub.nuaa.cf/torappinfo/uweb/raw/master/redirect.html#)
[yzuu](https://hub.yzuu.cf/torappinfo/uweb/raw/master/redirect.html#)
#### Mirrors (for all versions) #### Mirrors (for all versions)
<p> <p>

View file

@ -70,9 +70,7 @@
<a href="https://forge.chapril.org/jamesfengcao/uweb/raw/branch/master/redirect.html#">chapril</a><br> <a href="https://forge.chapril.org/jamesfengcao/uweb/raw/branch/master/redirect.html#">chapril</a><br>
<a href="https://git.cryto.net/jamesfengcao/uweb/raw/branch/master/redirect.html#">cryto</a><br> <a href="https://git.cryto.net/jamesfengcao/uweb/raw/branch/master/redirect.html#">cryto</a><br>
<a href="https://code.antopie.org/jamesfengcao/uweb/raw/branch/master/redirect.html#">antopie</a><br> <a href="https://code.antopie.org/jamesfengcao/uweb/raw/branch/master/redirect.html#">antopie</a><br>
<a href="https://bgithub.xyz/torappinfo/uweb/raw/master/redirect.html#">bgithub</a><br> <a href="https://bgithub.xyz/torappinfo/uweb/raw/master/redirect.html#">bgithub</a></p>
<a href="https://hub.nuaa.cf/torappinfo/uweb/raw/master/redirect.html#">nuaa</a><br>
<a href="https://hub.yzuu.cf/torappinfo/uweb/raw/master/redirect.html#">yzuu</a></p>
<h4 id="mirrors-for-all-versions">Mirrors (for all versions)</h4> <h4 id="mirrors-for-all-versions">Mirrors (for all versions)</h4>
<p> <p>
<a href="i:0mi:5h:https://gitee.com/jamesfengcao/uweb/raw/master/redirect.html">试验1</a> <a href="i:0mi:5h:https://gitee.com/jamesfengcao/uweb/raw/master/redirect.html">试验1</a>
@ -135,8 +133,8 @@
<a href="https://code.antopie.org/jamesfengcao/uweb/src/master/README.md">antopie</a></p> <a href="https://code.antopie.org/jamesfengcao/uweb/src/master/README.md">antopie</a></p>
</div> </div>
<p>Last Modified: 6 April 2024<br> <p>Last Modified: 18 June 2024<br>
more details on global redirection url<br> update mirrors<br>
<pre></pre> <pre></pre>
</p> </p>

View file

@ -107,7 +107,7 @@
</div> </div>
<p>Last Modified: 18 June 2024<br> <p>Last Modified: 18 June 2024<br>
use adaptable ebrowser links<br> update mirrors<br>
<pre></pre> <pre></pre>
</p> </p>

View file

@ -77,7 +77,7 @@
</div> </div>
<p>Last Modified: 18 June 2024<br> <p>Last Modified: 18 June 2024<br>
fix typos<br> update mirrors<br>
<pre></pre> <pre></pre>
</p> </p>

View file

@ -71,7 +71,7 @@
/> />
</url><url> </url><url>
<loc>/en/</loc> <loc>/en/</loc>
<lastmod>2024-06-18T11:13:22+08:00</lastmod> <lastmod>2024-06-18T23:24:23+08:00</lastmod>
<xhtml:link <xhtml:link
rel="alternate" rel="alternate"
hreflang="zh" hreflang="zh"
@ -508,10 +508,10 @@
/> />
</url><url> </url><url>
<loc>/en/ebrowserreadme/</loc> <loc>/en/ebrowserreadme/</loc>
<lastmod>2024-06-18T10:22:59+08:00</lastmod> <lastmod>2024-06-18T23:24:23+08:00</lastmod>
</url><url> </url><url>
<loc>/en/mirrors/</loc> <loc>/en/mirrors/</loc>
<lastmod>2024-04-06T10:20:49+08:00</lastmod> <lastmod>2024-06-18T23:17:17+08:00</lastmod>
</url><url> </url><url>
<loc>/en/readme/</loc> <loc>/en/readme/</loc>
<lastmod>2024-06-18T11:13:22+08:00</lastmod> <lastmod>2024-06-18T11:13:22+08:00</lastmod>
@ -539,7 +539,7 @@
/> />
</url><url> </url><url>
<loc>/en/unlist/</loc> <loc>/en/unlist/</loc>
<lastmod>2024-06-18T11:13:22+08:00</lastmod> <lastmod>2024-06-18T23:24:23+08:00</lastmod>
<xhtml:link <xhtml:link
rel="alternate" rel="alternate"
hreflang="zh" hreflang="zh"

View file

@ -19,7 +19,7 @@
<link>/en/mirrors/</link> <link>/en/mirrors/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate> <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/en/mirrors/</guid> <guid>/en/mirrors/</guid>
<description>Mirrors (for version 1040+) gitee&#xA;gitcode&#xA;gitcode&#xA;gitea&#xA;notabug&#xA;launchpad&#xA;framagit&#xA;agit&#xA;froggi&#xA;disroot&#xA;gitdab&#xA;pagure&#xA;bitbucket&#xA;jsdelivr&#xA;dagshub&#xA;gitgud&#xA;gitly&#xA;gitnet&#xA;palemoon&#xA;tilde&#xA;dotclear&#xA;mimetest&#xA;chapril&#xA;cryto&#xA;antopie&#xA;bgithub&#xA;nuaa&#xA;yzuu&#xA;Mirrors (for all versions) 试验1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 gitly gitnet palemoon tilde dotclear minetest chapril cryto antopie Repositories gitlab&#xA;sourceforge&#xA;github&#xA;bitbucket</description> <description>Mirrors (for version 1040+) gitee&#xA;gitcode&#xA;gitcode&#xA;gitea&#xA;notabug&#xA;launchpad&#xA;framagit&#xA;agit&#xA;froggi&#xA;disroot&#xA;gitdab&#xA;pagure&#xA;bitbucket&#xA;jsdelivr&#xA;dagshub&#xA;gitgud&#xA;gitly&#xA;gitnet&#xA;palemoon&#xA;tilde&#xA;dotclear&#xA;mimetest&#xA;chapril&#xA;cryto&#xA;antopie&#xA;bgithub&#xA;Mirrors (for all versions) 试验1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 gitly gitnet palemoon tilde dotclear minetest chapril cryto antopie Repositories gitlab&#xA;sourceforge&#xA;github&#xA;bitbucket&#xA;codeberg&#xA;gitee</description>
</item> </item>
<item> <item>
<title></title> <title></title>

View file

@ -0,0 +1,47 @@
{"version":"1.0.21",
"name": "ebrowser",
"description": "The keyboard-friendly minimal suckless web browser",
"main": "webview.js",
"scripts": {
"release": "electron-builder"
},
"author": "Richard H. Cao",
"keywords": ["browser","minimal","suckless","command line","vim key map","user scripts"],
"license": "GPL-3.0",
"repository": {
"type": "git",
"url": "git+https://github.com/torappinfo/ebrowser.git"
},
"build": {
"appId": "torapp.eweb",
"publish": "github",
"asar": false,
"files": [
"webview.js",
"index.html",
"package.json",
"README.md"
],
"directories": {
"output": "release"
},
"dmg": {
"contents": [
{ "x": 110, "y": 150 },
{ "x": 240, "y": 150, "type": "link", "path": "/Applications" }
]
},
"nsis": {
"createDesktopShortcut": "always"
},
"linux": {
"target": "AppImage"
}
},
"dependencies": {
},
"devDependencies": {
"electron":"",
"electron-builder": ""
}
}

View file

@ -177,6 +177,17 @@ function addrCommand(cmd){
case "ext": case "ext":
session.defaultSession.loadExtension(args[1]); session.defaultSession.loadExtension(args[1]);
return; return;
case "gr":
if(args.length<2) {
gredirect_enable(0);
return;
}
let i = parseInt(args[1]);
if(i>=0 && i<gredirects.length)
gredirect_enable(i);
else
gredirect_disable();
return;
case "nc": case "nc":
bForwardCookie = false; bForwardCookie = false;
msgbox_info("Cookie forwarding disabled"); msgbox_info("Cookie forwarding disabled");
@ -204,11 +215,7 @@ function addrCommand(cmd){
if(args.length>1) if(args.length>1)
proxy = proxies[args[1]]; //retrieve proxy proxy = proxies[args[1]]; //retrieve proxy
if(proxy){ if(proxy){
if(gredirect){ gredirect_disable();
gredirect=null;
unregisterHandler();
}
bRedirect = false;
session.defaultSession.setProxy(proxy); session.defaultSession.setProxy(proxy);
} }
return; return;
@ -222,10 +229,33 @@ function addrCommand(cmd){
else else
session.defaultSession.setUserAgent(defaultUA); session.defaultSession.setUserAgent(defaultUA);
return; return;
case "update":
let updateurl;
if(1==args.length)
updateurl = "https://gitlab.com/jamesfengcao/uweb/-/raw/master/misc/ebrowser/";
else {
updateurl = args[1];
if(!updateurl.endsWith("/")) updateurl = updateurl +"/";
}
updateApp(updateurl);
return;
} }
} }
} }
function gredirect_disable(){
if(gredirect){
gredirect=null;
unregisterHandler();
}
bRedirect = false;
}
function gredirect_enable(i){
if(i>=gredirects.length) return;
if(!gredirect) registerHandler();
gredirect=gredirects[i];
}
function cbConsoleMsg(e, level, msg, line, sourceid){ function cbConsoleMsg(e, level, msg, line, sourceid){
console.log(line); console.log(line);
console.log(sourceid); console.log(sourceid);
@ -355,15 +385,10 @@ function topMenu(){
win.webContents.executeJavaScript(js,false); win.webContents.executeJavaScript(js,false);
}}, }},
{ label: 'No redirect', accelerator: 'Ctrl+R', click: ()=>{ { label: 'No redirect', accelerator: 'Ctrl+R', click: ()=>{
if(gredirect){ gredirect_disable();
gredirect=null;
unregisterHandler();
}
}}, }},
{ label: 'Redirect', accelerator: 'Ctrl+Shift+R', click: ()=>{ { label: 'Redirect', accelerator: 'Ctrl+Shift+R', click: ()=>{
if(0==gredirects.length) return; gredirect_enable(0);
if(!gredirect) registerHandler();
gredirect=gredirects[0];
}}, }},
{ label: 'Close', accelerator: 'Ctrl+W', click: ()=>{ { label: 'Close', accelerator: 'Ctrl+W', click: ()=>{
win.webContents.executeJavaScript("tabClose()",false).then((r)=>{ win.webContents.executeJavaScript("tabClose()",false).then((r)=>{
@ -493,4 +518,66 @@ function msgbox_info(msg){
}) })
} }
async function updateApp(url){//url must ending with "/"
let msg;
do {
try {
let res = await fetch(url+"package.json");
let packageS = await res.text();
let nLatestVer;
//the last part of version string is the version number, must keep increasing
{
let head = packageS.slice(2,40);
let iV = head.indexOf("version");
if(iV<0) {
msg = "remote package.json corrupted"
break;
}
iV = iV + 11;
let iE = head.indexOf('"',iV+4);
let iS = head.lastIndexOf('.',iE-1);
nLatestVer = parseInt(head.substring(iS+1,iE));
}
let nVer;
{
let ver = process.versions;
let iS = ver.lastIndexOf('.');
nVer = parseInt(ver.substring(iS+1));
}
if(nVer>=nLatestVer){
msg = "Already up to date";
break;
}
writeFile("package.json", packageS);
fetch2file(url,"webview.js");
fetch2file(url,"index.html");
msg = "Update completed";
}catch(e){
msg = "Fail to update"
}
}while(false);
dialog.showMessageBoxSync(null, {
type: 'info',
title: msg,
message: msg,
buttons: ['OK']
})
}
async function fetch2file(urlFolder, filename){
let res = await fetch(urlFolder+filename);
let str = await res.text();
writeFile(filename, str);
}
async function writeFile(filename, str){
let pathname=path.join(__dirname,filename+".new");
fs.writeFile(pathname, str, (err) => {
if(err) throw "Fail to write";
fs.rename(pathname,path.join(__dirname,filename),(e1)=>{
if(e1) throw "Fail to rename";
});
});
}

View file

@ -4,7 +4,7 @@
<sitemap> <sitemap>
<loc>/en/sitemap.xml</loc> <loc>/en/sitemap.xml</loc>
<lastmod>2024-06-18T11:13:22+08:00</lastmod> <lastmod>2024-06-18T23:24:23+08:00</lastmod>
</sitemap> </sitemap>

View file

@ -326,7 +326,7 @@
</div> </div>
<p>Last Modified: 18 June 2024<br> <p>Last Modified: 18 June 2024<br>
add more AI search engines<br> update mirrors<br>
<pre>24.02.26 添加网盘搜索引擎 <pre>24.02.26 添加网盘搜索引擎
</pre> </pre>
</p> </p>