Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 10361cf3c0 |
15
main.js
15
main.js
@@ -110,6 +110,7 @@ let pendingNavigate = null; // { view, url } — cross-domain redirect awaiting
|
|||||||
function getProxySession() {
|
function getProxySession() {
|
||||||
if (!proxySession) {
|
if (!proxySession) {
|
||||||
proxySession = session.fromPartition('persist:proxy');
|
proxySession = session.fromPartition('persist:proxy');
|
||||||
|
proxySession.setUserAgent(app.userAgentFallback);
|
||||||
enableBlockingInSession(proxySession);
|
enableBlockingInSession(proxySession);
|
||||||
}
|
}
|
||||||
return proxySession;
|
return proxySession;
|
||||||
@@ -118,6 +119,7 @@ function getProxySession() {
|
|||||||
function getDirectSession() {
|
function getDirectSession() {
|
||||||
if (!directSession) {
|
if (!directSession) {
|
||||||
directSession = session.fromPartition('persist:direct');
|
directSession = session.fromPartition('persist:direct');
|
||||||
|
directSession.setUserAgent(app.userAgentFallback);
|
||||||
directSession.setProxy({ proxyRules: 'direct://' });
|
directSession.setProxy({ proxyRules: 'direct://' });
|
||||||
enableBlockingInSession(directSession);
|
enableBlockingInSession(directSession);
|
||||||
}
|
}
|
||||||
@@ -981,6 +983,19 @@ ipcMain.on('action', (_event, action) => {
|
|||||||
// --- App lifecycle ---
|
// --- App lifecycle ---
|
||||||
|
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
|
// Strip Electron/app tokens from User-Agent: Google blocks Electron's default UA
|
||||||
|
// with "Поддержка JavaScript отключена" on accounts.google.com. We keep the Chrome
|
||||||
|
// version Electron advertises (sufficient for modern features) but remove the
|
||||||
|
// Electron/X.X.X and ESH-Media/X.X.X identifiers.
|
||||||
|
const cleanUserAgent = app.userAgentFallback
|
||||||
|
.replace(/Electron\/[\d.]+\s*/g, '')
|
||||||
|
.replace(/ESH-Media\/[\d.]+\s*/g, '')
|
||||||
|
.replace(/\s+/g, ' ')
|
||||||
|
.trim();
|
||||||
|
console.log('[ua]', cleanUserAgent);
|
||||||
|
app.userAgentFallback = cleanUserAgent;
|
||||||
|
session.defaultSession.setUserAgent(cleanUserAgent);
|
||||||
|
|
||||||
// Add Referer to image requests so hotlink protection doesn't block them
|
// Add Referer to image requests so hotlink protection doesn't block them
|
||||||
session.defaultSession.webRequest.onBeforeSendHeaders(
|
session.defaultSession.webRequest.onBeforeSendHeaders(
|
||||||
{ urls: ['https://*/*', 'http://*/*'] },
|
{ urls: ['https://*/*', 'http://*/*'] },
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ESH-Media",
|
"name": "ESH-Media",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const Header: React.FC<HeaderProps> = ({ activeApp, setActiveApp, onAppsChange,
|
|||||||
const [rightDisabled, setRightDisabled] = useState(true)
|
const [rightDisabled, setRightDisabled] = useState(true)
|
||||||
const [refreshDisabled, setRefreshDisabled] = useState(true)
|
const [refreshDisabled, setRefreshDisabled] = useState(true)
|
||||||
const [showSettings, setShowSettings] = useState(false)
|
const [showSettings, setShowSettings] = useState(false)
|
||||||
|
const [currentUrl, setCurrentUrl] = useState<string>('')
|
||||||
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||||
const activeAppRef = useRef(activeApp)
|
const activeAppRef = useRef(activeApp)
|
||||||
useEffect(() => { activeAppRef.current = activeApp }, [activeApp])
|
useEffect(() => { activeAppRef.current = activeApp }, [activeApp])
|
||||||
@@ -36,6 +37,7 @@ const Header: React.FC<HeaderProps> = ({ activeApp, setActiveApp, onAppsChange,
|
|||||||
setLeftDisabled(app.historyPosition === 0)
|
setLeftDisabled(app.historyPosition === 0)
|
||||||
setRightDisabled(app.historyPosition === app.history.length - 1)
|
setRightDisabled(app.historyPosition === app.history.length - 1)
|
||||||
setRefreshDisabled(false)
|
setRefreshDisabled(false)
|
||||||
|
setCurrentUrl(app.history[app.historyPosition] || '')
|
||||||
})
|
})
|
||||||
return () => { offCloseApp(); offWebButtons() }
|
return () => { offCloseApp(); offWebButtons() }
|
||||||
}, [setActiveApp])
|
}, [setActiveApp])
|
||||||
@@ -149,12 +151,9 @@ const Header: React.FC<HeaderProps> = ({ activeApp, setActiveApp, onAppsChange,
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!appOpen) { setIsBookmarked(false); return }
|
if (!appOpen || !currentUrl) { setIsBookmarked(false); return }
|
||||||
window.electron?.getCurrentPage().then((page: any) => {
|
setIsBookmarked(bookmarks.some(b => b.url === currentUrl))
|
||||||
if (!page) return
|
}, [currentUrl, bookmarks, appOpen])
|
||||||
setIsBookmarked(bookmarks.some(b => b.url === page.url))
|
|
||||||
})
|
|
||||||
}, [activeApp, bookmarks, appOpen])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user