-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectronEvents.js
More file actions
87 lines (74 loc) · 2.65 KB
/
electronEvents.js
File metadata and controls
87 lines (74 loc) · 2.65 KB
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
const { clipboard } = require('electron')
const username = require("os").userInfo().username
// clipboard.writeText('hello i am a bit of text!')
// function PasteElectron(){
// const text = clipboard.readText()
// console.log(text)
// }
// const { contextBridge, ipcRenderer } = require('electron');
// // var Data = {message: "Looking at their library", message2: ""};
// // ipcRenderer.send('request-mainprocess-action', Data);
// const API = {
// sendMsg: function(msg) {
// ipcRenderer.send('request-mainprocess-action', {message: msg[0], message2: msg[1]})
// }
// };
// contextBridge.exposeToMainWorld("api", API);
// updateDiscordRichPresence("bruh", "whyyy");
// const { contextBridge, ipcRenderer } = require("electron");
// contextBridge.exposeInMainWorld("api", API);
// var isApp = true
window.addEventListener("load", function(){
// console.log(username)
// console.log("hiiii")
// var electronStyle = this.document.createElement("style")
// electronStyle.innerText = "header{-webkit-app-region: drag;padding-right: 140px} header *{-webkit-app-region: no-drag;}"
// this.document.head.appendChild(electronStyle)
})
// Import the necessary Electron components.
const contextBridge = require('electron').contextBridge;
const ipcRenderer = require('electron').ipcRenderer;
// White-listed channels.
const ipc = {
'render': {
// From render to main.
'send': [
'window:minimize',
'window:maximize',
'window:restore',
'window:close'
],
// From main to render.
'receive': [],
// From render to main and back again.
'sendReceive': []
}
};
// Exposed protected methods in the render process.
contextBridge.exposeInMainWorld(
// Allowed 'ipcRenderer' methods.
'ipcRender', {
// From render to main.
send: (channel, args) => {
let validChannels = ipc.render.send;
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, args);
}
},
// From main to render.
receive: (channel, listener) => {
let validChannels = ipc.render.receive;
if (validChannels.includes(channel)) {
// Deliberately strip event as it includes `sender`.
ipcRenderer.on(channel, (event, ...args) => listener(...args));
}
},
// From render to main and back again.
invoke: (channel, args) => {
let validChannels = ipc.render.sendReceive;
if (validChannels.includes(channel)) {
return ipcRenderer.invoke(channel, args);
}
}
}
);