49 lines
2.2 KiB
JavaScript
49 lines
2.2 KiB
JavaScript
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
// ── Inject styles for Electron titlebar overlay compatibility ─────────────────
|
|
// Adds top padding so the 38px system buttons don't cover the site's nav bar.
|
|
// Also makes the nav bar draggable so the user can move the window.
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
const style = document.createElement('style');
|
|
style.textContent = `
|
|
/* Reserve space for Windows titlebar overlay (38px) */
|
|
body { padding-top: 38px !important; }
|
|
/* Make the top nav draggable (window drag region) */
|
|
.topnav {
|
|
-webkit-app-region: drag !important;
|
|
margin-top: -38px !important;
|
|
padding-top: 38px !important;
|
|
height: calc(var(--nav, 52px) + 38px) !important;
|
|
/* Reserve right side for min/max/close buttons (≈138px on Windows) */
|
|
padding-right: 148px !important;
|
|
box-sizing: border-box !important;
|
|
}
|
|
/* All interactive elements inside the nav must NOT be drag targets */
|
|
.topnav *, .topnav button, .topnav a, .topnav input,
|
|
.topnav [onclick], .topnav [tabindex] {
|
|
-webkit-app-region: no-drag !important;
|
|
}
|
|
/* Hide Windows download prompts — already in the app */
|
|
.sb-dl-app, .dl-app-banner, #dl-app-banner,
|
|
[class*="dl-app"], [id*="dl-app"] {
|
|
display: none !important;
|
|
}
|
|
/* Push fullscreen player close button below the 38px native titlebar */
|
|
.fs-overlay .fs-top {
|
|
padding-top: 46px !important;
|
|
}
|
|
`;
|
|
document.head.appendChild(style);
|
|
});
|
|
|
|
// ── Minimal Electron API (future extensibility) ───────────────────────────────
|
|
contextBridge.exposeInMainWorld('electronApp', {
|
|
isElectron: true,
|
|
getVersion: () => ipcRenderer.invoke('get-version'),
|
|
storeGet: (k) => ipcRenderer.invoke('store-get', k),
|
|
storeSet: (k, v) => ipcRenderer.invoke('store-set', k, v),
|
|
storeDelete: (k) => ipcRenderer.invoke('store-delete', k),
|
|
// DRM cache management (can be called from the site's settings page)
|
|
cacheSize: () => ipcRenderer.invoke('cache-size'),
|
|
cacheClear: () => ipcRenderer.invoke('cache-clear'),
|
|
});
|