updates ebrowser

This commit is contained in:
James Feng Cao 2024-06-15 11:36:06 +08:00
parent d0d745b7f5
commit 2cc5b79da4
11 changed files with 145 additions and 75 deletions

View file

@ -1,9 +1,11 @@
### [Ebrowser](https://github.com/torappinfo/ebrowser) as alternative to [uweb browser](https://github.com/torappinfo/uweb) ### [Ebrowser](https://github.com/torappinfo/ebrowser): keyboard-friendly minimal suckless web browser
Ebrowser is the minimal browser with the philosophy of [Android uweb browser](https://gitlab.com/jamesfengcao/uweb). Ebrowser is designed with the philosophy of [Android uweb browser](https://github.com/torappinfo/uweb) ([gitlab](https://gitlab.com/jamesfengcao/uweb)).
- lightweight (less than 20k bytes) without bundled electron. - lightweight (less than 20k bytes) without bundled electron.
- much less memory footprint than edge/chrome browser and highly performant. - much less memory footprint than edge/chrome browser and highly performant.
- keyboard (command line) friendly. - keyboard friendly with vim-style keymaps and command line support in address bar.
- global redirection to bypass censorship.
- user scripts at will. Ex. pressing "tr" to translate the page (need mapkeys.json config).
- customizable. - 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. 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.
@ -18,9 +20,11 @@ Run ebrowser
electron ~/node_modules/ebrowser electron ~/node_modules/ebrowser
#### Key shortcuts #### Key shortcuts
- CTRL+C: stop loading
- CTRL+G: address bar to show page url - CTRL+G: address bar to show page url
- CTRL+L: focus to address bar - CTRL+L: focus to address bar
- CTRL+T: new Tab - CTRL+T: new Tab
- CTRL+SHIFT+T: restore closed Tab
- CTRL+TAB: switch to next tab - CTRL+TAB: switch to next tab
- CTRL+SHIFT+TAB: switch to previous tab - CTRL+SHIFT+TAB: switch to previous tab
- CTRL+W: close Tab - CTRL+W: close Tab
@ -43,7 +47,9 @@ Run ebrowser
- cache : clear cache - cache : clear cache
- dns : clear dns cache - dns : clear dns cache
- storage: clear site storage data. - storage: clear site storage data.
- {[options](https://www.electronjs.org/docs/latest/api/session#sescleardataoptions)}
- ext [extension path]: load unpacked Chrome extension. - ext [extension path]: load unpacked Chrome extension.
- 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.
- nr/ur for No/Use "redirect.json" for domain redirection. - nr/ur for No/Use "redirect.json" for domain redirection.

View file

@ -43,12 +43,14 @@
<ul class="tags"> <ul class="tags">
</ul> </ul>
<h3 id="ebrowserhttpsgithubcomtorappinfoebrowser-as-alternative-to-uweb-browserhttpsgithubcomtorappinfouweb"><a href="https://github.com/torappinfo/ebrowser">Ebrowser</a> as alternative to <a href="https://github.com/torappinfo/uweb">uweb browser</a></h3> <h3 id="ebrowserhttpsgithubcomtorappinfoebrowser-keyboard-friendly-minimal-suckless-web-browser"><a href="https://github.com/torappinfo/ebrowser">Ebrowser</a>: keyboard-friendly minimal suckless web browser</h3>
<p>Ebrowser is the minimal browser with the philosophy of <a href="https://gitlab.com/jamesfengcao/uweb">Android uweb browser</a>.</p> <p>Ebrowser is designed with the philosophy of <a href="https://github.com/torappinfo/uweb">Android uweb browser</a> (<a href="https://gitlab.com/jamesfengcao/uweb">gitlab</a>).</p>
<ul> <ul>
<li>lightweight (less than 20k bytes) without bundled electron.</li> <li>lightweight (less than 20k bytes) without bundled electron.</li>
<li>much less memory footprint than edge/chrome browser and highly performant.</li> <li>much less memory footprint than edge/chrome browser and highly performant.</li>
<li>keyboard (command line) friendly.</li> <li>keyboard friendly with vim-style keymaps and command line support in address bar.</li>
<li>global redirection to bypass censorship.</li>
<li>user scripts at will. Ex. pressing &quot;tr&quot; to translate the page (need mapkeys.json config).</li>
<li>customizable.</li> <li>customizable.</li>
</ul> </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> <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>
@ -61,9 +63,11 @@
</code></pre> </code></pre>
<h4 id="key-shortcuts">Key shortcuts</h4> <h4 id="key-shortcuts">Key shortcuts</h4>
<ul> <ul>
<li>CTRL+C: stop loading</li>
<li>CTRL+G: address bar to show page url</li> <li>CTRL+G: address bar to show page url</li>
<li>CTRL+L: focus to address bar</li> <li>CTRL+L: focus to address bar</li>
<li>CTRL+T: new Tab</li> <li>CTRL+T: new Tab</li>
<li>CTRL+SHIFT+T: restore closed Tab</li>
<li>CTRL+TAB: switch to next tab</li> <li>CTRL+TAB: switch to next tab</li>
<li>CTRL+SHIFT+TAB: switch to previous tab</li> <li>CTRL+SHIFT+TAB: switch to previous tab</li>
<li>CTRL+W: close Tab</li> <li>CTRL+W: close Tab</li>
@ -89,9 +93,11 @@
<li>cache : clear cache</li> <li>cache : clear cache</li>
<li>dns : clear dns cache</li> <li>dns : clear dns cache</li>
<li>storage: clear site storage data.</li> <li>storage: clear site storage data.</li>
<li>{<a href="https://www.electronjs.org/docs/latest/api/session#sescleardataoptions">options</a>}</li>
</ul> </ul>
</li> </li>
<li>ext [extension path]: load unpacked Chrome extension.</li> <li>ext [extension path]: load unpacked Chrome extension.</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>
<li>nr/ur for No/Use &quot;redirect.json&quot; for domain redirection.</li> <li>nr/ur for No/Use &quot;redirect.json&quot; for domain redirection.</li>
@ -146,7 +152,7 @@
</ul> </ul>
</div> </div>
<p>Last Modified: 12 June 2024<br> <p>Last Modified: 15 June 2024<br>
<br> <br>
<pre></pre> <pre></pre>
</p> </p>

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>Wed, 12 Jun 2024 13:19:32 +0800</lastBuildDate> <lastBuildDate>Sat, 15 Jun 2024 09:56:42 +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>
@ -216,7 +216,7 @@
<link>/en/ebrowserreadme/</link> <link>/en/ebrowserreadme/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate> <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/en/ebrowserreadme/</guid> <guid>/en/ebrowserreadme/</guid>
<description>Ebrowser as alternative to uweb browser Ebrowser is the minimal browser with the philosophy of Android uweb browser.&#xA;lightweight (less than 20k bytes) without bundled electron. much less memory footprint than edge/chrome browser and highly performant. keyboard (command line) friendly. 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.&#xA;Install (for Windows, MacOS and Linux) Install ebrowser with nodejs installed</description> <description>Ebrowser: keyboard-friendly minimal suckless web browser Ebrowser is designed with the philosophy of Android uweb browser (gitlab).&#xA;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 &amp;quot;tr&amp;quot; to translate the page (need mapkeys.json config). customizable. Note: Usually electron apps are heavyweight as they use browsers for simple things.</description>
</item> </item>
<item> <item>
<title></title> <title></title>

View file

@ -71,7 +71,7 @@
/> />
</url><url> </url><url>
<loc>/en/</loc> <loc>/en/</loc>
<lastmod>2024-06-12T13:19:32+08:00</lastmod> <lastmod>2024-06-15T09:56:42+08:00</lastmod>
<xhtml:link <xhtml:link
rel="alternate" rel="alternate"
hreflang="zh" hreflang="zh"
@ -508,7 +508,7 @@
/> />
</url><url> </url><url>
<loc>/en/ebrowserreadme/</loc> <loc>/en/ebrowserreadme/</loc>
<lastmod>2024-06-12T13:19:32+08:00</lastmod> <lastmod>2024-06-15T09:56:42+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-04-06T10:20:49+08:00</lastmod>
@ -539,7 +539,7 @@
/> />
</url><url> </url><url>
<loc>/en/unlist/</loc> <loc>/en/unlist/</loc>
<lastmod>2024-06-12T13:19:32+08:00</lastmod> <lastmod>2024-06-15T09:56:42+08:00</lastmod>
<xhtml:link <xhtml:link
rel="alternate" rel="alternate"
hreflang="zh" hreflang="zh"

View file

@ -12,7 +12,7 @@
<link>/en/ebrowserreadme/</link> <link>/en/ebrowserreadme/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate> <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/en/ebrowserreadme/</guid> <guid>/en/ebrowserreadme/</guid>
<description>Ebrowser as alternative to uweb browser Ebrowser is the minimal browser with the philosophy of Android uweb browser.&#xA;lightweight (less than 20k bytes) without bundled electron. much less memory footprint than edge/chrome browser and highly performant. keyboard (command line) friendly. 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.&#xA;Install (for Windows, MacOS and Linux) Install ebrowser with nodejs installed</description> <description>Ebrowser: keyboard-friendly minimal suckless web browser Ebrowser is designed with the philosophy of Android uweb browser (gitlab).&#xA;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 &amp;quot;tr&amp;quot; to translate the page (need mapkeys.json config). customizable. Note: Usually electron apps are heavyweight as they use browsers for simple things.</description>
</item> </item>
<item> <item>
<title></title> <title></title>

View file

@ -28,7 +28,8 @@ Copyright (C) 2024 Richard Hao Cao
var tabs; var tabs;
var engines = {}; var engines = {};
var mapKeys = {}; var mapKeys = {};
var defaultSE = "https://www.bing.com/search?q="; var closedUrls = [];
var defaultSE = "https://www.bing.com/search?q=%s";
let lastKeys; let lastKeys;
let lastKeys_millis = 0; let lastKeys_millis = 0;
@ -108,6 +109,7 @@ Copyright (C) 2024 Richard Hao Cao
let nTabs = tabs.children.length; let nTabs = tabs.children.length;
if(nTabs<2) return "";//no remain tab if(nTabs<2) return "";//no remain tab
let tab = tabs.children[iTab]; let tab = tabs.children[iTab];
closedUrls.push(tab.getURL());
if(document.activeElement == tab) tab.blur(); if(document.activeElement == tab) tab.blur();
tabs.removeChild(tab); tabs.removeChild(tab);
nTabs--; nTabs--;
@ -210,13 +212,16 @@ Copyright (C) 2024 Richard Hao Cao
} }
function getQ(){return document.forms[0].q.value;} function getQ(){return document.forms[0].q.value;}
function bang(query, iSpace){ function bang(query, iSpace){
let se=defaultSE;
if(iSpace>0){ if(iSpace>0){
let name = query.slice(0,iSpace); let name = query.slice(0,iSpace);
let engine = engines[name]; let engine = engines[name];
if(engine) if(engine){
return engine+query.substring(iSpace+1); se = engine;
query = query.substring(iSpace+1);
}
} }
return defaultSE+query; return se.replace('%s',query);
} }
function coloncommand(q){ function coloncommand(q){
document.title = q; document.title = q;

View file

@ -2,7 +2,8 @@
*/ */
const { const {
app, BrowserWindow, Menu, shell, clipboard, app, BrowserWindow, Menu, shell, clipboard,
session, protocol, net} = require('electron') session, protocol, net, dialog
} = require('electron')
let win; let win;
if(!app.requestSingleInstanceLock()) if(!app.requestSingleInstanceLock())
@ -10,7 +11,6 @@ if(!app.requestSingleInstanceLock())
else { else {
app.on('ready', createWindow); app.on('ready', createWindow);
app.on('second-instance', (event, args, cwd) => { app.on('second-instance', (event, args, cwd) => {
// 当已经有运行的实例时,我们激活窗口而不是创建新的窗口
if (win) { if (win) {
if (win.isMinimized()) { if (win.isMinimized()) {
win.restore() win.restore()
@ -34,6 +34,7 @@ var redirects;
var bRedirect = true; var bRedirect = true;
var bJS = true; var bJS = true;
var bHistory = false; var bHistory = false;
var bForwardCookie = false;
var proxies = {}; var proxies = {};
var proxy; var proxy;
var useragents = {}; var useragents = {};
@ -47,14 +48,14 @@ fs.readFile(path.join(__dirname,'redirect.json'), 'utf8', (err, jsonString) => {
if (err) return; if (err) return;
try { try {
redirects = JSON.parse(jsonString); redirects = JSON.parse(jsonString);
} catch (e){} } catch (e){console.log(e)}
}); });
async function createWindow () { async function createWindow () {
let json = await fs.promises.readFile(path.join(__dirname,'uas.json'), 'utf8'); let json = await fs.promises.readFile(path.join(__dirname,'uas.json'), 'utf8');
try { try {
useragents = JSON.parse(json); useragents = JSON.parse(json);
} catch (e){} } catch (e){console.log(e)}
await (async ()=>{ await (async ()=>{
try{ try{
@ -65,7 +66,7 @@ async function createWindow () {
for await (const line of readInterface) { for await (const line of readInterface) {
addrCommand(line); addrCommand(line);
} }
}catch(e){return;} }catch(e){console.log(e);}
})(); })();
win = new BrowserWindow( win = new BrowserWindow(
@ -85,7 +86,7 @@ async function createWindow () {
if (err) return; if (err) return;
try { try {
gredirects = JSON.parse(jsonString); gredirects = JSON.parse(jsonString);
} catch (e){} } catch (e){console.log(e)}
}); });
fs.readFile(path.join(__dirname,'proxy.json'), 'utf8', (err, jsonString) => { fs.readFile(path.join(__dirname,'proxy.json'), 'utf8', (err, jsonString) => {
@ -97,7 +98,7 @@ async function createWindow () {
} }
return val; return val;
}); });
} catch (e){} } catch (e){console.log(e)}
}); });
cmdlineProcess(process.argv, process.cwd(), 0); cmdlineProcess(process.argv, process.cwd(), 0);
@ -108,7 +109,6 @@ async function createWindow () {
}); });
win.webContents.on('console-message',cbConsoleMsg); win.webContents.on('console-message',cbConsoleMsg);
//protocol.handle("https",cbScheme_https);
} }
app.on('window-all-closed', function () { app.on('window-all-closed', function () {
@ -154,6 +154,7 @@ function addrCommand(cmd){
return; return;
case "clear": case "clear":
if(args.length==1){ if(args.length==1){
session.defaultSession.clearData();
return; return;
} }
switch(args[1]){ switch(args[1]){
@ -166,11 +167,27 @@ function addrCommand(cmd){
case "storage": case "storage":
session.defaultSession.clearStorageData(); session.defaultSession.clearStorageData();
return; return;
default:
try {
let opts = JSON.parse(args.slice(1).join(""));
session.defaultSession.clearData(opts);
}catch(e){console.log(e)}
} }
return; return;
case "ext": case "ext":
session.defaultSession.loadExtension(args[1]); session.defaultSession.loadExtension(args[1]);
return; return;
case "nc":
bForwardCookie = false;
msgbox_info("Cookie forwarding disabled");
return;
case "uc":
if(bForwardCookie) {
msgbox_info("Cookie forwarding enabled for global redirection");
return;
}
forwardCookie();
return;
case "nh": case "nh":
bHistory = false; return; bHistory = false; return;
case "uh": case "uh":
@ -230,37 +247,7 @@ function interceptRequest(details, callback){
return; return;
} }
do { do {
if(gredirect){ if(gredirect || !bRedirect ||(details.resourceType !== 'mainFrame' &&
if(!details.url.startsWith("http")) break;
if(!details.url.startsWith(gredirect)){
if(details.resourceType === 'mainFrame'){
let wc = details.webContents;
let url = details.url;
if(wc){
let nUrl = gredirect+url;
fetch(nUrl).then(res=>{
if(res.ok) return res.arrayBuffer();
throw new Error(`Err: ${res.status} - ${res.statusText}`);
}).then(aBuf=>{
const u8 = new Uint8Array(aBuf);
const b64 = Buffer.from (u8).toString('base64');
const dataUrl = `data:text/html;base64,${b64}`;
wc.loadURL(dataUrl,{baseURLForDataURL:url});
}).catch(e=>{
console.log(nUrl+" err:",e);
});
callback({ cancel: true });
return;
}
}
let newUrl = gredirect + details.url;
callback({ cancel: false, redirectURL: newUrl });
return;
}
break;
}
if(!bRedirect ||(details.resourceType !== 'mainFrame' &&
details.resourceType !== 'subFrame')) break; details.resourceType !== 'subFrame')) break;
let oURL = new URL(details.url); let oURL = new URL(details.url);
let domain = oURL.hostname; let domain = oURL.hostname;
@ -338,59 +325,71 @@ function topMenu(){
{ {
label: '', label: '',
submenu: [ submenu: [
{ label: '', accelerator: 'Ctrl+G', click: ()=>{ { label: 'Stop', accelerator: 'Ctrl+C', click: ()=>{
let js="tabs.children[iTab].stop()"
win.webContents.executeJavaScript(js,false)
}},
{ label: 'getURL', accelerator: 'Ctrl+G', click: ()=>{
let js="{let q=document.forms[0].q;q.focus();q.value=tabs.children[iTab].src}" let js="{let q=document.forms[0].q;q.focus();q.value=tabs.children[iTab].src}"
win.webContents.executeJavaScript(js,false) win.webContents.executeJavaScript(js,false)
}}, }},
{ label: '', accelerator: 'Ctrl+L', click:()=>{ { label: 'Select', accelerator: 'Ctrl+L', click:()=>{
win.webContents.executeJavaScript("document.forms[0].q.select()",false); win.webContents.executeJavaScript("document.forms[0].q.select()",false);
}}, }},
{ label: '', accelerator: 'Ctrl+T', click:()=>{ { label: 'New Tab', accelerator: 'Ctrl+T', click:()=>{
let js = "newTab();document.forms[0].q.select();switchTab(tabs.children.length-1)"; let js = "newTab();document.forms[0].q.select();switchTab(tabs.children.length-1)";
win.webContents.executeJavaScript(js,false); win.webContents.executeJavaScript(js,false);
}}, }},
{ label: '', accelerator: 'Ctrl+R', click: ()=>{ { label: 'Restore Tab', accelerator: 'Ctrl+Shift+T', click:()=>{
gredirect=null; let js = "{let u=closedUrls.pop();if(u){newTab();switchTab(tabs.children.length-1);tabs.children[iTab].src=u}}";
win.webContents.executeJavaScript(js,false);
}}, }},
{ label: '', accelerator: 'Ctrl+Shift+R', click: ()=>{ { label: 'No redirect', accelerator: 'Ctrl+R', click: ()=>{
if(gredirect){
gredirect=null;
unregisterHandler();
}
}},
{ label: 'Redirect', accelerator: 'Ctrl+Shift+R', click: ()=>{
if(0==gredirects.length) return; if(0==gredirects.length) return;
if(!gredirect) registerHandler();
gredirect=gredirects[0]; gredirect=gredirects[0];
}}, }},
{ label: '', accelerator: 'Ctrl+W', click: ()=>{ { label: 'Close', accelerator: 'Ctrl+W', click: ()=>{
win.webContents.executeJavaScript("tabClose()",false).then((r)=>{ win.webContents.executeJavaScript("tabClose()",false).then((r)=>{
if(""===r) win.close(); if(""===r) win.close();
else win.setTitle(r); else win.setTitle(r);
}); });
}}, }},
{ label: '', accelerator: 'Ctrl+Tab', click: ()=>{ { label: 'Next Tab', accelerator: 'Ctrl+Tab', click: ()=>{
let js="tabInc(1);getWinTitle()"; let js="tabInc(1);getWinTitle()";
win.webContents.executeJavaScript(js,false).then((r)=>{ win.webContents.executeJavaScript(js,false).then((r)=>{
win.setTitle(r); win.setTitle(r);
}); });
}}, }},
{ label: '', accelerator: 'Ctrl+Shift+Tab', click: ()=>{ { label: 'Previous Tab', accelerator: 'Ctrl+Shift+Tab', click: ()=>{
let js="tabDec(-1);getWinTitle()"; let js="tabDec(-1);getWinTitle()";
win.webContents.executeJavaScript(js,false).then((r)=>{ win.webContents.executeJavaScript(js,false).then((r)=>{
win.setTitle(r); win.setTitle(r);
}); });
}}, }},
{ label: '', accelerator: 'Ctrl+Left', click: ()=>{ { label: 'Go backward', accelerator: 'Ctrl+Left', click: ()=>{
let js="tabs.children[iTab].goBack()"; let js="tabs.children[iTab].goBack()";
win.webContents.executeJavaScript(js,false); win.webContents.executeJavaScript(js,false);
}}, }},
{ label: '', accelerator: 'Ctrl+Right', click: ()=>{ { label: 'Go forward', accelerator: 'Ctrl+Right', click: ()=>{
let js="tabs.children[iTab].goForward()"; let js="tabs.children[iTab].goForward()";
win.webContents.executeJavaScript(js,false); win.webContents.executeJavaScript(js,false);
}}, }},
{ label: '', accelerator: 'Esc', click: ()=>{ { label: 'No focus', accelerator: 'Esc', click: ()=>{
let js = `{let e=document.activeElement; let js = `{let e=document.activeElement;
if(e)e.blur();try{tabs.children[iTab].stopFindInPage('clearSelection')}catch(er){}}`; if(e)e.blur();try{tabs.children[iTab].stopFindInPage('clearSelection')}catch(er){}}`;
win.webContents.executeJavaScript(js,false); win.webContents.executeJavaScript(js,false);
}}, }},
{ label: '', accelerator: 'F5', click: ()=>{ { label: 'Reload', accelerator: 'F5', click: ()=>{
win.webContents.executeJavaScript("tabs.children[iTab].reload()",false); win.webContents.executeJavaScript("tabs.children[iTab].reload()",false);
}}, }},
{ label: '', accelerator: 'F12', click: ()=>{ { label: 'Devtools', accelerator: 'F12', click: ()=>{
let js = "try{tabs.children[iTab].openDevTools()}catch(e){console.log(e)}"; let js = "try{tabs.children[iTab].openDevTools()}catch(e){console.log(e)}";
win.webContents.executeJavaScript(js,false); win.webContents.executeJavaScript(js,false);
}}, }},
@ -419,3 +418,57 @@ function cmdlineProcess(argv,cwd,extra){
win.setTitle(url); win.setTitle(url);
} }
} }
async function cbScheme_redir(req){
if(!gredirect) return null;
let oUrl = req.url;
let newurl = gredirect+oUrl;
let options = {
body: req.body,
headers: req.headers,
method: req.method,
referer: req.referer,
duplex: "half",
bypassCustomProtocolHandlers: true
};
if(bForwardCookie){
let cookies = await session.defaultSession.cookies.get({url: oUrl});
let cookieS = cookies.map (cookie => cookie.name + '=' + cookie.value ).join(';');
options.headers['Cookie'] = cookieS;
}
return fetch(newurl, options);
}
function registerHandler(){
protocol.handle("http",cbScheme_redir);
protocol.handle("https",cbScheme_redir);
protocol.handle("ws",cbScheme_redir);
protocol.handle("wss",cbScheme_redir);
}
function unregisterHandler(){
protocol.unhandle("http",cbScheme_redir);
protocol.unhandle("https",cbScheme_redir);
protocol.unhandle("ws",cbScheme_redir);
protocol.unhandle("wss",cbScheme_redir);
}
function forwardCookie(){
const choice = dialog.showMessageBoxSync(null, {
type: 'warning',
title: 'Confirm cookie forwarding with global redirection',
message: 'Cookies are used to access your account. Forwarding cookies is vulnerable to global redirection server, proceed to enable cookie forwarding with global redirection?',
buttons: ['No','Yes']
})
if(1===choice) bForwardCookie=true;
}
function msgbox_info(msg){
dialog.showMessageBoxSync(null, {
type: 'info',
title: msg,
message: msg,
buttons: ['OK']
})
}

View file

@ -4,7 +4,7 @@
<sitemap> <sitemap>
<loc>/en/sitemap.xml</loc> <loc>/en/sitemap.xml</loc>
<lastmod>2024-06-12T13:19:32+08:00</lastmod> <lastmod>2024-06-15T09:56:42+08:00</lastmod>
</sitemap> </sitemap>

View file

@ -78,7 +78,7 @@ AI/chatGPT:</p>
</div> </div>
<p>Last Modified: 12 June 2024<br> <p>Last Modified: 12 June 2024<br>
remove google translation in China<br> markdown rjs to use marked<br>
<pre></pre> <pre></pre>
</p> </p>

View file

@ -120,7 +120,7 @@
</div> </div>
<p>Last Modified: 13 June 2024<br> <p>Last Modified: 13 June 2024<br>
remove google translation in China<br> markdown rjs to use marked<br>
<pre></pre> <pre></pre>
</p> </p>

View file

@ -72,7 +72,7 @@
</div> </div>
<p>Last Modified: 13 June 2024<br> <p>Last Modified: 13 June 2024<br>
remove google translation in China<br> markdown rjs to use marked<br>
<pre></pre> <pre></pre>
</p> </p>