sneedium/libbrowz.js

62 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-03-02 17:26:33 -06:00
let tabGroup = document.querySelector("tab-group");
function go() {
let browserFrame = tabGroup.getActiveTab().webview
2023-03-09 04:04:28 -06:00
let browser = tabGroup.getActiveTab()
2023-03-09 06:00:35 -06:00
let url = document.getElementById("txtUrl").value
2023-03-09 08:03:50 -06:00
if (url.includes("youtube.com") || url.includes("youtu.be")) {
url = url.replaceAll("youtube.com", "yewtu.be")
url = url.replaceAll("youtu.be", "yewtu.be")
} else if (url.includes("google.com")) {
url = url.replaceAll("google.com", "startpage.com")
}
2023-03-09 06:00:35 -06:00
document.getElementById("txtUrl").value = ""
browserFrame.loadURL(url);
2023-03-09 04:04:28 -06:00
browserFrame.addEventListener('dom-ready', () => {
browserFrame.insertCSS(`
::-webkit-scrollbar {
display: none;
}
`)
})
2023-03-02 17:26:33 -06:00
browserFrame.addEventListener("page-title-updated", (titleEvent) => {
let title = browserFrame.getTitle()
tabGroup.getActiveTab().setTitle(title)
console.log(title)
})
2023-03-09 04:04:28 -06:00
for (let i = 0; i < userscripts.length; i++) {
2023-03-09 05:25:24 -06:00
fetch(userscripts[i]).then( r => r.text() ).then( t => userscripts.executeJavaScript(t)).catch(() => {
console.log("Error loading userscripts! (Did you provide any?)")
2023-03-02 18:20:58 -06:00
})
2023-03-02 17:26:33 -06:00
}
}
2023-03-09 04:04:28 -06:00
function stop() {
let browserFrame = tabGroup.getActiveTab().webview
browserFrame.stop()
}
2023-03-02 17:26:33 -06:00
function back() {
let browserFrame = tabGroup.getActiveTab().webview
browserFrame.goBack()
}
2023-03-09 04:04:28 -06:00
2023-03-02 17:26:33 -06:00
function forward() {
let browserFrame = tabGroup.getActiveTab().webview
browserFrame.goForward()
}
tabGroup.setDefaultTab({
title: CONF.homepageTitle,
src: CONF.homepage,
active: true
});
tabGroup.addTab()
2023-03-09 04:04:28 -06:00
2023-03-02 17:26:33 -06:00
function clickPress(keyEvent) {
if (keyEvent.keyCode == 13) {
go()
}
2023-03-09 04:04:28 -06:00
}
2023-03-09 08:03:50 -06:00