Compare commits

..

37 commits

Author SHA1 Message Date
be64967438 Refactor main.js to modularize functionality and improve readability; update .gitignore to include build directory 2025-03-15 20:20:48 -05:00
154d15188d update rules 2025-03-15 20:16:42 -05:00
71b407c211 Add Chrome extension management functionality and update .gitignore 2025-03-15 20:07:56 -05:00
f11841c1a2 Update README.md 2025-03-03 14:42:08 +00:00
11b7692d14 Update README.md 2025-03-03 14:41:49 +00:00
6825c0d40c Update README.md 2025-03-03 14:40:23 +00:00
ff3f0d77cb Update README.md 2025-03-03 14:39:48 +00:00
2ebdd73942 Update README.md 2025-03-03 14:38:58 +00:00
87b53acf7e Update libbrowz.js 2025-03-03 14:38:29 +00:00
55a4b89b24 fix cam btn 2024-11-25 14:40:26 -06:00
fc736da1d3 fix window size to accomidate new button 2024-11-25 14:32:43 -06:00
1c1f7934fb fix styling on sneedium camBtn 2024-11-25 14:29:55 -06:00
4bac2b0542 add webcam button 2024-11-25 14:26:46 -06:00
bad5e26a86 re-introduce yt/google redirect 2024-11-25 14:21:10 -06:00
42de741e08 since i added adblock/trackblock support this isnt really needed 2024-11-25 14:18:15 -06:00
7198b136a6 add mic/cam access 2024-11-25 14:07:39 -06:00
8d18437dfa add more adblocking, update itworks html 2024-11-25 14:02:23 -06:00
37e109f739 "patches, and patches for the patches" 2024-11-21 15:12:04 -06:00
dc9f6a45a6 Remove userscript support. 2024-11-21 15:04:35 -06:00
995962a497 finish up the rewrite 2024-11-21 14:57:11 -06:00
fbdeb5dc7b no one's sure what devops really means 2024-11-21 14:08:59 -06:00
5789eb88a2 screaming out feibely, disgusting. 2024-11-21 14:02:51 -06:00
5dada52da5 begin work on big rewrite 2024-11-21 13:55:06 -06:00
d16aa9b3f3 Update LICENSE 2024-11-14 19:58:45 +00:00
The Ghost of FOSS' Future
c0037f256e
remove irelivant msg 2024-09-10 20:55:03 -05:00
The Ghost of FOSS' Future
6531460cd0
ok thats cool 2024-09-10 20:54:30 -05:00
The Ghost of FOSS' Future
95219d7298
demote mac maker to a shortcut 2024-09-08 16:13:04 -05:00
The Ghost of FOSS' Future
c7159725e2
Add files via upload 2024-09-08 16:00:22 -05:00
The Ghost of FOSS' Future
b4e88f8b22
Update README.md 2024-09-03 19:36:14 -05:00
The Ghost of FOSS' Future
ee706b339f
nature trail to hell...
in 3d!
2024-09-03 19:14:56 -05:00
The Ghost of FOSS' Future
726d22f096
will it work?
perhaps not
2024-09-03 19:10:29 -05:00
The Ghost of FOSS' Future
f244e0f003
yet another bugsbug 2024-09-03 19:01:28 -05:00
The Ghost of FOSS' Future
010e954d7d
Hotfix for the maker 2024-09-03 18:54:32 -05:00
The Ghost of FOSS' Future
38209621b9
Make the Mac maker make Mac binaries 2024-09-03 18:51:36 -05:00
The Ghost of FOSS' Future
1bef1f1615
Add files via upload 2024-09-03 18:47:16 -05:00
The Ghost of FOSS' Future
1549b64317
Update package.json 2024-09-03 18:43:12 -05:00
The Ghost of FOSS' Future
e4776f36ad
Update package.json 2024-09-03 18:34:53 -05:00
22 changed files with 1736 additions and 819 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View file

@ -0,0 +1,19 @@
---
description: A very basic ruleset
globs:
alwaysApply: true
---
# Basic rules
- Always use functional code
- Always prefer simple, easy-to-understand code
- Always create a .gitignore file with the build directory in it.
- Always code what the user specifies and that of which it is obvious that its within the user's specifications
- If not sure about something, ask the user
- Keep .gitignore up to date
- Comment code well
- NEVER EVER EDIT .env files
- Don't change config files unless needed
- If function line count is above 55, split into multiple smaller functions or refactor
- If file line count above 400 split into more files or refactor
- Feel free to auto-apply any changes that follow these or any other rules.

8
.gitignore vendored
View file

@ -3,3 +3,11 @@ seedium-linux-x64
sneedium-win32-x64 sneedium-win32-x64
seedium-linux-arm64 seedium-linux-arm64
sneedium-win32-arm64 sneedium-win32-arm64
sneedium-darwin-x64
sneedium-darwin-arm64
out/
dist/
build/
.DS_Store
.env
*.log

View file

@ -1,6 +1,6 @@
The Sammy Public License Revision 5 Sub-Revision 1 (SPL-R5 SR1) The Sammy Public License Revision 5 Sub-Revision 2 (SPL-R5 SR2)
Copyright (c) 2024 Sneed Group Copyright (c) Sneed Group
This document grants permission, without charge, to any individual acquiring a copy of the software and its associated documentation files (hereinafter referred to as the "Software"). Such individuals are authorized to engage in activities related to the Software with certain restrictions (listed below), including, but not limited to, the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software. These permissions extend to persons to whom the Software is furnished, subject to compliance with the specified conditions outlined below. This document grants permission, without charge, to any individual acquiring a copy of the software and its associated documentation files (hereinafter referred to as the "Software"). Such individuals are authorized to engage in activities related to the Software with certain restrictions (listed below), including, but not limited to, the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software. These permissions extend to persons to whom the Software is furnished, subject to compliance with the specified conditions outlined below.
@ -10,10 +10,20 @@ In making contributions to the Software, contributors irrevocably assign, transf
Furthermore, this document permits the reuse and redistribution of both executable binaries and source code, contingent upon the inclusion of the previously mentioned copyright notice and permission notice in all copies or substantial portions of the Software. It is imperative that you explicitly acknowledge and agree that the owner(s) retain ownership rights over the aforementioned source code. Furthermore, this document permits the reuse and redistribution of both executable binaries and source code, contingent upon the inclusion of the previously mentioned copyright notice and permission notice in all copies or substantial portions of the Software. It is imperative that you explicitly acknowledge and agree that the owner(s) retain ownership rights over the aforementioned source code.
Moreover, companies using the Software are encouraged to contribute upstream. Fortune 500 companies are required to make an annual contribution of at least 20,000 USD or an equivalent amount per project used to support the said projects' sustainability unless no donation option is provided. Also, all Fortune 500 companies using said projects are required to contibute their changes upstream as well. Additionally, note that the use of AI-assisted tools, including but not limited to GitHub Copilot and ChatGPT, is expressly permitted in conjunction with this software. Users are encouraged to leverage these AI tools to enhance their experience in developing, modifying, and interacting with the Software. The permission granted herein extends to the integration and utilization of AI-generated content for coding and communication purposes. The owner(s) of the Software acknowledge and embrace the collaborative nature of AI-assisted development.
Additionally, note that the use of AI-assisted tools, including but not limited to GitHub Copilot and ChatGPT, is expressly permitted in conjunction with this software. Users are encouraged to leverage these AI tools to enhance their experience in developing, modifying, and interacting with the Software. The permission granted herein extends to the integration and utilization of AI-generated content for coding and communication purposes. The owners(s) of the Software acknowledge and embrace the collaborative nature of AI-assisted development. In addition, the owner of the code is granted the authority to update their copy of The Sammy Public License (SPL) to the latest revision. This update may be undertaken at the discretion of the owner to ensure alignment with any subsequent revisions made to The Sammy Public License.
In addition, the owner of the code is granted the authority to update their copy of The Samuel Public License (SPL) to the latest revision. This update may be undertaken at the discretion of the owner to ensure alignment with any subsequent revisions made to The Samuel Public License. Minimum Payment Requirements by Business Size:
1. Fortune 500 Companies: Companies that are included in the Fortune 500 list are required to make an annual contribution of at least 42,069 USD or an equivalent amount per project used to support the sustainability of the Software, unless no donation option is provided. Additionally, Fortune 500 companies are required to contribute their changes upstream to the Software.
2. Large Non-Fortune 500 Companies: Non-Fortune 500 large companies (defined as companies with 128 or more employees) must pay a minimum of 15,000 USD per year for the continued use of the Software.
3. Medium Businesses: Medium businesses (defined as companies with 42 to 128 employees) are required to pay a minimum of 420 USD per year for the continued use of the Software.
4. Small Businesses: Small businesses (defined as companies with 42 or fewer employees) are required to pay a minimum of 69 USD per year for the continued use of the Software.
These fees are intended to ensure the sustainability of the project and may be subject to change by the project owner(s). Payment is due annually, and the corresponding amount must be paid no later than 30 days after the beginning of each calendar year. Failure to comply with these payment terms may result in revocation of the right to use the Software.
The aforementioned copyright notice and this permission notice must be included in all copies or substantial portions of the Software. The aforementioned copyright notice and this permission notice must be included in all copies or substantial portions of the Software.

View file

@ -1,9 +1,9 @@
<img src="https://github.com/Sneed-Group/sneedium/blob/master/logo.png?raw=true" align="right" width="15%"/> <img src="https://github.com/Sneed-Group/sneedium/blob/master/logo.png?raw=true" align="right" width="15%"/>
# Sneedium # Sneedium
A basic web browser in Electron. ***With a functioning adblocker and privacy redirection technologies!*** A basic web browser in Electron. ***With a functioning adblocker, privacy redirection technologies, and Chrome extension support!***
[![Download latest build.](https://github.com/Sneed-Group/sneedium/blob/master/download.png?raw=true)](https://github.com/Sneed-Group/sneedium/releases/latest) [![Download latest build.](https://sneedgit.nodemixaholic.com/Sneed-Group/sneedium/raw/branch/master/download.png)](https://sneedgit.nodemixaholic.com/Sneed-Group/sneedium/releases)
## Testing, compiling, and creation notes ## Testing, compiling, and creation notes
@ -14,6 +14,8 @@ To clone and run this repository you'll need [Node.js](https://nodejs.org/en/dow
npm install npm install
# Run the app # Run the app
npm start npm start
# Run in development mode (with dev tools)
npm run dev
``` ```
Supports compiling via electron packager. Install and run it with: Supports compiling via electron packager. Install and run it with:
@ -32,6 +34,17 @@ A basic Electron application needs just these files:
- `index.html` - A web page to render. This is the app's **renderer process**. - `index.html` - A web page to render. This is the app's **renderer process**.
- `preload.js` - A content script that runs before the renderer process loads. - `preload.js` - A content script that runs before the renderer process loads.
## Chrome Extension Support
Sneedium now supports loading and using Chrome extensions. Extensions are managed through a dedicated Extension Manager interface:
1. Click the extension button (🧩) in the browser toolbar to open the extension manager
2. Install extensions by clicking the "Install Extension" button and selecting a .crx file
3. Extensions are stored in the `SneedExtensions` folder in your home directory
4. You can also manually install extensions by unpacking them into subdirectories of the `SneedExtensions` folder
Note: Not all Chrome extensions may work perfectly due to API differences between Chrome and Electron. Features like sync and Chrome Web Store integration are not supported.
## License ## License
[SPL-R5](https://github.com/Sneed-Group/sneedium/blob/master/LICENSE.md) [SPL-R5](https://github.com/Sneed-Group/sneedium/blob/master/LICENSE.md)
@ -42,4 +55,4 @@ A basic Electron application needs just these files:
## What is Privacy Redirection Technology (PRT)? ## What is Privacy Redirection Technology (PRT)?
This is a simple technology that replaces a bad URL with a more privacy friendly service, when we know that ADs aren't 100% blocked, or just to provide a better UX. TLDR: Clickjacking for the greater good. This is a simple technology that replaces a bad URL with a more privacy friendly service, when we know that ADs aren't 100% blocked, or just to provide a better UX. TLDR: Clickjacking for the greater good. *This will NEVER use affilate links or whatnot, and how it works can be seen [here.](https://sneedgit.nodemixaholic.com/Sneed-Group/sneedium/src/branch/master/libbrowz.js)*

187
ad-blocker.js Normal file
View file

@ -0,0 +1,187 @@
/**
* Ad Blocker Module
*
* Handles ad blocking and web request filtering for Sneedium browser:
* - Sets up ad blocking with the Ghostery adblocker
* - Configures web request rules
* - Prevents access to local resources from remote sites
*/
const { ElectronBlocker } = require('@ghostery/adblocker-electron');
const fetch = require("cross-fetch");
// Blocklist for ad filtering
const toBlock = [
"*://*.doubleclick.*",
"*://s.innovid.com/*",
"*://partner.googleadservices.com/*",
"*://*.googlesyndication.com/*",
"*://*.google-analytics.com/*",
"*://*.creative.ak.fbcdn.net/*",
"*://*.adbrite.com/*",
"*://*.exponential.com/*",
"*://*.quantserve.com/*",
"*://*.scorecardresearch.com/*",
"*://*.zedo.com/*",
"*://*.a-ads.com/*",
"*://*.777partner.com/*",
"*://*.77tracking.com/*",
"*://*.abc-ads.com/*",
"*://*.aaxads.com/*",
"*://*.adizio.com/*",
"*://*.adjix.com/*",
"*://*.adjug.com/*",
"*://*.adjuggler.com/*",
"*://*.trafficjunky.net/*",
"*://*.trafficleader.com/*",
"*://*.trafficrouter.io/*",
"*://*.monerominer.rocks/*",
"*://*.2mdn.net/*",
"*.exe",
"*.vbs",
"*://*.googlesyndication.*",
"*pixels*",
"*telemetry*",
"*analytics*",
"*://ads.*.com*",
"*ae/us/audience*",
"*/api/v*/science*",
"*/api/v*/typing*"
];
// Regex patterns for additional blocking
const regexPatterns = [
"r[0-100]+---sn-.*\\.googlevideo\\.com$/g",
"r[0-100]+-sn-.*\\.googlevideo\\.com$/g"
];
// Local domain tokens for security filtering
const locals = [
'0.0.0.0', '127.0.0.1', '192.168', '.local', '.example', '.staging', 'fe80::', '::1'
];
/**
* Initialize ad blocker and web request filtering
* @param {Object} session - Electron session to apply blocking to
* @returns {Object} Functions to control ad blocker
*/
function initAdBlocker(session) {
let blocker = undefined;
return {
enableAdBlocking: () => enableGoodies(session),
setupWebRequestFilters: () => setupWebRequestFilters(session),
isLocal
};
}
/**
* Enable ad blocking for a session
* @param {Object} s - Electron session to enable blocking for
*/
async function enableGoodies(s) {
try {
if (!s) {
console.log("No session provided to enableGoodies, using default session");
return;
}
const blocker = await ElectronBlocker.fromLists(fetch, [
"https://github.com/uBlockOrigin/uAssets/raw/refs/heads/master/filters/ubol-filters.txt",
'https://easylist.to/easylist/easylist.txt',
'https://secure.fanboy.co.nz/fanboy-annoyance.txt',
'https://easylist.to/easylist/easyprivacy.txt',
'https://easylist-downloads.adblockplus.org/antiadblockfilters.txt',
'https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/nocoin.txt',
'https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/pro.plus.txt',
"https://github.com/yokoffing/filterlists/raw/refs/heads/main/youtube_clear_view.txt",
"https://pgl.yoyo.org/as/serverlist.php?showintro=0;hostformat=adblock",
"https://github.com/uBlockOrigin/uAssets/raw/refs/heads/master/filters/unbreak.txt",
"https://github.com/uBlockOrigin/uAssets/raw/refs/heads/master/filters/quick-fixes.txt",
"https://github.com/uBlockOrigin/uAssets/raw/refs/heads/master/filters/privacy.txt",
"https://github.com/uBlockOrigin/uAssets/raw/refs/heads/master/filters/badware.txt",
"https://github.com/uBlockOrigin/uAssets/raw/refs/heads/master/filters/filters.txt"
]);
blocker.enableBlockingInSession(s);
console.log("AD blocking enabled successfully");
return blocker;
} catch (error) {
console.error("Error enabling AD blocking:", error);
return null;
}
}
/**
* Check if a URL is for a local resource
* @param {string} url - URL to check
* @returns {boolean} Whether URL is for a local resource
*/
function isLocal(url) {
return locals.some(local => url.includes(local));
}
/**
* Check if a URL should be blocked by our custom rules
* @param {string} url - URL to check
* @returns {boolean} Whether URL should be blocked
*/
function containsAD(url) {
// Check against simple pattern list
for (let i = 0; i < toBlock.length; i++) {
let regex = toBlock[i].replace(/\*/g, "[^ ]*");
if (url.match(regex)) {
return true;
}
}
// Check against regex patterns
for (let i = 0; i < regexPatterns.length; i++) {
let regex = regexPatterns[i];
if (url.match(regex)) {
return true;
}
}
return false;
}
/**
* Set up web request filters for ad blocking and security
* @param {Object} session - Electron session to set up filters for
*/
function setupWebRequestFilters(session) {
// Set up web request filter
session.webRequest.onBeforeRequest((details, callback) => {
// Block ads
if (containsAD(details.url)) {
return callback({cancel: true});
}
try {
const url = new URL(details.url);
const hostname = url.hostname;
const isLocalDomain = isLocal(hostname);
// Check if the request is to a local domain
if (isLocalDomain) {
// Check if the request is initiated by a remote domain
const initiator = details.initiator ? new URL(details.initiator).hostname : '';
const isInitiatorLocal = isLocal(initiator);
if (initiator && !isInitiatorLocal) {
console.log(`[W] Local domain is being accessed by external source (${initiator}), don't allow!`);
callback({ cancel: true }); // Block request to local domains from remote sources
return;
}
}
callback({ cancel: false }); // Allow request
} catch (error) {
console.error("Error in web request filter:", error);
callback({ cancel: false }); // Allow on error
}
});
}
module.exports = initAdBlocker;

112
crx-extractor.js Normal file
View file

@ -0,0 +1,112 @@
/**
* CRX Extractor - Utility for handling Chrome extension files
* This module provides functions to extract and install Chrome extensions from CRX files
*/
const fs = require('fs');
const path = require('path');
const AdmZip = require('adm-zip');
/**
* Extracts a CRX file to the specified directory
*
* @param {string} crxFilePath - Path to the CRX file
* @param {string} outputDir - Directory to extract the CRX file to
* @returns {Promise<Object>} Result of the extraction
*/
async function extractCrxFile(crxFilePath, outputDir) {
return new Promise((resolve, reject) => {
try {
// Read the CRX file
const crxData = fs.readFileSync(crxFilePath);
// Check CRX header (Chrome extensions start with "Cr24")
if (crxData.slice(0, 4).toString() !== 'Cr24') {
return reject(new Error('Invalid CRX file format'));
}
// CRX format:
// [0-3] "Cr24" (Chrome extension signature)
// [4-7] Version number (uint32)
// [8-11] Public key length (uint32)
// [12-15] Signature length (uint32)
// Extract header information
const publicKeyLength = crxData.readUInt32LE(8);
const signatureLength = crxData.readUInt32LE(12);
// ZIP data starts after the header, public key, and signature
const zipStartOffset = 16 + publicKeyLength + signatureLength;
// Extract the ZIP portion of the CRX file
const zipData = crxData.slice(zipStartOffset);
// Write the ZIP data to a temporary file
const tempZipPath = path.join(require('os').tmpdir(), `${path.basename(crxFilePath, '.crx')}.zip`);
fs.writeFileSync(tempZipPath, zipData);
// Extract the ZIP file using AdmZip
const zip = new AdmZip(tempZipPath);
zip.extractAllTo(outputDir, true);
// Clean up the temporary ZIP file
fs.unlinkSync(tempZipPath);
// Check if manifest.json exists in the extracted files
const manifestPath = path.join(outputDir, 'manifest.json');
if (!fs.existsSync(manifestPath)) {
return reject(new Error('No manifest.json found in the extension'));
}
// Read the manifest.json file to get extension information
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
resolve({
success: true,
manifest,
extensionId: manifest.name ? manifest.name.replace(/[^a-zA-Z0-9]/g, '').toLowerCase() : null
});
} catch (error) {
reject(error);
}
});
}
/**
* Installs a Chrome extension from a CRX file
*
* @param {string} crxFilePath - Path to the CRX file
* @param {string} extensionsDir - Directory where extensions are stored
* @returns {Promise<Object>} Result of the installation
*/
async function installCrxExtension(crxFilePath, extensionsDir) {
try {
const extensionId = path.basename(crxFilePath, '.crx');
const extractPath = path.join(extensionsDir, extensionId);
// Create directory if it doesn't exist
if (!fs.existsSync(extractPath)) {
fs.mkdirSync(extractPath, { recursive: true });
}
// Extract the CRX file
const extractResult = await extractCrxFile(crxFilePath, extractPath);
return {
success: true,
message: 'Extension installed successfully',
extensionId,
manifest: extractResult.manifest
};
} catch (error) {
return {
success: false,
message: `Failed to install extension: ${error.message}`
};
}
}
module.exports = {
extractCrxFile,
installCrxExtension
};

194
extension-manager.js Normal file
View file

@ -0,0 +1,194 @@
/**
* Extension Manager Module
*
* Handles Chrome extension management for Sneedium browser
* - Loading extensions from disk
* - Installing extensions from CRX files
* - Removing extensions
* - Creating extensions management UI
*/
const path = require('path');
const fs = require('fs');
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
const { installCrxExtension } = require('./crx-extractor');
// Define extension directory path
const homePath = app.getPath('home');
const extensionsDir = path.join(homePath, 'SneedExtensions');
// Ensure extensions directory exists
if (!fs.existsSync(extensionsDir)) {
fs.mkdirSync(extensionsDir, { recursive: true });
}
/**
* Initialize extension manager and set up IPC handlers
* @returns {Object} Extension manager functions
*/
function initExtensionManager() {
// Set up IPC handlers for extension management
setupIpcHandlers();
return {
getExtensionsDir: () => extensionsDir,
createExtensionsWindow,
loadExtensions
};
}
/**
* Set up IPC handlers for extension management
*/
function setupIpcHandlers() {
// Get list of installed extensions
ipcMain.handle('get-extensions-list', getExtensionsList);
// Install extension from CRX file
ipcMain.handle('install-extension', handleInstallExtension);
// Remove installed extension
ipcMain.handle('remove-extension', handleRemoveExtension);
// Open extension management window
ipcMain.on('open-extensions-page', () => createExtensionsWindow());
}
/**
* Get list of installed extensions with their metadata
* @returns {Array} List of extension objects with metadata
*/
async function getExtensionsList() {
try {
const extensionFolders = fs.readdirSync(extensionsDir, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => {
const extPath = path.join(extensionsDir, dirent.name);
let manifest = {};
try {
const manifestPath = path.join(extPath, 'manifest.json');
if (fs.existsSync(manifestPath)) {
manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
}
} catch (e) {
console.error(`Error reading manifest for extension ${dirent.name}:`, e);
}
return {
id: dirent.name,
name: manifest.name || dirent.name,
version: manifest.version || 'unknown',
description: manifest.description || '',
path: extPath
};
});
return extensionFolders;
} catch (error) {
console.error('Error getting extensions list:', error);
return [];
}
}
/**
* Handle extension installation request
* @param {Object} event - IPC event
* @param {string} crxPath - Path to CRX file or null to prompt for file
* @returns {Object} Result of installation
*/
async function handleInstallExtension(event, crxPath) {
try {
// If no path provided, open dialog to select CRX file
if (!crxPath) {
const result = await dialog.showOpenDialog({
properties: ['openFile'],
filters: [{ name: 'Chrome Extension', extensions: ['crx'] }]
});
if (result.canceled || result.filePaths.length === 0) {
return { success: false, message: 'No file selected' };
}
crxPath = result.filePaths[0];
}
// Use the CRX extractor to install the extension
const installResult = await installCrxExtension(crxPath, extensionsDir);
return installResult;
} catch (error) {
console.error('Error installing extension:', error);
return { success: false, message: error.message };
}
}
/**
* Handle extension removal request
* @param {Object} event - IPC event
* @param {string} extensionId - ID of extension to remove
* @returns {Object} Result of removal
*/
async function handleRemoveExtension(event, extensionId) {
try {
const extensionPath = path.join(extensionsDir, extensionId);
if (fs.existsSync(extensionPath)) {
fs.rmSync(extensionPath, { recursive: true, force: true });
return { success: true };
} else {
return { success: false, message: 'Extension not found' };
}
} catch (error) {
console.error('Error removing extension:', error);
return { success: false, message: error.message };
}
}
/**
* Create extension management window
*/
function createExtensionsWindow() {
const extensionsWindow = new BrowserWindow({
width: 800,
height: 600,
title: 'Extension Manager',
webPreferences: {
preload: path.join(__dirname, 'extensions-preload.js'),
nodeIntegration: false,
contextIsolation: true
}
});
extensionsWindow.loadFile('extensions.html');
extensionsWindow.setMenuBarVisibility(false);
}
/**
* Load all extensions from the extensions directory
* @param {Object} extensionsInstance - ElectronChromeExtensions instance
*/
function loadExtensions(extensionsInstance) {
if (!extensionsInstance) return;
try {
// Get list of extension directories
const extensionFolders = fs.readdirSync(extensionsDir, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => path.join(extensionsDir, dirent.name));
// Load each extension
for (const extensionPath of extensionFolders) {
try {
if (fs.existsSync(path.join(extensionPath, 'manifest.json'))) {
const loadResult = extensionsInstance.loadExtension(extensionPath);
console.log(`Loaded extension from ${extensionPath}`, loadResult);
} else {
console.warn(`Missing manifest.json in extension directory: ${extensionPath}`);
}
} catch (extError) {
console.error(`Failed to load extension at ${extensionPath}:`, extError);
}
}
} catch (error) {
console.error('Error loading extensions:', error);
}
}
module.exports = initExtensionManager;

17
extensions-preload.js Normal file
View file

@ -0,0 +1,17 @@
// Preload script for the extensions management page
const { contextBridge, ipcRenderer } = require('electron');
// Expose extension management functions to the renderer process
contextBridge.exposeInMainWorld('extensionsAPI', {
// Get list of installed extensions
getExtensions: () => ipcRenderer.invoke('get-extensions-list'),
// Install a new extension (from CRX file)
installExtension: (crxPath) => ipcRenderer.invoke('install-extension', crxPath),
// Remove an extension
removeExtension: (extensionId) => ipcRenderer.invoke('remove-extension', extensionId),
// Open file dialog to select CRX file
openFileDialog: () => ipcRenderer.invoke('install-extension')
});

164
extensions.html Normal file
View file

@ -0,0 +1,164 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Extension Manager</title>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<link rel="stylesheet" href="styles.css">
<style>
.extension-container {
display: flex;
flex-direction: column;
padding: 10px;
}
.extension-card {
display: flex;
justify-content: space-between;
align-items: center;
border: 1px solid #ddd;
border-radius: 4px;
padding: 10px;
margin-bottom: 10px;
background-color: #f9f9f9;
}
.extension-info {
flex: 1;
}
.extension-actions {
display: flex;
gap: 10px;
}
.extension-card h3 {
margin-top: 0;
margin-bottom: 5px;
}
.extension-card p {
margin-top: 5px;
margin-bottom: 0;
color: #666;
}
.version {
color: #999;
font-size: 0.8em;
}
.button {
padding: 5px 10px;
border-radius: 4px;
border: none;
cursor: pointer;
font-weight: bold;
}
.install-btn {
background-color: #4CAF50;
color: white;
}
.remove-btn {
background-color: #f44336;
color: white;
}
.no-extensions {
text-align: center;
color: #666;
padding: 20px;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
border-bottom: 1px solid #ddd;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="header">
<h1>Extension Manager</h1>
<button id="install-extension" class="button install-btn">Install Extension</button>
</div>
<div class="extension-container" id="extensions-list">
<div class="no-extensions">No extensions installed</div>
</div>
<script>
// Get extensions list
async function loadExtensions() {
try {
const extensions = await window.extensionsAPI.getExtensions();
const extensionsList = document.getElementById('extensions-list');
// Clear current list
extensionsList.innerHTML = '';
if (extensions.length === 0) {
extensionsList.innerHTML = '<div class="no-extensions">No extensions installed</div>';
return;
}
// Populate list with extension cards
extensions.forEach(extension => {
const card = document.createElement('div');
card.className = 'extension-card';
card.innerHTML = `
<div class="extension-info">
<h3>${extension.name || 'Unknown Extension'}</h3>
<p class="version">Version: ${extension.version || 'unknown'}</p>
<p>${extension.description || 'No description available'}</p>
</div>
<div class="extension-actions">
<button class="button remove-btn" data-id="${extension.id}">Remove</button>
</div>
`;
extensionsList.appendChild(card);
});
// Add event listeners to remove buttons
document.querySelectorAll('.remove-btn').forEach(button => {
button.addEventListener('click', async (e) => {
const extensionId = e.target.getAttribute('data-id');
const result = await window.extensionsAPI.removeExtension(extensionId);
if (result.success) {
loadExtensions(); // Refresh list
} else {
alert('Failed to remove extension: ' + (result.message || 'Unknown error'));
}
});
});
} catch (error) {
console.error('Error loading extensions:', error);
alert('Failed to load extensions: ' + error.message);
}
}
// Install button click handler
document.getElementById('install-extension').addEventListener('click', async () => {
try {
const result = await window.extensionsAPI.openFileDialog();
if (result.success) {
loadExtensions(); // Refresh list
} else if (result.message) {
alert(result.message);
}
} catch (error) {
console.error('Error installing extension:', error);
alert('Failed to install extension: ' + error.message);
}
});
// Load extensions when page loads
document.addEventListener('DOMContentLoaded', loadExtensions);
</script>
</body>
</html>

View file

@ -16,6 +16,8 @@
<button onclick="stop(); return false;" id="stopBtn">🛑</button> <button onclick="stop(); return false;" id="stopBtn">🛑</button>
<button onclick="back(); return false;" id="backBtn">⬅️</button> <button onclick="back(); return false;" id="backBtn">⬅️</button>
<button onclick="forward(); return false;" id="forwardBtn">➡️</button> <button onclick="forward(); return false;" id="forwardBtn">➡️</button>
<button id="camBtn">🎦</button>
<button id="extBtn" title="Manage Extensions">🧩</button>
</div> </div>
<div id="whProtection"> <div id="whProtection">
<tab-group new-tab-button="true" sortable="true"> <tab-group new-tab-button="true" sortable="true">
@ -23,7 +25,6 @@
</tab-group> </tab-group>
</div> </div>
<script src="node_modules/electron-tabs/dist/electron-tabs.js"></script> <script src="node_modules/electron-tabs/dist/electron-tabs.js"></script>
<script type="text/javascript" src="./userscript/userscripts.js"></script>
<script type="text/javascript" src="./config.js"></script> <script type="text/javascript" src="./config.js"></script>
<script type="text/javascript" src="./libbrowz.js"></script> <script type="text/javascript" src="./libbrowz.js"></script>
</body> </body>

View file

@ -1,3 +1,5 @@
<!-- This is the Sneedium new tab page. -->
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -11,6 +13,7 @@
<img src="logo.png" align="right" width="20%"/> <img src="logo.png" align="right" width="20%"/>
<h1>Welcome to Sneedium!</h1> <h1>Welcome to Sneedium!</h1>
<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.</p> <p>Welcome to the Sneedium Browser! You can easily compile for for macOS, Windows, and Linux as of the time of writing this. We hope you enjoy this browser as much as we did making it.</br></br>From all of us at Sneed Group.
</p>
</body> </body>
</html> </html>

View file

@ -6,9 +6,7 @@ const userAgents = [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Edg/98.0.0.0", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Edg/98.0.0.0",
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Firefox/128.0"
]; ];
function getRandomUserAgent() { function getRandomUserAgent() {
@ -48,8 +46,8 @@ function go() {
let browser = tabGroup.getActiveTab() let browser = tabGroup.getActiveTab()
url = normalizeUrl(document.getElementById("txtUrl").value) url = normalizeUrl(document.getElementById("txtUrl").value)
if (url.includes("youtube.com") || url.includes("youtu.be")) { if (url.includes("youtube.com") || url.includes("youtu.be")) {
url = url.replaceAll("youtube.com", "invidious.nerdvpn.de") url = url.replaceAll("youtube.com", "samtube.nodemixaholic.com")
url = url.replaceAll("youtu.be", "invidious.nerdvpn.de") url = url.replaceAll("youtu.be", "samtube.nodemixaholic.com")
} else if (url.includes("google.com/search?q") || url.includes("google.com/?q")) { } else if (url.includes("google.com/search?q") || url.includes("google.com/?q")) {
// Define the URL object // Define the URL object
const serachUrlObj = new URL(url); const serachUrlObj = new URL(url);
@ -60,7 +58,7 @@ function go() {
url = searchPattern.replaceAll("!!!QUERY!!!", query) url = searchPattern.replaceAll("!!!QUERY!!!", query)
} else if (url.includes("https://news.google.com")) { } else if (url.includes("https://news.google.com")) {
url = url.replaceAll("https://news.google.com", "http://68k.news") url = url.replaceAll("https://news.google.com", "http://68k.news")
} else if (url.includes("google.com") && !url.includes("maps") && !url.includes("news") && !url.includes("webstore") && !url.includes("drive") && !url.includes("docs") && !url.includes("sheets") && !url.includes("slides") && !url.includes("mail")) { } else if (url.includes("google.com") && !url.includes("maps") && !url.includes("news") && !url.includes("webstore") && !url.includes("drive") && !url.includes("docs") && !url.includes("sheets") && !url.includes("slides") && !url.includes("mail") && !url.includes("webstore") && !url.includes("in") && !url.includes("on") && !url.includes("jp")) {
url = url.replaceAll("google.com", "search.sparksammy.com") url = url.replaceAll("google.com", "search.sparksammy.com")
} }
document.getElementById("txtUrl").value = "" document.getElementById("txtUrl").value = ""
@ -79,11 +77,6 @@ function go() {
tabGroup.getActiveTab().setTitle(title) tabGroup.getActiveTab().setTitle(title)
console.log(title) console.log(title)
}) })
for (let i = 0; i < userscripts.length; i++) {
fetch(userscripts[i]).then( r => r.text() ).then( t => userscripts.executeJavaScript(t)).catch(() => {
console.log("Error loading userscripts! (Did you provide any?)")
})
}
} }
function stop() { function stop() {

251
main.js
View file

@ -1,199 +1,74 @@
// Modules to control application life and create native browser window /**
const {app, BrowserWindow, session, ipcMain} = require('electron') * Sneedium Browser - Main Process
const path = require('path') *
const fetch = require("cross-fetch") * This is the main entry point for the Electron application.
const { ElectronChromeExtensions } = require('electron-chrome-extensions') * It initializes all necessary modules and manages application lifecycle.
const { ElectronBlocker } = require('@cliqz/adblocker-electron'); */
const { app, BrowserWindow, ipcMain, session } = require('electron');
const http = require('http'); const http = require('http');
const { createProxy } = require('proxy'); const { createProxy } = require('proxy');
ipcMain.on('windowmaker', (event, arg) => { // Import our modular components
createWindow(); const initExtensionManager = require('./extension-manager');
}) const initAdBlocker = require('./ad-blocker');
const initWindowManager = require('./window-manager');
// Create HTTP proxy server
const proxy = createProxy(http.createServer()); const proxy = createProxy(http.createServer());
proxy.listen(3129) proxy.listen(3129);
//Function to enable AD Blocking and extensions...
let blocker = undefined // Initialize our modules
let extensions = undefined const extensionManager = initExtensionManager();
async function enableGoodies(s) { const adBlocker = initAdBlocker(session.defaultSession);
blocker = await ElectronBlocker.fromLists(fetch, [ const windowManager = initWindowManager(adBlocker, extensionManager);
'https://easylist.to/easylist/easylist.txt',
'https://secure.fanboy.co.nz/fanboy-annoyance.txt', // Handle IPC messages from renderer process
'https://easylist.to/easylist/easyprivacy.txt', setupIpcHandlers();
'https://easylist-downloads.adblockplus.org/antiadblockfilters.txt',
'https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/nocoin.txt', /**
'https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/pro.plus.txt' * Set up IPC handlers for renderer process
]) */
blocker.enableBlockingInSession(s); function setupIpcHandlers() {
extensions = new ElectronChromeExtensions({ // Create a new window when requested
session: s ipcMain.on('windowmaker', () => {
}) windowManager.createWindow();
});
// Request media access permissions
ipcMain.on('allowCam', () => {
windowManager.setMediaAccess();
});
} }
// 0.0.0.0 day fix // This method will be called when Electron has finished initialization
const locals = [ // and is ready to create browser windows.
'0.0.0.0', '127.0.0.1', '192.168', '.local', '.example', '.staging', 'fe80::', '::1'
];
// Function to check if a URL is restricted
function isLocal(url) {
return locals.some(local => url.includes(local));
}
function createWindow () {
const mainWindow = new BrowserWindow({
width: 1100,
height: 600,
minWidth: 1100,
minHeight: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
webviewTag: true,
devTools: false,
nodeIntegration: true,
sandbox: true,
contextIsolation: true
}
})
mainWindow.removeMenu()
mainWindow.setMinimumSize(1000, 300)
const toBlock = [
"*://*.doubleclick.*",
"*://s.innovid.com/*",
"*://partner.googleadservices.com/*",
"*://*.googlesyndication.com/*",
"*://*.google-analytics.com/*",
"*://creative.ak.fbcdn.net/*",
"*://*.adbrite.com/*",
"*://*.exponential.com/*",
"*://*.quantserve.com/*",
"*://*.scorecardresearch.com/*",
"*://*.zedo.com/*",
"*://*.a-ads.com/*",
"*://*.777partner.com/*",
"*://*.77tracking.com/*",
"*://*.abc-ads.com/*",
"*://*.aaxads.com/*",
"*://*.adizio.com/*",
"*://*.adjix.com/*",
"*://*.adjug.com/*",
"*://*.adjuggler.com/*",
"*://*.trafficjunky.net/*",
"*://*.trafficleader.com/*",
"*://*.trafficrouter.io/*",
"*://*.monerominer.rocks/*",
"*://*.2mdn.net/*",
"*.exe",
"*.vbs",
"*://*.googlesyndication.*",
"*pixels*",
"*telemetry*",
"*analytics*",
"*://ads.*.com*",
"*ae/us/audience*",
"*/api/v*/science*",
"*/api/v*/typing*"
]
const regexPatterns = [
"r[0-100]+---sn-.*\.googlevideo\.com$/g",
"r[0-100]+-sn-.*\.googlevideo\.com$/g"
]
function containsAD(url) {
var i;
for (i = 0; i < toBlock.length; i++) {
let regex = toBlock[i].replace(/\*/g, "[^ ]*");
if (url.match(regex)) {
return true;
}
}
for (i = 0; i < regexPatterns.length; i++) {
let regex = regexPatterns[i]
if (url.match(regex)) {
return true;
}
}
return false;
}
session.defaultSession.setProxy({
proxyRules: 'http=localhost:3129;https=localhost:3129',
proxyBypassRules: '<local>'
})
session.defaultSession.webRequest.onBeforeRequest((details, callback) => {
if (containsAD(details.url)) {
return callback({cancel: true})
}
const url = new URL(details.url);
const hostname = url.hostname;
const isLocalDomain = isLocal(hostname);
// Check if the request is to a local domain
if (isLocalDomain) {
// Check if the request is initiated by a remote domain
const initiator = details.initiator ? new URL(details.initiator).hostname : '';
const isInitiatorLocal = isLocal(initiator);
if (initiator && !isInitiatorLocal) {
console.log(`[W] Local domain is being accessed by external source (${initiator}), don't allow!`);
callback({ cancel: true }); // Block request to local domains from remote sources
} else {
//console.log("Local domain is not being accessed by external source, allow..."); // debug
callback({ cancel: false }); // Allow request
}
} else {
//console.log("Request is not to a local domain, allow..."); //debug
callback({ cancel: false }); // Allow non-local requests
}
})
// and load the index.html of the app.
mainWindow.loadFile('index.html')
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(() => { app.whenReady().then(() => {
let x = createWindow() // Create main window
enableGoodies().then() const mainWindow = windowManager.createWindow();
// Enable ad blocking
adBlocker.enableAdBlocking(session.defaultSession).then(() => {
console.log("Ad blocking enabled");
}).catch(error => {
console.error("Error enabling ad blocking:", error);
});
// On macOS it's common to re-create a window when the
// dock icon is clicked and there are no other windows open
app.on('activate', function () { app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the if (BrowserWindow.getAllWindows().length === 0) windowManager.createWindow();
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
// Set DNS
app.on('ready', () => {
app.configureHostResolver({
mode: 'secure',
dohServers: [
'https://dns9.quad9.net/dns-query',
'https://cloudflare-dns.com/dns-query'
]
}); });
}); });
// Quit when all windows are closed, except on macOS
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});
// Set up DNS configuration when app is ready
app.on('ready', () => {
windowManager.setupDnsConfig();
});

1300
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,14 @@
{ {
"name": "sneedium", "name": "sneedium",
"version": "1.0.0", "version": "1.0.0",
"description": "A Electron browser", "description": "A Electron browser with Chrome extension support",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"start": "electron-forge start", "start": "electron-forge start",
"package": "electron-forge package", "package": "electron-forge package",
"make": "npx electron-packager --platform linux,win32 --arch x64,arm64 ." "make": "npx electron-packager --platform linux,win32 --arch x64,arm64 .",
"make-mac": "npx electron-packager --platform darwin --arch x64,arm64 .",
"dev": "cross-env NODE_ENV=development electron ."
}, },
"repository": "https://github.com/Sneed-Group/sneedium", "repository": "https://github.com/Sneed-Group/sneedium",
"keywords": [ "keywords": [
@ -14,7 +16,9 @@
"quick", "quick",
"start", "start",
"tutorial", "tutorial",
"demo" "demo",
"browser",
"extension"
], ],
"author": "Sneed Group", "author": "Sneed Group",
"license": "SPL-R5", "license": "SPL-R5",
@ -25,13 +29,17 @@
"@electron-forge/maker-rpm": "^6.0.5", "@electron-forge/maker-rpm": "^6.0.5",
"@electron-forge/maker-squirrel": "^6.0.5", "@electron-forge/maker-squirrel": "^6.0.5",
"@electron-forge/maker-zip": "^6.0.5", "@electron-forge/maker-zip": "^6.0.5",
"cross-env": "^7.0.3",
"electron": "^31.0.1", "electron": "^31.0.1",
"electron-forge-maker-appimage": "^25.0.5", "electron-forge-maker-appimage": "^24.6.3",
"electron-packager": "^17.1.2" "electron-packager": "^17.1.2"
}, },
"dependencies": { "dependencies": {
"@cliqz/adblocker-electron": "^1.31.3", "@ghostery/adblocker": "^2.1.1",
"@ghostery/adblocker-electron": "^2.1.1",
"adm-zip": "^0.5.16",
"cross-fetch": "^3.1.5", "cross-fetch": "^3.1.5",
"electron-chrome-context-menu": "^1.1.0",
"electron-chrome-extensions": "^3.10.0", "electron-chrome-extensions": "^3.10.0",
"electron-squirrel-startup": "^1.0.1", "electron-squirrel-startup": "^1.0.1",
"electron-tabs": "^1.0.1", "electron-tabs": "^1.0.1",

View file

@ -10,6 +10,11 @@ const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electron', { contextBridge.exposeInMainWorld('electron', {
enforceDomainRestrictions: (url) => ipcRenderer.sendSync('check-domain', url), enforceDomainRestrictions: (url) => ipcRenderer.sendSync('check-domain', url),
// Add extension management functionality
extensions: {
openExtensionsPage: () => ipcRenderer.send('open-extensions-page'),
getExtensionsList: () => ipcRenderer.invoke('get-extensions-list')
}
}); });
@ -24,11 +29,32 @@ window.addEventListener('DOMContentLoaded', () => {
} }
ipcRenderer.on('windowmaker', (event, arg) => { ipcRenderer.on('windowmaker', (event, arg) => {
console.log(arg) // prints "pong" console.log(arg)
})
ipcRenderer.on('allowCam', (event, arg) => {
console.log(arg)
}) })
//button and its event listener //button and its event listener
const makeWindowButton = document.getElementById('nwBtn'); const makeWindowButton = document.getElementById('nwBtn');
makeWindowButton.addEventListener('click', () => { if (makeWindowButton) {
makeWindowButton.addEventListener('click', () => {
ipcRenderer.send('windowmaker', 'ping') ipcRenderer.send('windowmaker', 'ping')
}) });
}
const camButton = document.getElementById('camBtn');
if (camButton) {
camButton.addEventListener('click', () => {
ipcRenderer.send('allowCam', 'ping')
});
}
// Add extension management button event listener
const extensionsButton = document.getElementById('extBtn');
if (extensionsButton) {
extensionsButton.addEventListener('click', () => {
ipcRenderer.send('open-extensions-page');
});
}
}) })

View file

@ -5,3 +5,5 @@
* `contextIsolation` is turned on. Use the contextBridge API in `preload.js` * `contextIsolation` is turned on. Use the contextBridge API in `preload.js`
* to expose Node.js functionality from the main process. * to expose Node.js functionality from the main process.
*/ */
require('electron-chrome-extension/preload');

1
sneedium-maker-mac.sh Normal file
View file

@ -0,0 +1 @@
npm run make-mac

View file

@ -33,6 +33,17 @@ body {
font-size: 1.25rem; font-size: 1.25rem;
} }
#camBtn {
background-color: #a6b70d; /* Gold */
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;
@ -106,20 +117,24 @@ html, body {
align-items: center; /* Center vertically */ align-items: center; /* Center vertically */
} }
html, body {
height: 100%;
margin: 0;
}
#whProtection { #whProtection {
position: absolute; width: 100%; /* % of viewport width */
top: 50%; height: 100%; /* % of viewport height */
left: 50%; border: 2vw solid rgb(70, 70, 70); /* Border color and thickness */
bottom: 5%;
transform: translate(-50%, -46%); /* Offset by half the width and 46% height */
width: 90%; /* % of viewport width */
height: 86%; /* % of viewport height */
border: 1vw solid green; /* Border color and thickness */
box-sizing: border-box; box-sizing: border-box;
display: block;
overflow: scroll;
} }
webview { webview {
width: 100%; width: 100%;
height: 100%; height: 100%;
border: none; border: none;
box-sizing: border-box; /* Ensures any padding or border inside the webview is included in the total size */
display: block; /* Ensure it behaves as a block element */
} }

View file

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

150
window-manager.js Normal file
View file

@ -0,0 +1,150 @@
/**
* Window Manager Module
*
* Handles browser window creation and management for Sneedium browser
* - Creates main browser windows
* - Sets up context menu
* - Configures window properties
*/
const { app, BrowserWindow, session, systemPreferences } = require('electron');
const path = require('path');
const buildChromeContextMenu = require('electron-chrome-context-menu').default;
const { ElectronChromeExtensions } = require('electron-chrome-extensions');
// Track permissions state
let mic = false;
let cam = false;
/**
* Initialize window manager
* @param {Object} adBlocker - Ad blocker instance
* @param {Object} extensionManager - Extension manager instance
* @returns {Object} Window manager functions
*/
function initWindowManager(adBlocker, extensionManager) {
// Set up context menu handler
setupContextMenu();
let extensionsInstance = null;
return {
createWindow: () => createWindow(extensionsInstance, adBlocker, extensionManager),
setMediaAccess,
setupDnsConfig: () => setupDnsConfig()
};
}
/**
* Set up context menu for all web contents
*/
function setupContextMenu() {
app.on('web-contents-created', (event, webContents) => {
webContents.on('context-menu', (e, params) => {
const menu = buildChromeContextMenu({
params,
webContents,
openLink: (url, disposition) => {
webContents.loadURL(url);
}
});
menu.popup();
});
});
}
/**
* Create main browser window
* @param {Object} extensionsInstance - Chrome extensions instance
* @param {Object} adBlocker - Ad blocker instance
* @param {Object} extensionManager - Extension manager instance
* @returns {Object} Created browser window
*/
function createWindow(extensionsInstance, adBlocker, extensionManager) {
try {
// Initialize extensions once if not already initialized
if (!extensionsInstance) {
extensionsInstance = new ElectronChromeExtensions({
// Specify extension session
session: session.defaultSession,
// Set to true to enable background pages for extensions
createBackgroundPages: true
});
}
} catch (error) {
console.error("Error initializing extensions:", error);
}
const mainWindow = new BrowserWindow({
width: 1220,
height: 600,
minWidth: 1220,
minHeight: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
webviewTag: true,
// Enable devTools for development
devTools: process.env.NODE_ENV === 'development',
nodeIntegration: false,
sandbox: true,
contextIsolation: true,
// Enable Chrome extension support
additionalArguments: ['--enable-features=ExtensionsToolbarMenu'],
// Allow access to chrome:// URLs for extensions
allowRunningInsecureContent: false,
webSecurity: true
}
});
mainWindow.setMinimumSize(1000, 300);
// Load installed extensions
if (extensionManager && extensionsInstance) {
extensionManager.loadExtensions(extensionsInstance);
}
// Register window with extensions system
if (extensionsInstance) {
extensionsInstance.addTab(mainWindow.webContents, mainWindow);
}
// Set up proxy for the session
session.defaultSession.setProxy({
proxyRules: 'http=localhost:3129;https=localhost:3129',
proxyBypassRules: '<local>'
});
// Setup web request filters
if (adBlocker) {
adBlocker.setupWebRequestFilters(session.defaultSession);
}
// Load the main HTML file
mainWindow.loadFile('index.html');
return mainWindow;
}
/**
* Set media access permissions
*/
function setMediaAccess() {
mic = systemPreferences.askForMediaAccess('microphone');
cam = systemPreferences.askForMediaAccess('camera');
}
/**
* Set up secure DNS configuration
*/
function setupDnsConfig() {
app.configureHostResolver({
mode: 'secure',
dohServers: [
'https://dns9.quad9.net/dns-query',
'https://cloudflare-dns.com/dns-query'
]
});
}
module.exports = initWindowManager;