please help me.
var UserConfig, isNew, theme;
UserConfig = 'profile';
isNew = app.LoadBoolean('isNewUser', true, 'UserConfig');
var tabCounter = 0;
var tabs = [];
var tabNames = [];
function OnStart() {
theme = app.LoadText('myTheme', 'Dark')
app.InitializeUIKit(MUI.colors.blue.darken2, theme);
if (isNew === true) NewUser();
else AddNewTab();
}
function NewUser() {
layWelcome = MUI.CreateLayout('Absolute', 'FillXY')
logo = app.CreateImage("Img/icon.png", 0.4, -1)
logo.SetPosition(0.3, 0.2)
layWelcome.AddChild(logo)
let newmsg = "Welcome To Asteroid Browser, By Using Our Browser, You Aggree To T & C's.";
Message = app.CreateText(newmsg, 1, 1, 'Monospace,Multiline')
Message.SetOnTouch(ShowTerms)
Message.SetPosition(0, 0.6)
layWelcome.AddChild(Message)
AgreeBtn = MUI.CreateButtonContained('Agree', 0.4, 0.1)
AgreeBtn.SetPosition(0.3, 0.8)
AgreeBtn.SetOnTouch(AcceptedTerms)
layWelcome.AddChild(AgreeBtn)
app.AddLayout(layWelcome)
}
function ShowTerms() {
app.OpenUrl('
https://asteroid.data.blog/2022/12/25/end-user-license-aggreement-eula/')
}
function AcceptedTerms() {
app.SaveBoolean('isNewUser', false, 'UserConfig') || Main();
}
function AddNewTab() {
if (app.GetOrientation() === 'Landscape') {
app.SetOrientation('Portrait')
}
if (theme === 'Light'){
app.SetStatusBarColor('black');
}
if (theme === 'Dark'){
app.SetStatusBarColor('#121212');
}
lay = app.CreateLayout('Absolute', 'VCenter,Vertical,FillXY')
layHome = MUI.CreateLayout('Absolute', 'VCenter,Vertical,FillXY')
layHome.SetPosition(0, 0, 1, 0.93)
lay.SetOrientation('Portrait')
logo = app.CreateImage("Img/icon.png", 0.5, -1)
logo.SetPosition(0.25, 0.05)
searchbx = MUI.CreateTextEditSearch(0.85, "Left", "Search Or Enter Address")
searchbx.SetOnEnter(FindQuery)
searchbx.SetPosition(0.07, 0.3)
if (isUrl(app.GetClipboardText())) {
CpdBtn = MUI.CreateButtonOutlined('Copied Link')
CpdBtn.SetPosition(0.07, 0.42)
CpdBtn.SetOnTouch(FastQuery)
layHome.AddChild(CpdBtn)
}
if (isText(app.GetClipboardText()) && isUrl(app.GetClipboardText()) === false) {
CpdBtn = MUI.CreateButtonOutlined('Copied Text')
CpdBtn.SetPosition(0.07, 0.42)
CpdBtn.SetOnTouch(FastQuery)
layHome.AddChild(CpdBtn)
}
AIBtn = MUI.CreateButtonOutlined('Hayzhel AI')
AIBtn.SetPosition(0.42, 0.42)
AIBtn.SetOnTouch(notAvailable)
layHome.AddChild(AIBtn)
barcodeSearch = MUI.CreateButtonOutlined('qrcode')
barcodeSearch.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
barcodeSearch.SetPosition(0.74, 0.42)
barcodeSearch.SetOnTouch(imageSearch)
layHome.AddChild(barcodeSearch)
//RANDOM FACTS
var txt = app.ReadFile("factList.txt");
var lines = txt.split("\n");
var randomIndex = Math.floor(Math.random() * lines.length);
var fact = lines[randomIndex];
cardLay = MUI.CreateLayout("Card");
cardLay.SetSize(0.85, 0.25);
cardLay.SetPosition(0.07, 0.52, 0.5);
textLay = app.CreateLayout('Linear', 'H/VCenter,FillXY')
factTxt = app.CreateText(fact, 0.8, null, 'Monospace,AutoSize,Multiline');
//factTxt.SetSize(20)
textLay.AddChild(factTxt);
cardLay.AddChild(textLay)
layHome.AddChild(cardLay);
if (theme === 'Light') {
textLay.SetBackground('Img/light.png')
factTxt.SetTextColor('#FFC107')
} else {
textLay.SetBackground('Img/dark.png')
factTxt.SetTextColor('#FFC107')
}
bookmarks = MUI.CreateButtonElegant('bookmark', 0.19, 0.08)
bookmarks.SetPosition(0.054, 0.83)
//bookmarks.SetOnTouch(bookmarkViewer)
bookmarks.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
layHome.AddChild(bookmarks)
recents = MUI.CreateButtonElegant('book', 0.19, 0.08)
recents.SetPosition(0.29, 0.83)
recents.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
layHome.AddChild(recents)
bhistory = MUI.CreateButtonElegant('gobackward', 0.19, 0.08)
bhistory.SetPosition(0.51, 0.83)
bhistory.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
layHome.AddChild(bhistory)
collections = MUI.CreateButtonElegant('archivebox', 0.19, 0.08)
collections.SetPosition(0.74, 0.83)
collections.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
layHome.AddChild(collections)
layFooter = MUI.CreateLayout("Absolute", "FillXY")
layFooter.SetPosition(0, 0.93, 1, 0.09)
back = MUI.CreateButtonFlat("chevron_left", 0.19, 0.08)
back.SetPosition(0, 0, 0.19, 0.08)
back.SetOnTouch(webOnBack)
back.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
forward = MUI.CreateButtonFlat("chevron_right", 0.19, 0.08)
forward.SetPosition(0.2, 0, 0.19, 0.08)
forward.SetOnTouch(webOnForward)
forward.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
panel = MUI.CreateButtonFlat("slider_horizontal_3", 0.19, 0.08)
panel.SetPosition(0.4, 0, 0.19, 0.08)
panel.SetOnTouch(HomePanel)
panel.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
tabdrawer = MUI.CreateButtonFlat("rectangle_stack", 0.19, 0.08)
tabdrawer.SetOnTouch(showTabDrawer)
tabdrawer.SetPosition(0.6, 0, 0.19, 0.08)
tabdrawer.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
home = MUI.CreateButtonFlat("house", 0.19, 0.08)
home.SetPosition(0.8, 0, 0.19, 0.08)
home.SetOnTouch(goToHome)
home.SetOnLongTouch(BrowsingOptions)
home.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
layHome.AddChild(logo)
layHome.AddChild(searchbx)
layFooter.AddChild(back)
layFooter.AddChild(forward)
layFooter.AddChild(panel)
layFooter.AddChild(tabdrawer)
layFooter.AddChild(home)
lay.AddChild(layFooter)
lay.AddChild(layHome)
app.AddLayout(lay)
app.LoadPlugin('Support')
app.LoadPlugin("PopUp");
sup = app.CreateSupport();
if (theme === 'Dark') app.SetNavBarColor("#121212");
else app.SetNavBarColor("#f5f5f5");
// Create a new tab object and add it to the tabs array
var tab = {
name: 'Tab ' + tabCounter, // You can set a more meaningful name here
layout: lay,
};
tabs.push(tab);
// Increment the tab counter
tabCounter++;
lst = app.CreateList(tabNames, null, null, "menu");
// Update the tab name list
UpdateTabList();
}
function showTabDrawer() {
tabSheet = sup.CreateBottomSheet();
tabList = MUI.CreateLayout("Linear", "VCenter,FillXY");
tabSheet.AddChild(tabList);
tabList.SetSize(1, 0.55);
// Create a list of tab names for the tab drawer
var tabNames = tabs.map(function(tab) {
return
tab.name;
});
lst.SetBackColor("#EEEEEE");
lst.SetOnTouch(function(index) {
// Switch to the selected tab
SwitchToTab(index);
tabSheet.Dismiss();
});
tabList.AddChild(lst);
newTabBtn = MUI.CreateButtonElegant('New Tab');
newTabBtn.SetOnTouch(AddNewTab);
tabList.AddChild(newTabBtn);
tabSheet.Show();
}
function UpdateTabList() {
// Create a list of tab names for the tab drawer
var tabNames = tabs.map(function(tab) {
return
tab.name;
});
// Update the list in the tab drawer
lst.SetList(tabNames);
}
function SwitchToTab(index) {
// Check if the index is valid
if (index >= 0 && index < tabs.length) {
// Hide all tab layouts
tabs.forEach(function(tab) {
tab.layout.Hide();
});
// Show the selected tab layout
tabs[index].layout.Show();
// Update the current tab index
currentIndex = index;
}
}
// ...
function imageSearch(){
app.LoadPlugin( "BarcodeReader" );
qrdisplay = sup.CreateBottomSheet();
qrlay = app.CreateLayout('Absolute','VCenter,FillXY')
qrlay.SetSize(1,0.72)
qrdisplay.AddChild(qrlay)
qrreader = app.CreateObject( "BarcodeReader" );
cam = app.CreateCameraView( 1, 0.72, "VGA, UseYUV" );
cam.SetOnReady( cam_OnReady );
qrlay.AddChild( cam );
flashBtn = MUI.CreateButtonFlat("lightbulb", 0.19, 0.08)
flashBtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
flashBtn.SetPosition(0.4, 0.6)
flashBtn.SetOnTouch(flashT)
flashBtn.Show()
qrlay.AddChild( flashBtn );
flashBtnOff = MUI.CreateButtonFlat("lightbulb_slash", 0.19, 0.08)
flashBtnOff.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
flashBtnOff.SetPosition(0.4, 0.6)
flashBtnOff.SetOnTouch(flashF)
flashBtnOff.Hide()
qrlay.AddChild( flashBtnOff );
qrdisplay.Show();
}
function flashT() {flashOn(true);}
function flashF() { flashOn(false);}
function flashOn(val){
if(val === true){
cam.SetFlash(true)
flashBtn.Hide()
flashBtnOff.Show()
}
else{
cam.SetFlash(false)
flashBtnOff.Hide()
flashBtn.Show()
}
}
function cam_OnReady()
{
cam.StartPreview();
DecodeFromCamera();
}
function DecodeFromCamera()
{
var result = qrreader.Decode( cam );
if( result != null )
{
app.Vibrate( "0,100,30,100,50,300" );
cam.StopPreview()
qrdisplay.Dismiss()
let data = result.content;
let searchdata = "
https://www.google.com/search?q=" +data;
if( isUrl(result.content)){
FindQuery(result.content)
}
else{
FindQuery(searchdata);
}
}
else
{
//Decode again in 200 milliseconds.
setTimeout( DecodeFromCamera, 200 );
}
}
function HomePanel() {
sup = app.CreateSupport();
panel = sup.CreateBottomSheet(null, null, "NoDim")
panellay = MUI.CreateLayout("Absolute", "VCenter,FillXY")
panellay.SetSize(1, 0.35)
panel.AddChild(panellay)
if (theme === 'Dark') {
themebtn = MUI.CreateButtonFlat("sun_max_fill", 0.35)
themebtn.SetPosition(0.1, 0, 0.2, 0.1)
themebtn.SetOnTouch(setLightTheme)
themebtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
} else {
themebtn = MUI.CreateButtonFlat("moon", 0.35)
themebtn.SetPosition(0.1, 0, 0.2, 0.1)
themebtn.SetOnTouch(setDarkTheme)
themebtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
}
htbtn = MUI.CreateButtonFlat("goforward", 0.35)
htbtn.SetPosition(0.3, 0, 0.2, 0.1)
htbtn.SetOnTouch(webReload)
htbtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
tlebtn = MUI.CreateButtonFlat("doc_append", 0.35)
tlebtn.SetPosition(0.5, 0, 0.2, 0.1)
tlebtn.SetOnTouch(GetContentLang)
tlebtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
pinbtn = MUI.CreateButtonFlat("bookmark", 0.35)
pinbtn.SetPosition(0.7, 0, 0.2, 0.1)
pinbtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
sharebtn = MUI.CreateButtonFlat("square_arrow_up_on_square", 0.35)
sharebtn.SetPosition(0.1, 0.11, 0.2, 0.1)
sharebtn.SetOnTouch(ShareContent)
sharebtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
readerbtn = MUI.CreateButtonFlat("doc_plaintext", 0.35)
readerbtn.SetPosition(0.3, 0.11, 0.2, 0.1)
//readerbtn.SetOnTouch(ReaderView)
readerbtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
findbtn = MUI.CreateButtonFlat("doc_text_search", 0.35)
findbtn.SetPosition(0.5, 0.11, 0.2, 0.1)
//findbtn.SetOnTouch(FindInPage)
findbtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
downloadbtn = MUI.CreateButtonFlat("cloud_download", 0.35)
downloadbtn.SetPosition(0.7, 0.11, 0.2, 0.1)
downloadbtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
stngsbtn = MUI.CreateButtonFlat("gear_alt", 0.35)
stngsbtn.SetPosition(0.5, 0.25, 0.2, 0.1)
//stngsbtn.SetOnTouch(SettingsPanel)
stngsbtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
closebtn = MUI.CreateButtonFlat("power", 0.35)
closebtn.SetPosition(0.7, 0.25, 0.2, 0.1)
closebtn.SetOnTouch(ExitApp)
closebtn.SetFontFile("Fonts/Framework7Icons-Regular.ttf")
panellay.AddChild(closebtn), panellay.AddChild(stngsbtn), panellay.AddChild(downloadbtn), panellay.AddChild(findbtn), panellay.AddChild(readerbtn), panellay.AddChild(sharebtn), panellay.AddChild(themebtn), panellay.AddChild(htbtn), panellay.AddChild(tlebtn), panellay.AddChild(pinbtn), panel.Show();
}
function BrowsingOptions(){
let list = "Read Page,Remove Paywall,View Page Security";
lst = MUI.CreateMenu(list, null, null, "Bottom, Right")
lst.SetOnSelect(selectOptions)
lst.Show()
}
function FindQuery(url, main) {
layWeb = app.CreateLayout('Absolute', 'FillXY,VCenter')
layWeb.SetPosition(0, 0, 1, 0.93)
layWeb.SetVisibility('Show')
webLay = app.CreateLayout('Absolute', 'FillXY,VCenter')
webLay.SetPosition(0, 0, 1, 0.905)
webLay.SetVisibility('Show')
siteDisplay = MUI.CreateLayout('Absolute', 'FillXY,VCenter')
siteDisplay.SetPosition(0, 0.905, 1, 0.25)
siteDisplay.SetBackColor()
siteDisplay.SetSize(1, 0.5)
siteDisplay.SetOnTouch(editBar)
editUrl = MUI.CreateTextEditSearch(0.8)
editUrl.SetPosition(0.1, 0.01)
editUrl.Hide()
editUrl.SetOnEnter(FindQuery)
webLay.AddChild(editUrl)
siteLinear = app.CreateLayout('Linear', "Horizontal,HCenter")
siteLinear.SetBackColor()
siteLinear.SetSize(1, 0.5)
siteDisplay.AddChild(siteLinear)
web = app.CreateWebView(1, 0.905, "IgnoreSSLErrors,IgnoreErrors,NoPause,AllowZoom,ScrollFade,AllowCapture")
web.SetOnRequest(webOnRequest)
web.SetBackColor("white")
web.SetOnUrl(webOnUrl)
webLay.AddChild(web)
layWeb.AddChild(webLay)
layWeb.AddChild(siteDisplay)
app.AddLayout(layWeb)
try {
editUrl.Hide()
} catch (err) {}
try {
var query = this.GetText();
app.HideKeyboard() || layHome.SetVisibility('Hide');
let fixedquery = 'https://' + query;
let searchquery = "
https://www.google.com/search?q=" +query;
if (isUrl(query) === true & isDomain(query) === true) web.LoadUrl(query);
else if (isUrl(query) === true && isDomain(query) === false) web.LoadUrl(fixedquery);
else web.LoadUrl(searchquery);
} catch (err) {}
var fastsearchquery = "
https://www.google.com/search?q=" + app.GetClipboardText();
if (isUrl(url) && isDomain(url) === true) {
web.LoadUrl(url)
}
if (isText(url) === false && isDomain(url) === false) {
let fixedquery = 'https://' + url;
web.LoadUrl(fixedquery);
}
if (isText(url) === true && main === false) web.LoadUrl(fastsearchquery);
if(editUrl.GetVisibility()==='Show'){
hideBar()
}
hideBar()
}
function keyboardControls(shown) {
var KH = app.GetKeyboardHeight();
var KS = app.GetDisplayHeight();
var KH2 = KS - KH;
var KH3 = KH2 / KS * 1 - 0.001;
var KH3A = KH2 / KS * 1 + 6.58;
//try,catch used bc if its not there errors with almost anykeyboard use
//appear
try{
if (shown === true && editUrl.GetVisibility()!='Show' ) {
webLay.SetSize(1, KH3);
web.SetSize(1, KH3);
}
if ( shown === true && editBar.GetVisibility()==='Show') {
editUrl.SetSize(0.1, KH3A)
}
else {
//layWeb.SetSize(1, 0.905);
webLay.SetSize(1, 0.905);
web.SetSize(1, 0.905);
siteDisplay.Show()
}
}
catch(e){
DoNothing()
}
}
function editBar() {
editUrl.Show()
editUrl.SetText(web.GetUrl())
if(editUrl.GetText()===web.GetUrl()){
setTimeout(hideBar,10000)
}
else{
setTimeout(hideBar,15000)
}
}
function hideBar() {
editUrl.Hide()
}
function webOnUrl(url) {
if (isUrl(url) === true && isDownloadable(url) === true) {
startDownload(url);
}
if(isTel(url)){
app.Call(extractPhoneNumber(url))
}
if(isMailToScheme(url)){
let email = extractEmail(web.GetUrl());
let subject = extractSubject(web.GetUrl());
let body = extractBody(web.GetUrl());
app.SendMail(email, subject, body);
}
if (isSmsScheme(url)) {
let number = extractSmsNumber(web.GetUrl());
let body = extractSmsBody(web.GetUrl());
app.SendSMS(body, number);
}
if(isUrl(url)){
web.LoadUrl(url);
}
}