Add files via upload

This commit is contained in:
NodeMixaholic 2023-03-09 05:25:24 -06:00 committed by GitHub
parent 1f20616077
commit 06879c2080
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 11 deletions

View file

@ -9,6 +9,7 @@
</head>
<body>
<div id="navBar">
<button id="nwBtn">📄</button>
<input id="txtUrl" placeholder="Put the website here" name="url" type="text" onkeypress="clickPress(event)" />
<button onclick="go(); return false;" id="goBtn"></button>
<button onclick="stop(); return false;" id="stopBtn">🛑</button>

View file

@ -8,6 +8,6 @@
</head>
<body>
<h1>Welcome to F-Stopium!</h1>
<p>Put userscripts in ./userscript. It uses a standard JS array format and uses URLs. Config is located at: ./config.json. Note: if you are using a pre-compiled version, these features are not available to you.</p>
<p>Put a list of URLs to userscripts in ./userscript/userscripts.js. It uses a standard JS array format and uses URLs. Config is located at: ./config.js. Note: if you are using a pre-compiled version, these features are not available to you.</p>
</body>
</html>

View file

@ -2,7 +2,6 @@ let tabGroup = document.querySelector("tab-group");
function go() {
let browserFrame = tabGroup.getActiveTab().webview
let browser = tabGroup.getActiveTab()
extensions.addTab(browserWindow, browserFrame)
browserFrame.loadURL(document.getElementById("txtUrl").value);
browserFrame.addEventListener('dom-ready', () => {
browserFrame.insertCSS(`
@ -19,8 +18,8 @@ function go() {
})
document.getElementById("txtUrl").value = ""
for (let i = 0; i < userscripts.length; i++) {
fetch(extensions[i]).then( r => r.text() ).then( t => userscripts.executeJavaScript(t)).catch(() => {
console.log("Error loading extensions! (Did you provide any?)")
fetch(userscripts[i]).then( r => r.text() ).then( t => userscripts.executeJavaScript(t)).catch(() => {
console.log("Error loading userscripts! (Did you provide any?)")
})
}
}
@ -52,3 +51,4 @@ function clickPress(keyEvent) {
go()
}
}

23
main.js
View file

@ -1,9 +1,19 @@
// Modules to control application life and create native browser window
const {app, BrowserWindow, session} = require('electron')
const {app, BrowserWindow, session, ipcMain} = require('electron')
const path = require('path')
const fetch = require("cross-fetch")
const { ElectronChromeExtensions } = require('electron-chrome-extensions')
ipcMain.on('windowmaker', (event, arg) => {
createWindow();
})
function newExtensionSession(mainWindow) {
const extensions = new ElectronChromeExtensions({
session: session.defaultSession
})
extensions.addTab(mainWindow.webContents, mainWindow)
}
function createWindow () {
// Create the browser window.
@ -67,23 +77,22 @@ const toBlock = [
}
return callback({})
})
const extensions = new ElectronChromeExtensions({
session: session.defaultSession
})
extensions.addTab(mainWindow.webContents, mainWindow)
// and load the index.html of the app.
mainWindow.loadFile('index.html')
// Open the DevTools.
mainWindow.webContents.openDevTools()
return mainWindow;
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {
createWindow()
let x = createWindow()
newExtensionSession(x)
app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.

View file

@ -14,4 +14,13 @@ window.addEventListener('DOMContentLoaded', () => {
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
const { ipcRenderer } = require('electron')
ipcRenderer.on('windowmaker', (event, arg) => {
console.log(arg) // prints "pong"
})
//button and its event listener
const makeWindowButton = document.getElementById('nwBtn');
makeWindowButton.addEventListener('click', () => {
ipcRenderer.send('windowmaker', 'ping')
})
})

View file

@ -22,6 +22,17 @@ body {
margin: 0;
}
#nwBtn {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 1% 1%;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 1.25rem;
}
#goBtn {
background-color: #4CAF50; /* Green */
border: none;

View file

@ -0,0 +1 @@
var userscripts = [""]