-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathv1bin.txt
104 lines (87 loc) · 2.64 KB
/
v1bin.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { app, BrowserWindow, shell } from 'electron';
import path from 'path';
import { config } from './config/index.js';
import { fileURLToPath } from 'url';
import electronContextMenu from 'electron-context-menu';
// Set up the context menu
electronContextMenu({
showSaveImageAs: true,
});
const appUrl = 'https://www.notion.so/login';
let window = null;
function onNewWindow(details) {
// Open URL directly in the default system browser for Google Sign-In popups
if (details.url.includes('accounts.google.com')) {
shell.openExternal(details.url); // Open Google Sign-In popup in the system browser
return { action: 'deny' };
}
return { action: 'allow' }; // Allow other popups
}
// Calculate __dirname for ES modules
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// Function to create the main application window
const createWindow = () => {
window = new BrowserWindow({
icon: path.join(__dirname, 'assets/icon.png'),
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
nativeWindowOpen: true, // Enables proper popup handling
preload: path.join(__dirname, 'preload.js'),
webSecurity: true,
},
});
// Load Notion login page
window.loadURL(appUrl, {
userAgent: config.userAgent,
});
window.webContents.setWindowOpenHandler((details) => {
return {
action: 'allow', // Allow popups by default
};
});
window.once('ready-to-show', () => {
window.maximize();
});
};
// Single instance lock
const appLock = app.requestSingleInstanceLock();
if (!appLock) {
app.quit();
} else {
app.on('second-instance', (event, args) => {
if (window) {
const url = processArgs(args);
if (url) {
window.loadURL(url, { userAgent: config.userAgent });
}
window.focus();
}
});
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
}
// Process arguments for the second instance
function processArgs(args) {
const regHttps = /^https:\/\/www\.notion\.so\/.*/g;
const regNotion = /^notion:\/\//g;
for (const arg of args) {
if (regHttps.test(arg)) {
return arg;
}
if (regNotion.test(arg)) {
return appUrl + arg.substring(11);
}
}
return null;
}