Add files via upload
This commit is contained in:
parent
1f20616077
commit
06879c2080
7 changed files with 42 additions and 11 deletions
|
@ -9,6 +9,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="navBar">
|
<div id="navBar">
|
||||||
|
<button id="nwBtn">📄</button>
|
||||||
<input id="txtUrl" placeholder="Put the website here" name="url" type="text" onkeypress="clickPress(event)" />
|
<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="go(); return false;" id="goBtn">✅</button>
|
||||||
<button onclick="stop(); return false;" id="stopBtn">🛑</button>
|
<button onclick="stop(); return false;" id="stopBtn">🛑</button>
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Welcome to F-Stopium!</h1>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -2,7 +2,6 @@ let tabGroup = document.querySelector("tab-group");
|
||||||
function go() {
|
function go() {
|
||||||
let browserFrame = tabGroup.getActiveTab().webview
|
let browserFrame = tabGroup.getActiveTab().webview
|
||||||
let browser = tabGroup.getActiveTab()
|
let browser = tabGroup.getActiveTab()
|
||||||
extensions.addTab(browserWindow, browserFrame)
|
|
||||||
browserFrame.loadURL(document.getElementById("txtUrl").value);
|
browserFrame.loadURL(document.getElementById("txtUrl").value);
|
||||||
browserFrame.addEventListener('dom-ready', () => {
|
browserFrame.addEventListener('dom-ready', () => {
|
||||||
browserFrame.insertCSS(`
|
browserFrame.insertCSS(`
|
||||||
|
@ -19,8 +18,8 @@ function go() {
|
||||||
})
|
})
|
||||||
document.getElementById("txtUrl").value = ""
|
document.getElementById("txtUrl").value = ""
|
||||||
for (let i = 0; i < userscripts.length; i++) {
|
for (let i = 0; i < userscripts.length; i++) {
|
||||||
fetch(extensions[i]).then( r => r.text() ).then( t => userscripts.executeJavaScript(t)).catch(() => {
|
fetch(userscripts[i]).then( r => r.text() ).then( t => userscripts.executeJavaScript(t)).catch(() => {
|
||||||
console.log("Error loading extensions! (Did you provide any?)")
|
console.log("Error loading userscripts! (Did you provide any?)")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,3 +51,4 @@ function clickPress(keyEvent) {
|
||||||
go()
|
go()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
main.js
23
main.js
|
@ -1,9 +1,19 @@
|
||||||
// Modules to control application life and create native browser window
|
// 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 path = require('path')
|
||||||
const fetch = require("cross-fetch")
|
const fetch = require("cross-fetch")
|
||||||
const { ElectronChromeExtensions } = require('electron-chrome-extensions')
|
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 () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
|
@ -67,23 +77,22 @@ const toBlock = [
|
||||||
}
|
}
|
||||||
return callback({})
|
return callback({})
|
||||||
})
|
})
|
||||||
const extensions = new ElectronChromeExtensions({
|
|
||||||
session: session.defaultSession
|
|
||||||
})
|
|
||||||
extensions.addTab(mainWindow.webContents, mainWindow)
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
mainWindow.webContents.openDevTools()
|
mainWindow.webContents.openDevTools()
|
||||||
|
|
||||||
|
return mainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
createWindow()
|
let x = createWindow()
|
||||||
|
newExtensionSession(x)
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it's common to re-create a window in the app when the
|
// 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.
|
// dock icon is clicked and there are no other windows open.
|
||||||
|
|
|
@ -14,4 +14,13 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||||
for (const type of ['chrome', 'node', 'electron']) {
|
for (const type of ['chrome', 'node', 'electron']) {
|
||||||
replaceText(`${type}-version`, process.versions[type])
|
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')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
11
styles.css
11
styles.css
|
@ -22,6 +22,17 @@ body {
|
||||||
margin: 0;
|
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 {
|
#goBtn {
|
||||||
background-color: #4CAF50; /* Green */
|
background-color: #4CAF50; /* Green */
|
||||||
border: none;
|
border: none;
|
||||||
|
|
1
userscript/userscripts.js
Normal file
1
userscript/userscripts.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
var userscripts = [""]
|
Loading…
Reference in a new issue