-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (27 loc) · 931 Bytes
/
index.js
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
const getWindowsProxy = require('@cypress/get-windows-proxy');
const regedit = require('./node_modules/registry-js/build/Release/registry.node');
process.env.TZ = 'Europe/Istanbul';
const HKCU = 0x80000001; // HKEY_CURRENT_USER
const day = 60 * 60 * 24; // 1 day
const restartTime = (7 - 3) * 3600 + 45 * 60; // 07:45:00
setInterval(async function () {
const proxyEnable = (
await regedit.readValues(
HKCU,
'Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings'
)
).find((x) => x?.name === 'ProxyEnable');
if (proxyEnable?.data === 1)
console.log(
new Date().toLocaleString(),
'regedit.setValue: ',
regedit.setValue(
HKCU,
'Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
'ProxyEnable',
'REG_DWORD',
'0'
)
);
if (parseInt((+new Date() / 1000) % day, 10) === restartTime) process.exit(0);
}, 1000);