summarylogtreecommitdiffstats
path: root/patch
blob: 7a69614adf2de5894f54370b12c2497a1c4025bb (plain)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
diff --git a/engine.js b/engine.js
index cad99c3..22e7c38 100644
--- a/engine.js
+++ b/engine.js
@@ -5,10 +5,10 @@ const path = require('path')
 const electron = require('electron')
 const { ipcMain, webContents, app, globalShortcut } = electron;
 const sqlite3 = require('sqlite3').verbose()
-const robot = require("robotjs")
+const robot = require("node-key-sender")
 let db;
 const schedule = require('node-schedule')
-const activeWin = require('active-win-lite')
+const activeWin = require('active-win')
 const Store = require('electron-store')
 const uuidv4 = require('uuid/v4')
 const utils = require('./utils')
@@ -191,7 +191,7 @@ function get_appusage_data(day_id) {
 
             notify_windows('appusage_data', {
                 rows: rows,
-                lock: store.get('lock'),
+                lock: false,
                 uuid: UUID
             })
 
@@ -211,7 +211,7 @@ function get_trend_data(start_day_id, end_day_id) {
 
             notify_windows('trend_data', {
                 rows: rows,
-                lock: store.get('lock'),
+                lock: false,
                 uuid: UUID,
                 chart_fill: store.get('chart_fill'),
                 chart_tension: store.get('chart_tension')
@@ -409,32 +409,9 @@ function tick_tock() {
     }
     */
     activeWin().then(result => {
-        if (result.app == '') {
-            console.log('empty app')
-        } else {
+        let appName = result.title;
+        if(true){
             console.log(new Date().toLocaleTimeString(), result)
-
-            let appName = result.app
-
-            if (utils.is_win()) {
-                if (result.app == "ApplicationFrameHost.exe") {
-                    //UWP应用,并且对Edge特别处理一下
-                    appName = "UWP application"
-                    if (result.title.includes('Microsoft Edge')) {
-                        appName = "Microsoft Edge"
-                    }
-                } else {
-                    //win32 通过appPath和fdc获取文件的description来作为名字
-                    if (result.appPath in win32_apppath_filedesc) {
-                    } else {
-                        let file_desc = fdc.get_file_desc(result.appPath)
-                        //如果file desc是空的,则仍旧使用appName
-                        win32_apppath_filedesc[result.appPath] = file_desc.length > 0 ? file_desc : appName
-                    }
-                    appName = win32_apppath_filedesc[result.appPath]
-                }
-            }
-
             console.log('AppName=', appName)
             if (appName in last_minute_active_win_map) {
                 last_minute_active_win_map[appName] += TICK_STEP
@@ -882,14 +859,14 @@ ipcMain.on('unlock', function (e, data) {
 })
 
 ipcMain.on('check_lock', function (e, data) {
-    notify_windows('check_lock_result', store.get('lock'))
+    notify_windows('check_lock_result', false)
 })
 
 function check_auto_unlock() {
 
     if (TEST_LOCK) return;
 
-    if (store.get('lock')) {
+    if (false) {
         if (!store.has('lock_day')) {
             store.set('lock_day', utils.gen_day_id())
         }
@@ -948,7 +925,7 @@ function shortcut_callback_enter() {
     last_minute_keyboard_stroke_energy += 5
     last_tick_keyboard_stroke += 1
     globalShortcut.unregister('enter')
-    robot.keyTap("enter")
+    robot.sendKey("enter")
     const ret = globalShortcut.register('enter', shortcut_callback_enter)
     if (!ret) {
         console.log('[Error] hotkey enter failed')
@@ -960,7 +937,7 @@ function shortcut_callback_backspace() {
     last_minute_keyboard_stroke_energy += 5
     last_tick_keyboard_stroke += 1
     globalShortcut.unregister('backspace')
-    robot.keyTap("backspace")
+    robot.sendKey("backspace")
     const ret = globalShortcut.register('backspace', shortcut_callback_backspace)
     if (!ret) {
         console.log('[Error] hotkey backspace failed')
@@ -1006,7 +983,7 @@ function shortcut_callback_up() {
     last_minute_keyboard_stroke_energy += 5
     last_tick_keyboard_stroke += 1
     globalShortcut.unregister('up')
-    robot.keyTap("up")
+    robot.sendKey("up")
     const ret = globalShortcut.register('up', shortcut_callback_up)
     if (!ret) {
         console.log('[Error] hotkey up failed')
@@ -1019,7 +996,7 @@ function shortcut_callback_down() {
     last_minute_keyboard_stroke_energy += 5
     last_tick_keyboard_stroke += 1
     globalShortcut.unregister('down')
-    robot.keyTap("down")
+    robot.sendKey("down")
     const ret = globalShortcut.register('down', shortcut_callback_down)
     if (!ret) {
         console.log('[Error] hotkey down failed')
@@ -1038,4 +1015,4 @@ function load_juzi() {
             console.log('juzi.json not exist, use default')
         }
     })
-}
\ No newline at end of file
+}
diff --git a/fdc.js b/fdc.js
index cbabce0..4474f18 100644
--- a/fdc.js
+++ b/fdc.js
@@ -1,5 +1,5 @@
-
-const ffi = require('ffi');
+const electron = require('electron');
+const ffi = require('ffi-napi');
 const iconv = require('iconv-lite');
 const os = require('os');
 
diff --git a/index.js b/index.js
index 945a15e..77fcefb 100644
--- a/index.js
+++ b/index.js
@@ -970,10 +970,10 @@ function open_settings_window() {
 
 // MOVING COUNT
 function refresh_moving_count() {
-  $.get("http://adicons.boringuniverse.com/ct/r", function (response, body) {
+  $.get("https://example.com/", function (response, body) {
     //更新字面
     console.log(response)
-    my_set_text('second_comment', locale.g(`Live online ${response.moving}/${response.total}`, `Live Online ${response.moving}/${response.total}`))
+    my_set_text('second_comment', locale.g(`Live online ${114514}/${1919810}`, `Live Online ${114514}/${1919810}`))
     console.log('set second_comment')
   })
 }
@@ -1054,7 +1054,7 @@ function may_check_update() {
 
 
 function check_update() {
-  $.get("http://afcapp.boringuniverse.com/version.json", function (response, body) {
+  $.get("https://example.com/", function (response, body) {
 
     let myVerCode = utils.version_string_2_code(electron.remote.app.getVersion())
 
@@ -1114,4 +1114,4 @@ electron.ipcRenderer.on('chart_tension_change', (event, data) => {
     mychart.update()
   }
 
-})
\ No newline at end of file
+})
diff --git a/main.js b/main.js
index fe32fcd..e338950 100644
--- a/main.js
+++ b/main.js
@@ -4,11 +4,13 @@ const utils = require('./utils')
 
 // Single instance
 if (utils.is_win()) {
-  if (app.makeSingleInstance(single_instance_callback)){
-    //第二个进程,直接退出
-    console.log('second instance, quit imediately')
-    app.exit(0)
-  }
+  app.requestSingleInstanceLock();
+  app.on('second-instance', ()=>{console.log('second instance, quit imediately')
+  app.exit(0)});
+  // if (app.makeSingleInstance(single_instance_callback)){
+  //   //第二个进程,直接退出
+    
+  // }
 }
 
 function single_instance_callback(argv, workdir){
@@ -209,7 +211,11 @@ var mb = menubar({
     protocol: 'file:',
     slashes: true
   }),
-  preloadWindow: true
+  preloadWindow: true,
+  webPreferences:{
+    nodeIntegration: true,
+    contextIsolation: false,
+  }
 })
 
 
@@ -229,7 +235,7 @@ function createMainWindow() {
 
     // Create the browser window.
     mainWindow = new BrowserWindow({
-      webPreferences: { webSecurity: false }, //关闭同源检查,为了ad页面可以调用electron来在外部浏览器打开url
+      webPreferences: { webSecurity: false,nodeIntegration:true,webviewTag:true,enableRemoteModule:true,contextIsolation: false, }, //关闭同源检查,为了ad页面可以调用electron来在外部浏览器打开url
       width: 1060,
       height: utils.is_win() ? 575 : 565,
       icon: path.join(__dirname, 'images/icon.png') //无效果TODO
@@ -279,7 +285,7 @@ function createSettingWindow() {
     settingWindow.show()
   } else {
     settingWindow = new BrowserWindow({
-      webPreferences: { webSecurity: false },
+      webPreferences: { webSecurity: false,nodeIntegration:true,webviewTag:true,enableRemoteModule:true,contextIsolation: false, },
       width: 300,
       height: utils.is_win() ? 540 : 520
     })
@@ -353,7 +359,7 @@ let shareWindow
 function createShareWindow() {
 
   shareWindow = new BrowserWindow({
-    webPreferences: { webSecurity: false },
+    webPreferences: { webSecurity: false,nodeIntegration:true,webviewTag:true,enableRemoteModule:true,contextIsolation: false, },
     width: 300,
     height: utils.is_win() ? 530 : 500
   })
@@ -392,7 +398,7 @@ function openCheckUpdateWindow() {
     checkUpdateWindow.show()
   } else {
     checkUpdateWindow = new BrowserWindow({
-      webPreferences: { webSecurity: false },
+      webPreferences: { webSecurity: false,nodeIntegration:true,webviewTag:true,enableRemoteModule:true,contextIsolation: false, },
       width: 300,
       height: 500
     })
@@ -444,7 +450,7 @@ function openAboutWindow() {
     aboutWindow.show()
   } else {
     aboutWindow = new BrowserWindow({
-      webPreferences: { webSecurity: false },
+      webPreferences: { webSecurity: false,nodeIntegration:true,webviewTag:true,enableRemoteModule:true,contextIsolation: false, },
       width: 300,
       height: 500
     })