From c3173e0f97c06c8bc8384991938eb72ddc9824f4 Mon Sep 17 00:00:00 2001 From: James Feng Cao Date: Tue, 18 Jun 2024 23:28:12 +0800 Subject: [PATCH] support ebrowser update --- ebrowser.md | 6 +- en/ebrowserreadme/index.html | 4 +- en/index.xml | 4 +- en/mirrors.md | 2 - en/mirrors/index.html | 8 +-- en/readme/index.html | 2 +- en/rjs/index.html | 2 +- en/sitemap.xml | 8 +-- en/unlist/index.xml | 2 +- misc/ebrowser/package.json | 47 +++++++++++++++ misc/ebrowser/webview.js | 111 +++++++++++++++++++++++++++++++---- sitemap.xml | 2 +- zh/search/index.html | 2 +- 13 files changed, 167 insertions(+), 33 deletions(-) create mode 100644 misc/ebrowser/package.json diff --git a/ebrowser.md b/ebrowser.md index 87344a4..7d43624 100644 --- a/ebrowser.md +++ b/ebrowser.md @@ -56,6 +56,7 @@ Later on, you can run "npm install electron" to update electron/chromium or "npm - storage: clear site storage data. - {[options](https://www.electronjs.org/docs/latest/api/session#sescleardataoptions)} - 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. - nh/uh for No/Use url history. - 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. - 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. + - 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. -- "!" address bar commands +- "!" address bar commands "!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) Pressing "ESC" to enter no-focus mode if not sure. - ":" for address bar commands - "/" 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. diff --git a/en/ebrowserreadme/index.html b/en/ebrowserreadme/index.html index bd43ba3..ce9e4ae 100644 --- a/en/ebrowserreadme/index.html +++ b/en/ebrowserreadme/index.html @@ -102,6 +102,7 @@ npm install ebrowser
  • 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.
  • nh/uh for No/Use url history.
  • nj/uj for No/Use external Javascript files.
  • @@ -109,6 +110,7 @@ npm install ebrowser
  • 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".
  • 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} : print to PDF file. All arguments are optional; empty option "{}" to capture long screenshot as vector graphics.
  • @@ -120,7 +122,7 @@ npm install ebrowser

    The other commands are defined in "mapkeys.json", which will map keys to address bar commands.

    Configuration files

    diff --git a/en/index.xml b/en/index.xml index b1b82f6..622efc5 100644 --- a/en/index.xml +++ b/en/index.xml @@ -6,7 +6,7 @@ Recent content on uweb browser: unlimited power Hugo en - Tue, 18 Jun 2024 11:13:22 +0800 + Tue, 18 Jun 2024 23:24:23 +0800 Text selection/processing @@ -223,7 +223,7 @@ /en/mirrors/ Mon, 01 Jan 0001 00:00:00 +0000 /en/mirrors/ - Mirrors (for version 1040+) gitee gitcode gitcode gitea notabug launchpad framagit agit froggi disroot gitdab pagure bitbucket jsdelivr dagshub gitgud gitly gitnet palemoon tilde dotclear mimetest chapril cryto antopie bgithub nuaa yzuu 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 sourceforge github bitbucket + Mirrors (for version 1040+) gitee gitcode gitcode gitea notabug launchpad framagit agit froggi disroot gitdab pagure bitbucket jsdelivr dagshub gitgud gitly gitnet palemoon tilde dotclear mimetest chapril cryto antopie bgithub 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 sourceforge github bitbucket codeberg gitee diff --git a/en/mirrors.md b/en/mirrors.md index 7fcb784..6599b87 100644 --- a/en/mirrors.md +++ b/en/mirrors.md @@ -26,8 +26,6 @@ [cryto](https://git.cryto.net/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#) -[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)

    diff --git a/en/mirrors/index.html b/en/mirrors/index.html index 232047c..99fa1eb 100644 --- a/en/mirrors/index.html +++ b/en/mirrors/index.html @@ -70,9 +70,7 @@ chapril
    cryto
    antopie
    -bgithub
    -nuaa
    -yzuu

    +bgithub

    Mirrors (for all versions)

    试验1 @@ -135,8 +133,8 @@ antopie

    -

    Last Modified: 6 April 2024
    -more details on global redirection url
    +

    Last Modified: 18 June 2024
    +update mirrors

    
     

    diff --git a/en/readme/index.html b/en/readme/index.html index a758351..9de0e87 100644 --- a/en/readme/index.html +++ b/en/readme/index.html @@ -107,7 +107,7 @@

    Last Modified: 18 June 2024
    -use adaptable ebrowser links
    +update mirrors

    
     

    diff --git a/en/rjs/index.html b/en/rjs/index.html index 6cbe5d5..ae93ec4 100644 --- a/en/rjs/index.html +++ b/en/rjs/index.html @@ -77,7 +77,7 @@

    Last Modified: 18 June 2024
    -fix typos
    +update mirrors

    
     

    diff --git a/en/sitemap.xml b/en/sitemap.xml index 87bd1b3..6b44d0c 100644 --- a/en/sitemap.xml +++ b/en/sitemap.xml @@ -71,7 +71,7 @@ /> /en/ - 2024-06-18T11:13:22+08:00 + 2024-06-18T23:24:23+08:00 /en/ebrowserreadme/ - 2024-06-18T10:22:59+08:00 + 2024-06-18T23:24:23+08:00 /en/mirrors/ - 2024-04-06T10:20:49+08:00 + 2024-06-18T23:17:17+08:00 /en/readme/ 2024-06-18T11:13:22+08:00 @@ -539,7 +539,7 @@ /> /en/unlist/ - 2024-06-18T11:13:22+08:00 + 2024-06-18T23:24:23+08:00 /en/mirrors/ Mon, 01 Jan 0001 00:00:00 +0000 /en/mirrors/ - Mirrors (for version 1040+) gitee gitcode gitcode gitea notabug launchpad framagit agit froggi disroot gitdab pagure bitbucket jsdelivr dagshub gitgud gitly gitnet palemoon tilde dotclear mimetest chapril cryto antopie bgithub nuaa yzuu 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 sourceforge github bitbucket + Mirrors (for version 1040+) gitee gitcode gitcode gitea notabug launchpad framagit agit froggi disroot gitdab pagure bitbucket jsdelivr dagshub gitgud gitly gitnet palemoon tilde dotclear mimetest chapril cryto antopie bgithub 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 sourceforge github bitbucket codeberg gitee
    diff --git a/misc/ebrowser/package.json b/misc/ebrowser/package.json new file mode 100644 index 0000000..194e206 --- /dev/null +++ b/misc/ebrowser/package.json @@ -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": "" + } +} diff --git a/misc/ebrowser/webview.js b/misc/ebrowser/webview.js index 27cc913..2da15b2 100644 --- a/misc/ebrowser/webview.js +++ b/misc/ebrowser/webview.js @@ -177,6 +177,17 @@ function addrCommand(cmd){ case "ext": session.defaultSession.loadExtension(args[1]); return; + case "gr": + if(args.length<2) { + gredirect_enable(0); + return; + } + let i = parseInt(args[1]); + if(i>=0 && i1) proxy = proxies[args[1]]; //retrieve proxy if(proxy){ - if(gredirect){ - gredirect=null; - unregisterHandler(); - } - bRedirect = false; + gredirect_disable(); session.defaultSession.setProxy(proxy); } return; @@ -222,10 +229,33 @@ function addrCommand(cmd){ else session.defaultSession.setUserAgent(defaultUA); 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){ console.log(line); console.log(sourceid); @@ -355,15 +385,10 @@ function topMenu(){ win.webContents.executeJavaScript(js,false); }}, { label: 'No redirect', accelerator: 'Ctrl+R', click: ()=>{ - if(gredirect){ - gredirect=null; - unregisterHandler(); - } + gredirect_disable(); }}, { label: 'Redirect', accelerator: 'Ctrl+Shift+R', click: ()=>{ - if(0==gredirects.length) return; - if(!gredirect) registerHandler(); - gredirect=gredirects[0]; + gredirect_enable(0); }}, { label: 'Close', accelerator: 'Ctrl+W', click: ()=>{ 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"; + }); + }); +} diff --git a/sitemap.xml b/sitemap.xml index 4606f6d..e357888 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -4,7 +4,7 @@ /en/sitemap.xml - 2024-06-18T11:13:22+08:00 + 2024-06-18T23:24:23+08:00 diff --git a/zh/search/index.html b/zh/search/index.html index c14d8b6..57f4273 100644 --- a/zh/search/index.html +++ b/zh/search/index.html @@ -326,7 +326,7 @@

    Last Modified: 18 June 2024
    -add more AI search engines
    +update mirrors

    24.02.26 添加网盘搜索引擎