Skip to content

Instantly share code, notes, and snippets.

@codebytere
Last active July 14, 2025 09:11
Show Gist options
  • Save codebytere/237ddda00daa4fe47fe7b11a4abd9f61 to your computer and use it in GitHub Desktop.
Save codebytere/237ddda00daa4fe47fe7b11a4abd9f61 to your computer and use it in GitHub Desktop.
rainbow-accent
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using Node.js <span id="node-version"></span>,
Chromium <span id="chrome-version"></span>,
and Electron <span id="electron-version"></span>.
<script src="./renderer.js"></script>
</body>
</html>
const { app, BrowserWindow } = require('electron')
const path = require('node:path')
function createWindow () {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
frame: false,
accentColor: true,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
const rainbow = [
'#e81416',
'#ffa500',
'#faeb36',
'#79c314',
'#487de7',
'#4b369d',
'#70369d'
];
let idx = 0;
function getNext() {
const item = rainbow[idx];
idx = (idx + 1) % rainbow.length;
return item;
}
setInterval(() => {
const color = getNext();
mainWindow.setAccentColor(color)
}, 1000)
mainWindow.loadFile('index.html')
}
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
{
"name": "amazing-awareness-spit-7edfl",
"productName": "amazing-awareness-spit-7edfl",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "codebytere",
"scripts": {
"start": "electron ."
},
"dependencies": {},
"devDependencies": {
"electron": "35.7.0"
}
}
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
})
/**
* This file is loaded via the <script> tag in the index.html file and will
* be executed in the renderer process for that window. No Node.js APIs are
* available in this process because `nodeIntegration` is turned off and
* `contextIsolation` is turned on. Use the contextBridge API in `preload.js`
* to expose Node.js functionality from the main process.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment