ebrowser v1.0.38

This commit is contained in:
James Feng Cao 2024-06-28 09:48:56 +08:00
parent c00e3a1f09
commit ad1d9e33b7
7 changed files with 51 additions and 11 deletions

View file

@ -33,6 +33,9 @@ Type ":update" in the address bar and press "enter" key to update.
Mirror urls could be used like ":update https://uwebzh.netlify.app/misc/ebrowser". All the mirrors listed on [uweb browser](https://uwebzh.netlify.app/en/readme/index.html) could be used. The update url needs to be changed accordingly to be the folder "misc/ebrowser" under the mirror site root url.
#### Key shortcuts
- Alt: show menu
- ALT+<-: go backward
- ALT+->: go forward
- CTRL+C: stop loading
- CTRL+G: address bar to show page url
- CTRL+L: focus to address bar
@ -41,8 +44,6 @@ Mirror urls could be used like ":update https://uwebzh.netlify.app/misc/ebrowser
- CTRL+TAB: switch to next tab
- CTRL+SHIFT+TAB: switch to previous tab
- CTRL+W: close Tab
- ALT+<-: go backward
- ALT+->: go forward
- CTRL+SHIFT+R: enable global redirection ("gredirect.json")
- CTRL+R: disable global redirection
- ESC: remove focus. similar to vi normal mode.
@ -51,6 +52,7 @@ Mirror urls could be used like ":update https://uwebzh.netlify.app/misc/ebrowser
- F12: devtools
#### Address bar commands
Like any popular browser, the very first word in address bar if defined in "search.json" identifies a search engine. Moreover, the address bar serves as command line interface:
- "/" for find-in-page
- ":" for address bar commands
- ac [bookmark/history path w/o ext] : load ".rec" file for autocomplete.

View file

@ -429,6 +429,9 @@ You should have received a copy of the GNU General Public License along with thi
break NOREC;
if(58===c5 && 47===q.charCodeAt(7))//https://
break NOREC;
}else if(58===q.charCodeAt(1)){
internalLink(q);
return;
}else if(q.startsWith("javascript:")){
tabs.children[iTab].executeJavaScript(q.substring(11),false);
recQueryHistory(q);
@ -449,11 +452,42 @@ You should have received a copy of the GNU General Public License along with thi
break;
}
url = bang(q, iS);
if(58===url.charCodeAt(1)){
internalLink(url);
recQueryHistory(q);
return;
}
}while(false);
recQueryHistory(q);
}while(false);
tabs.children[iTab].src=url;
}
function internalLink(url){
let cmd = url.charCodeAt(2);
let subcmd = url.charCodeAt(3);
let iColon = url.indexOf(':',2);
switch(cmd){
case 48://'0' i:0
switch(subcmd){
case 47://'/' i:0/
if(106===url.charCodeAt(4) && 115===url.charCodeAt(5) && 47===url.charCoseAt(6)){
//i:0/js/xx:[url]
let fname = url.slice(4,iColon);
let pname = path.join(__dirname,fname);
if(fs.existsSync(pname)){
(async ()=>{
try {
let js = await fs.promises.readFile(pname,'utf8');
let t=tabs.children[iTab];
t.dataset.jsonce=js;
t.src = url.substring(iColon+1);
}catch(e){}
})();
}
}
}
}
}
function autocomplete(inp,container,arr) {
var currentFocus;
function clickItem(e){inp.value = arr[e.target.dataset.index];}
@ -470,6 +504,7 @@ function autocomplete(inp,container,arr) {
inp.addEventListener("input", function(e) {
const MAXITEMS = 30;
var b, i, val = this.value;
console.log(val)
if (!val) { return false;}
currentFocus = -1;
let items = container.children;
@ -554,6 +589,7 @@ function autocomplete(inp,container,arr) {
currentFocus = -1;
}
closeAllLists();
lastVal = null;
}
});
function addActive(x) {

View file

@ -1,4 +1,4 @@
{"version":"1.0.37",
{"version":"1.0.38",
"name": "ebrowser",
"description": "The keyboard-friendly minimal suckless web browser",
"main": "webview.js",