Skip to content

Commit

Permalink
ebrowser 1.0.33
Browse files Browse the repository at this point in the history
  • Loading branch information
James Feng Cao committed Jun 24, 2024
1 parent 536ff07 commit 1577313
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 184 deletions.
116 changes: 0 additions & 116 deletions ebrowser.md

This file was deleted.

16 changes: 13 additions & 3 deletions en/ebrowserreadme/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ <h4 id="address-bar-commands">Address bar commands</h4>
<ul>
<li>ac [bookmark/history path w/o ext] : load &quot;.rec&quot; file for autocomplete.</li>
<li>b [bookmarkfilename w/o ext] : bookmark current page in file.</li>
<li>bjs : Browser-level JavaScript execution.</li>
<li>bml [filename w/o extension]: load/execute the javascript file.</li>
<li>cert : allow invalid certificates w/o arguments, otherwise restore to default.</li>
<li>clear : the arguments could be
Expand All @@ -109,8 +110,6 @@ <h4 id="address-bar-commands">Address bar commands</h4>
<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>js [js code] : execute JS code at OS level. Note: &quot;javascript:...&quot; is special url and thus works in the current web page, while &quot;:js ...&quot; commands can do any OS operations.</li>
<li>nc/uc : No Cookie forwarding/Use Cookie forwarding with global redirection.</li>
<li>nh/uh for No/Use url history.</li>
<li>nj/uj for No/Use external Javascript files.</li>
<li>nr/ur for No/Use &quot;redirect.json&quot; for domain redirection.</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>
Expand Down Expand Up @@ -144,9 +143,20 @@ <h4 id="configuration-files">Configuration files</h4>
<h4 id="javascript-at-three-levels">Javascript at three levels</h4>
<ul>
<li>Web page: urls like &quot;javascript:&quot; or bookmarklet command &quot;:bml&quot; run in web page.</li>
<li>Browser (or renderer process) : &quot;!xx&quot; evaluates &quot;xx.js&quot;, which could manipulate address bar etc.</li>
<li>Browser (or renderer process) :
<ul>
<li>&quot;:bjs&quot; to execute the following js code at browser level.</li>
<li>&quot;!xx&quot; evaluates &quot;xx.js&quot;, which could manipulate address bar etc.</li>
</ul>
</li>
<li>OS level (or main process) : &quot;:js&quot; to execute the following js code with all OS APIs available.</li>
</ul>
<h5 id="examples-for-jsbjs-commands">examples for &quot;:js&quot;/&quot;:bjs&quot; commands</h5>
<pre><code>:js bJS=true //allow external Javascript files for web pages
:js bJS=false //disallow external Javascript files for web pages
:bjs bHistory=true //to record url history
:bjs bQueryHistory=true //to record query/command history
</code></pre>
<h4 id="new-usages">New usages</h4>
<ul>
<li>
Expand Down
2 changes: 1 addition & 1 deletion en/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<description>Recent content on uweb browser: unlimited power</description>
<generator>Hugo</generator>
<language>en</language>
<lastBuildDate>Mon, 24 Jun 2024 10:28:02 +0800</lastBuildDate>
<lastBuildDate>Mon, 24 Jun 2024 19:36:44 +0800</lastBuildDate>
<atom:link href="/en/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Text selection/processing</title>
Expand Down
6 changes: 3 additions & 3 deletions en/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
/>
</url><url>
<loc>/en/</loc>
<lastmod>2024-06-24T10:28:02+08:00</lastmod>
<lastmod>2024-06-24T19:36:44+08:00</lastmod>
<xhtml:link
rel="alternate"
hreflang="zh"
Expand Down Expand Up @@ -508,7 +508,7 @@
/>
</url><url>
<loc>/en/ebrowserreadme/</loc>
<lastmod>2024-06-24T09:46:43+08:00</lastmod>
<lastmod>2024-06-24T19:36:44+08:00</lastmod>
</url><url>
<loc>/en/mirrors/</loc>
<lastmod>2024-06-18T23:17:17+08:00</lastmod>
Expand Down Expand Up @@ -539,7 +539,7 @@
/>
</url><url>
<loc>/en/unlist/</loc>
<lastmod>2024-06-24T10:28:02+08:00</lastmod>
<lastmod>2024-06-24T19:36:44+08:00</lastmod>
<xhtml:link
rel="alternate"
hreflang="zh"
Expand Down
14 changes: 11 additions & 3 deletions misc/ebrowser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Mirror urls could be used like ":update https://uwebzh.netlify.app/misc/ebrowser
- ":" for address bar commands
- ac [bookmark/history path w/o ext] : load ".rec" file for autocomplete.
- b [bookmarkfilename w/o ext] : bookmark current page in file.
- bjs : Browser-level JavaScript execution.
- bml [filename w/o extension]: load/execute the javascript file.
- cert : allow invalid certificates w/o arguments, otherwise restore to default.
- clear : the arguments could be
Expand All @@ -66,8 +67,6 @@ Mirror urls could be used like ":update https://uwebzh.netlify.app/misc/ebrowser
- 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.
- js [js code] : execute JS code at OS level. Note: "javascript:..." is special url and thus works in the current web page, while ":js ..." commands can do any OS operations.
- 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.
- nr/ur for No/Use "redirect.json" for domain redirection.
- 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".
Expand Down Expand Up @@ -97,9 +96,18 @@ The other commands are defined in "mapkeys.json", which will map keys to address

#### Javascript at three levels
- Web page: urls like "javascript:" or bookmarklet command ":bml" run in web page.
- Browser (or renderer process) : "!xx" evaluates "xx.js", which could manipulate address bar etc.
- Browser (or renderer process) :
- ":bjs" to execute the following js code at browser level.
- "!xx" evaluates "xx.js", which could manipulate address bar etc.
- OS level (or main process) : ":js" to execute the following js code with all OS APIs available.

##### examples for ":js"/":bjs" commands

:js bJS=true //allow external Javascript files for web pages
:js bJS=false //disallow external Javascript files for web pages
:bjs bHistory=true //to record url history
:bjs bQueryHistory=true //to record query/command history

#### New usages
- Vector designing with web tech to replace Adobe Illustrator/Inkscape.
- Design with web tech.
Expand Down
79 changes: 60 additions & 19 deletions misc/ebrowser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
}
.autocomplete-items div {
cursor: pointer;
background-color: #fff;
}
.autocomplete-items div:hover {
background-color: #e9e9e9;
Expand All @@ -65,8 +66,13 @@
var closedUrls = [];
var autocStrArray = [];
var defaultSE = "https://www.bing.com/search?q=%s";
var historyFile = path.join(__dirname,'history.rec');
var bHistory = false;
var bQueryHistory = false;
var autocMode = 0; //0 for substring, 1 for startsWith
const JSPREFIX_LOAD = "(async ()=>{let d=document;async function _loadJs(u){var a=d.createElement('script');a.type='text/javascript';a.async=false;a.src=u;d.body.appendChild(a);await new Promise(resolve=>a.onload=resolve)}";
const BML_md = JSPREFIX_LOAD + "await _loadJs('https://cdn.jsdelivr.net/npm/marked@12.0.2/marked.min.js');let b=d.body;b.innerHTML=marked.parse(b.textContent)})()";

let lastKeys;
let lastKeys_millis = 0;

Expand All @@ -78,7 +84,10 @@
initSearchEngines(jsonString,false);
});
fs.readFile(path.join(__dirname,'mapkeys.json'), 'utf8', (err, jsonStr) => {
if (err) return;
if (err) {
coloncommand(":js fetch2file(repositoryurl,'mapkeys.json')");
return;
}
try {
mapKeys = JSON.parse(jsonStr);
}catch(e){}
Expand Down Expand Up @@ -126,9 +135,24 @@
iTab = i;
tabs.children[iTab].classList.add('curWV');
}
function cbFinishLoad(e){
let tab = e.target;
let js = tab.dataset.jsonce;
if(js){
tab.dataset.jsonce = null;
tab.executeJavaScript(js,false);
}
if(!bHistory) return;
let histItem = tab.getTitle()+" "+tab.getURL()+"\n";
fs.appendFile(historyFile, histItem, (err) => {});
}
function initTab(tab){
tab.allowpopups = true;
tab.addEventListener('did-finish-load',cbFinishLoad);
}
function newTab(){
var tab = document.createElement('webview');
tab.allowpopups = true;
initTab(tab);
tabs.appendChild(tab);
}
function tabInc(num){
Expand Down Expand Up @@ -195,24 +219,36 @@
}
return;
}
SCROLL: do {
let h = -32;
switch(key){
case " ":
if(inputE === document.activeElement) return;
if(e.shiftKey){
h = -3*document.documentElement.clientHeight/4;
break;
}
case "PageDown":
tabs.children[iTab].src =
"javascript:window.scrollBy(0,3*document.documentElement.clientHeight/4)";
return;
h = 3*document.documentElement.clientHeight/4;
break;
case "PageUp":
tabs.children[iTab].src = "javascript:window.scrollBy(0,-3*document.documentElement.clientHeight/4)";
return;
h = -3*document.documentElement.clientHeight/4;
break;
case "ArrowDown":
if(inputE !== document.activeElement || 0==inputE.nextElementSibling.children.length)
tabs.children[iTab].src="javascript:window.scrollBy(0,32)";
return;
h = 32;
case "ArrowUp":
if(inputE !== document.activeElement || 0==inputE.nextElementSibling.children.length)
tabs.children[iTab].src="javascript:window.scrollBy(0,-32)";
return;

if(inputE === document.activeElement &&
0!==inputE.nextElementSibling.children.length)
return;
break;
default:
break SCROLL;
}
let js = `javascript:window.scrollBy(0,${h})`;
tabs.children[iTab].src = js;
return;
}while(false);

if(inputE === document.activeElement){
if (9===e.keyCode){//tab completion
}
Expand Down Expand Up @@ -269,6 +305,9 @@
case "b":
bookmark(args);
return;
case "bjs":
eval(cmd.slice(5));
return;
case "bml":
bml(args);
return;
Expand Down Expand Up @@ -375,15 +414,16 @@
}
}
var url=q;
NOREC: do{
do {
if(q.length>12){
let c6 = q.charCodeAt(6);
if(47===c6){// '/'
let c5 = q.charCodeAt(5);
if(47===c5 && 58===q.charCodeAt(4))//http/file urls
break;
break NOREC;
if(58===c5 && 47===q.charCodeAt(7))//https://
break;
break NOREC;
}else if(q.startsWith("javascript:")){
tabs.children[iTab].executeJavaScript(q.substring(11),false);
recQueryHistory(q);
Expand All @@ -398,14 +438,14 @@
}
if(q.indexOf('.')>0){
url = 'https://'+q;
break;
break NOREC;
}
url = defaultSE.replace('%s',q);
recQueryHistory(q);
break;
}
url = bang(q, iS);
recQueryHistory(q);
}while(false);
recQueryHistory(q);
}while(false);
tabs.children[iTab].src=url;
}
Expand Down Expand Up @@ -501,6 +541,7 @@
</div>
<script>
tabs = document.body.children[1];
initTab(tabs.children[0]);
{
let inp = document.forms[0].q;
autocomplete(inp,inp.nextElementSibling,autocStrArray);
Expand Down
Loading

0 comments on commit 1577313

Please sign in to comment.