mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
ebrowser 1.0.45: sitejs/sitecss support
This commit is contained in:
parent
e28838f738
commit
6fc7d22514
12 changed files with 64 additions and 27 deletions
|
@ -60,10 +60,3 @@
|
|||
- 网页矢量长截屏,允许通过mermaid等设计矢量图案。
|
||||
- 可用网页设计代替Adobe Illustrator平面设计。
|
||||
- 完全开源,共同探索浏览新技术。
|
||||
- nodejs 下安装:
|
||||
|
||||
npm install ebrowser
|
||||
|
||||
- nodejs 下运行:
|
||||
|
||||
electron ~/node_modules/ebrowser
|
|
@ -60,10 +60,3 @@
|
|||
- 网页矢量长截屏,允许通过mermaid等设计矢量图案。
|
||||
- 可用网页设计代替Adobe Illustrator平面设计。
|
||||
- 完全开源,共同探索浏览新技术。
|
||||
- nodejs 下安装:
|
||||
|
||||
npm install ebrowser
|
||||
|
||||
- nodejs 下运行:
|
||||
|
||||
electron ~/node_modules/ebrowser
|
|
@ -51,6 +51,7 @@
|
|||
<li>keyboard friendly with vim-style keymaps and command line support in address bar.</li>
|
||||
<li><a href="https://uweb.surge.sh/en/redirect/index.html#">global redirection</a> to bypass censorship.</li>
|
||||
<li>user scripts at will. Ex. pressing "md" in no-focus mode to preview markdown file.</li>
|
||||
<li>CSS/JS for domains, similar to <a href="https://jamesfengcao.gitlab.io/uweb/en/sitejs/index.html">uweb</a>, but use sitejs/[domain].js or sitecss/[domain].css, not [domain root].js/css.</li>
|
||||
<li>customizable.</li>
|
||||
</ul>
|
||||
<p>Note: Usually electron apps are heavyweight as they use browsers for simple things. Ebrowser uses core chromium effectively and very lightweight. Recommend to install electron separately.</p>
|
||||
|
@ -149,7 +150,7 @@ npm install ebrowser
|
|||
</ul>
|
||||
<h4 id="javascript-at-three-levels">Javascript at three levels</h4>
|
||||
<ul>
|
||||
<li>Web page: urls like "javascript:" or bookmarklet command ":bml" run in web page.</li>
|
||||
<li>Web page: url like "javascript:" or bookmarklet command ":bml" runs in web page.</li>
|
||||
<li>Browser (or renderer process) :
|
||||
<ul>
|
||||
<li>":bjs" to execute the following js code at browser level.</li>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<description>Recent content on uweb browser: unlimited power</description>
|
||||
<generator>Hugo</generator>
|
||||
<language>en</language>
|
||||
<lastBuildDate>Sat, 29 Jun 2024 08:47:08 +0800</lastBuildDate>
|
||||
<lastBuildDate>Sat, 29 Jun 2024 21:05:42 +0800</lastBuildDate>
|
||||
<atom:link href="/en/index.xml" rel="self" type="application/rss+xml" />
|
||||
<item>
|
||||
<title>Text selection/processing</title>
|
||||
|
@ -216,7 +216,7 @@
|
|||
<link>/en/ebrowserreadme/</link>
|
||||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||||
<guid>/en/ebrowserreadme/</guid>
|
||||
<description>Ebrowser: keyboard-friendly minimal suckless web browser Ebrowser is designed with the philosophy of Android uweb browser (gitlab).
lightweight (less than 20k bytes) without bundled electron. much less memory footprint than edge/chrome browser and highly performant. keyboard friendly with vim-style keymaps and command line support in address bar. global redirection to bypass censorship. user scripts at will. Ex. pressing &quot;md&quot; in no-focus mode to preview markdown file. customizable. Note: Usually electron apps are heavyweight as they use browsers for simple things.</description>
|
||||
<description>Ebrowser: keyboard-friendly minimal suckless web browser Ebrowser is designed with the philosophy of Android uweb browser (gitlab).
lightweight (less than 20k bytes) without bundled electron. much less memory footprint than edge/chrome browser and highly performant. keyboard friendly with vim-style keymaps and command line support in address bar. global redirection to bypass censorship. user scripts at will. Ex. pressing &quot;md&quot; in no-focus mode to preview markdown file. CSS/JS for domains, similar to uweb, but use sitejs/[domain].</description>
|
||||
</item>
|
||||
<item>
|
||||
<title></title>
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
/>
|
||||
</url><url>
|
||||
<loc>/en/</loc>
|
||||
<lastmod>2024-06-29T08:47:08+08:00</lastmod>
|
||||
<lastmod>2024-06-29T21:05:42+08:00</lastmod>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="zh"
|
||||
|
@ -508,7 +508,7 @@
|
|||
/>
|
||||
</url><url>
|
||||
<loc>/en/ebrowserreadme/</loc>
|
||||
<lastmod>2024-06-29T08:47:08+08:00</lastmod>
|
||||
<lastmod>2024-06-29T21:05:42+08:00</lastmod>
|
||||
</url><url>
|
||||
<loc>/en/mirrors/</loc>
|
||||
<lastmod>2024-06-18T23:17:17+08:00</lastmod>
|
||||
|
@ -539,7 +539,7 @@
|
|||
/>
|
||||
</url><url>
|
||||
<loc>/en/unlist/</loc>
|
||||
<lastmod>2024-06-29T08:47:08+08:00</lastmod>
|
||||
<lastmod>2024-06-29T21:05:42+08:00</lastmod>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="zh"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<link>/en/ebrowserreadme/</link>
|
||||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||||
<guid>/en/ebrowserreadme/</guid>
|
||||
<description>Ebrowser: keyboard-friendly minimal suckless web browser Ebrowser is designed with the philosophy of Android uweb browser (gitlab).
lightweight (less than 20k bytes) without bundled electron. much less memory footprint than edge/chrome browser and highly performant. keyboard friendly with vim-style keymaps and command line support in address bar. global redirection to bypass censorship. user scripts at will. Ex. pressing &quot;md&quot; in no-focus mode to preview markdown file. customizable. Note: Usually electron apps are heavyweight as they use browsers for simple things.</description>
|
||||
<description>Ebrowser: keyboard-friendly minimal suckless web browser Ebrowser is designed with the philosophy of Android uweb browser (gitlab).
lightweight (less than 20k bytes) without bundled electron. much less memory footprint than edge/chrome browser and highly performant. keyboard friendly with vim-style keymaps and command line support in address bar. global redirection to bypass censorship. user scripts at will. Ex. pressing &quot;md&quot; in no-focus mode to preview markdown file. CSS/JS for domains, similar to uweb, but use sitejs/[domain].</description>
|
||||
</item>
|
||||
<item>
|
||||
<title></title>
|
||||
|
|
|
@ -6,6 +6,7 @@ Ebrowser is designed with the philosophy of [Android uweb browser](https://githu
|
|||
- keyboard friendly with vim-style keymaps and command line support in address bar.
|
||||
- [global redirection](https://uweb.surge.sh/en/redirect/index.html#) to bypass censorship.
|
||||
- user scripts at will. Ex. pressing "md" in no-focus mode to preview markdown file.
|
||||
- CSS/JS for domains, similar to [uweb](https://jamesfengcao.gitlab.io/uweb/en/sitejs/index.html), but use sitejs/[domain].js or sitecss/[domain].css, not [domain root].js/css.
|
||||
- customizable.
|
||||
|
||||
Note: Usually electron apps are heavyweight as they use browsers for simple things. Ebrowser uses core chromium effectively and very lightweight. Recommend to install electron separately.
|
||||
|
@ -99,7 +100,7 @@ The other commands are defined in "mapkeys.json", which will map keys to address
|
|||
- "uas.json" : name-useragent pairs
|
||||
|
||||
#### Javascript at three levels
|
||||
- Web page: urls like "javascript:" or bookmarklet command ":bml" run in web page.
|
||||
- Web page: url like "javascript:" or bookmarklet command ":bml" runs in web page.
|
||||
- Browser (or renderer process) :
|
||||
- ":bjs" to execute the following js code at browser level.
|
||||
- "!xx" evaluates "xx.js", which could manipulate address bar etc.
|
||||
|
|
|
@ -69,6 +69,10 @@ You should have received a copy of the GNU General Public License along with thi
|
|||
var historyFile = path.join(__dirname,'history.rec');
|
||||
var bHistory = false;
|
||||
var bQueryHistory = false;
|
||||
let sitecssP = path.join(__dirname,"sitecss");
|
||||
let sitejsP = path.join(__dirname,"sitejs");
|
||||
var bDomainJS = fs.existsSync(sitejsP);
|
||||
var bDomainCSS = fs.existsSync(sitecssP);
|
||||
var autocMode = 0; //0 for substring, 1 for startsWith
|
||||
const BML_head = "(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_tail = "})()";
|
||||
|
@ -136,20 +140,52 @@ You should have received a copy of the GNU General Public License along with thi
|
|||
iTab = i;
|
||||
tabs.children[iTab].classList.add('curWV');
|
||||
}
|
||||
async function loadJSFile(tab,jsF){
|
||||
if(fs.existsSync(jsF)){
|
||||
try {
|
||||
let js = await fs.promises.readFile(jsF,'utf8');
|
||||
tab.executeJavaScript(js,false);
|
||||
}catch(e){}
|
||||
}
|
||||
}
|
||||
function cbStartLoading(e){
|
||||
if(!bDomainCSS) return;
|
||||
let tab = e.target;
|
||||
let domain = new URL(tab.getURL()).hostname;
|
||||
let jsF = path.join(sitecssP, domain+".js");
|
||||
loadJSFile(tab,jsF);
|
||||
jsF = path.join(sitecssP, domain+".css");
|
||||
if(fs.existsSync(jsF)){
|
||||
(async ()=>{
|
||||
try {
|
||||
let css = await fs.promises.readFile(jsF,'utf8');
|
||||
tab.insertCSS(css);
|
||||
}catch(e){}
|
||||
})();
|
||||
}
|
||||
}
|
||||
function cbFinishLoad(e){
|
||||
let tab = e.target;
|
||||
let url = tab.getURL();
|
||||
if(bHistory){
|
||||
let histItem = tab.getTitle()+" "+url+"\n";
|
||||
fs.appendFile(historyFile, histItem, (err) => {});
|
||||
}
|
||||
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) => {});
|
||||
if(bDomainJS){
|
||||
let domain = new URL(url).hostname;
|
||||
let jsF = path.join(sitejsP, domain+".js");
|
||||
loadJSFile(tab,jsF);
|
||||
}
|
||||
}
|
||||
function initTab(tab){
|
||||
tab.allowpopups = true;
|
||||
tab.addEventListener('did-finish-load',cbFinishLoad);
|
||||
tab.addEventListener('did-start-loading',cbStartLoading);
|
||||
}
|
||||
function newTab(){
|
||||
var tab = document.createElement('webview');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{"version":"1.0.44",
|
||||
{"version":"1.0.45",
|
||||
"name": "ebrowser",
|
||||
"description": "The keyboard-friendly minimal suckless web browser",
|
||||
"main": "webview.js",
|
||||
|
|
1
misc/ebrowser/sitecss/baidu.com.css
Normal file
1
misc/ebrowser/sitecss/baidu.com.css
Normal file
|
@ -0,0 +1 @@
|
|||
.ec_wise_ad,.ec_wise_pp,.na-like-container{transform:scale(0)!important;display:none!important}
|
12
misc/ebrowser/sitejs/mypikpak.net.js
Normal file
12
misc/ebrowser/sitejs/mypikpak.net.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
(function() {
|
||||
const originFetch = fetch;
|
||||
window.fetch = (...arg) => {
|
||||
if (arg[0].indexOf('area_accessible') > -1) {
|
||||
return new Promise(() => {
|
||||
throw new Error();
|
||||
});
|
||||
} else {
|
||||
return originFetch(...arg);
|
||||
}
|
||||
}
|
||||
})();
|
|
@ -4,7 +4,7 @@
|
|||
<sitemap>
|
||||
<loc>/en/sitemap.xml</loc>
|
||||
|
||||
<lastmod>2024-06-29T08:47:08+08:00</lastmod>
|
||||
<lastmod>2024-06-29T21:05:42+08:00</lastmod>
|
||||
|
||||
</sitemap>
|
||||
|
||||
|
|
Loading…
Reference in a new issue