mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
ebrowser 1.0.58
This commit is contained in:
parent
47777c299e
commit
e469cb1a87
22 changed files with 217 additions and 64 deletions
|
@ -4,7 +4,7 @@ Ebrowser is designed with the philosophy of [Android uweb browser](https://githu
|
|||
- 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](https://uweb.surge.sh/en/redirect/index.html#) to bypass censorship.
|
||||
- <a href="https://uweb.surge.sh/en/redirect/index.html#" onclick="if(notRepo()){location='../redirect/index.html#';return false;}">global redirection</a> to bypass censorship.
|
||||
- user CSS/JS at will. Ex. pressing "md" in no-focus mode to preview markdown file.
|
||||
- global CSS/JS for all sites at will.
|
||||
- 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.
|
||||
|
@ -92,15 +92,17 @@ The other commands are defined in "mapkeys.json", which will map keys to address
|
|||
|
||||
#### Configuration files
|
||||
- "config": lines of address bar commands.
|
||||
- "search.json": [search engines](https://jamesfengcao.gitlab.io/uweb/en/search/index.html) as shortcut-queryUrl pairs, where "%s" would be replaced by search query.
|
||||
- "search.json": <a href="https://jamesfengcao.gitlab.io/uweb/en/search/index.html" onclick="if(notRepo()){location='../search/index.html#';return false;}">search engines</a> as shortcut-queryUrl pairs, where "%s" would be replaced by search query.
|
||||
- "default.autoc": predefined strings for address bar auto completion.
|
||||
- "gredirect.json": global redirection urls as array of urls
|
||||
- "redirect.json": domain-replacementDomain pairs, default to be applied.
|
||||
- "mapkeys.json": keys-addressbarCommands pairs. The addressbar commands are multiple lines of address bar command separated by "\n".
|
||||
- "proxy.json": name-[ProxyConfig](https://www.electronjs.org/docs/latest/api/structures/proxy-config) pairs
|
||||
- "uas.json" : name-useragent pairs
|
||||
- "menu.json": array of strings for [user-defined menus](https://jamesfengcao.gitlab.io/uweb/en/urls/index.html). The array has submenu name and address bar commands alternately.
|
||||
- "download.json" : array of strings to define buttons for downloading dialog. The even-indexed strings are texts to show on the button. The odd-indexed strings are address bar commands with "%u" as the downloaded url.
|
||||
- "uas.json" : name-<a href="https://jamesfengcao.gitlab.io/uweb/en/useragents/index.html" onclick="if(notRepo()){location='../useragents/index.html#';return false;}">useragent</a> pairs.
|
||||
- Customized menus: json files as array of strings with menuitem name and address bar commands alternately.
|
||||
- "menu.json": array of strings for <a href="https://jamesfengcao.gitlab.io/uweb/en/urls/index.html" onclick="if(notRepo()){location='../urls/index.html#';return false;}">user-defined menus</a>. The array has submenu name and address bar commands alternately. The odd-indexed strings are address bar commands with "%u" as the downloaded url.
|
||||
- "select.json": to define menus for text selections. The odd-indexed strings are address bar commands with "%s" as the text selection.
|
||||
- "download.json" : array of strings to define context menu and buttons for downloading dialog. The even-indexed strings are texts to show on the button. The odd-indexed strings are address bar commands with "%u" as the downloaded url.
|
||||
|
||||
#### Javascript at three levels
|
||||
- Web page: url like "javascript:" or bookmarklet command ":bml" runs in web page.
|
||||
|
|
|
@ -345,8 +345,7 @@ You should have received a copy of the GNU General Public License along with thi
|
|||
setTimeout(()=>{
|
||||
if(lastKeys.length != keyLen) return;
|
||||
lastKeys = null;
|
||||
for(var cmd of cmds.split("\n"))
|
||||
handleQuery(cmd);
|
||||
handleQueries(cmds);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
@ -587,6 +586,10 @@ You should have received a copy of the GNU General Public License along with thi
|
|||
}
|
||||
}
|
||||
}
|
||||
function handleQueries(cmds){
|
||||
for(var cmd of cmds.split("\n"))
|
||||
handleQuery(cmd);
|
||||
}
|
||||
async function jsonAppend(filePath, charcode, str){
|
||||
let fd;
|
||||
try{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{"version":"1.0.57",
|
||||
{"version":"1.0.58",
|
||||
"name": "ebrowser",
|
||||
"description": "The keyboard-friendly minimal suckless web browser",
|
||||
"main": "webview.js",
|
||||
|
|
|
@ -52,6 +52,7 @@ var proxies = {};
|
|||
var proxy;
|
||||
var useragents = {};
|
||||
var downloadMenus; //[]
|
||||
var selectMenus = [];
|
||||
var defaultUA =
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/" +
|
||||
process.versions.chrome +" Safari/537.36";
|
||||
|
@ -125,6 +126,13 @@ async function createWindow () {
|
|||
}catch (e){console.log(e)}
|
||||
});
|
||||
|
||||
fs.readFile(path.join(__dirname,'select.json'), 'utf8', (err, jsonStr) => {
|
||||
if (err) return;
|
||||
try {
|
||||
selectMenus = JSON.parse(jsonStr);
|
||||
}catch (e){console.log(e)}
|
||||
});
|
||||
|
||||
win.webContents.on('page-title-updated',(event,cmd)=>{
|
||||
addrCommand(cmd);
|
||||
});
|
||||
|
@ -134,7 +142,7 @@ async function createWindow () {
|
|||
if(!downloadMenus) return;
|
||||
let buttons = ["OK", "Cancel", translate("Copy")];
|
||||
buttons.push(downloadMenus.filter((item, index) => (index&1) === 0));
|
||||
const button = dialog.showMessageBoxSync(mainWindow, {
|
||||
const button = dialog.showMessageBoxSync(win, {
|
||||
"type": "question",
|
||||
"title": translate("Download"),
|
||||
"message": `Do you want to download the file?`,
|
||||
|
@ -151,7 +159,7 @@ async function createWindow () {
|
|||
break;
|
||||
default:
|
||||
let cmd = downloadMenus[2*button-5].replace('%u',item.getURL());
|
||||
let js = `handleQuery(\`${cmd}\`)`;
|
||||
let js = `handleQueries(\`${cmd}\`)`;
|
||||
win.webContents.executeJavaScript(js,false);
|
||||
}
|
||||
e.preventDefault();
|
||||
|
@ -348,8 +356,20 @@ function cbWindowOpenHandler(details){
|
|||
function cbTitleUpdate(event,title){
|
||||
win.setTitle(title);
|
||||
}
|
||||
function menuSelection(menuTemplate, text){
|
||||
for(let i=0; i<selectMenus.length-1;i++){
|
||||
menuTemplate.push({
|
||||
label: selectMenus[i],
|
||||
click: () => {
|
||||
let cmd = selectMenus[i+1].replace('%s',text);
|
||||
let js = `handleQueries(\`${cmd}\`)`;
|
||||
win.webContents.executeJavaScript(js,false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function menuArray(labelprefix, linkUrl){
|
||||
const menuTemplate = [
|
||||
let menuTemplate = [
|
||||
{
|
||||
label: labelprefix+translate('Open'),
|
||||
click: () => {
|
||||
|
@ -375,7 +395,7 @@ function menuArray(labelprefix, linkUrl){
|
|||
label: labelprefix+downloadMenus[i],
|
||||
click: () => {
|
||||
let cmd = downloadMenus[i+1].replace('%u',linkUrl);
|
||||
let js = `handleQuery(\`${cmd}\`)`;
|
||||
let js = `handleQueries(\`${cmd}\`)`;
|
||||
win.webContents.executeJavaScript(js,false);
|
||||
}
|
||||
});
|
||||
|
@ -395,6 +415,8 @@ function onContextMenu(event, params){
|
|||
}else if((url=params.srcURL)){
|
||||
mTemplate.push({label:url,enabled:false});
|
||||
mTemplate.push.apply(mTemplate,menuArray("src: ",url));
|
||||
}else if((url=params.selectionText)){
|
||||
menuSelection(mTemplate,url);
|
||||
}else
|
||||
return;
|
||||
|
||||
|
@ -411,7 +433,7 @@ async function topMenu(){
|
|||
let submenu = [];
|
||||
for(let i=0;i<menus.length-1; i=i+2){
|
||||
let cmd = menus[i+1];
|
||||
let js = `handleQuery("${cmd}")`;
|
||||
let js = `handleQueries("${cmd}")`;
|
||||
submenu.push({
|
||||
label: menus[i], click: ()=>{
|
||||
win.webContents.executeJavaScript(js,false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue