@@ -7,13 +7,16 @@ global.browser = require('webextension-polyfill');
7
7
8
8
const isFirefox = navigator . userAgent . toUpperCase ( ) . indexOf ( 'Firefox' ) ? true : false ;
9
9
const isChrome = window . navigator . userAgent . indexOf ( 'Chrome' ) !== - 1 ;
10
+ const isEdge = navigator . userAgent . indexOf ( 'Edg' ) !== - 1 ;
10
11
11
12
//清空之前版本的数据
12
13
if ( window . localStorage . curt_index === undefined ) {
13
14
window . localStorage . clear ( ) ;
14
15
indexedDB . deleteDatabase ( 'bookmarks' ) ;
15
16
}
16
17
18
+ const debug = process . env . NODE_ENV === 'development' ;
19
+
17
20
// 检测新标签页,控制迷你和full版本
18
21
chrome . tabs . onUpdated . addListener ( ( tabId , changeInfo , tab ) => {
19
22
if ( isChrome ) {
@@ -34,10 +37,12 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
34
37
}
35
38
}
36
39
}
37
- if ( tab . url === 'edge://newtab/' ) {
38
- if ( store . getters . config . mini === false ) {
39
- const url = chrome . runtime . getURL ( 'tab/tab.html' ) ;
40
- chrome . tabs . update ( tabId , { url } ) ;
40
+ if ( isEdge ) {
41
+ if ( tab . url === 'edge://newtab/' ) {
42
+ if ( store . getters . config . mini === false ) {
43
+ const url = chrome . runtime . getURL ( 'tab/tab.html' ) ;
44
+ chrome . tabs . update ( tabId , { url } ) ;
45
+ }
41
46
}
42
47
}
43
48
} ) ;
@@ -68,16 +73,17 @@ const GetUid = {
68
73
const uid = GetUid . get ( ) ;
69
74
70
75
//google analytics
71
- let currentVersion = '3_0_3 ' ;
76
+ let currentVersion = '3_0_4 ' ;
72
77
if ( isChrome ) {
73
78
currentVersion = `chrome_${ currentVersion } ` ;
74
- }
75
- if ( isFirefox ) {
79
+ } else if ( isFirefox ) {
76
80
currentVersion = `firefox_${ currentVersion } ` ;
81
+ } else if ( isEdge ) {
82
+ currentVersion = `edge_${ currentVersion } ` ;
77
83
}
78
84
const gaID = 'UA-64832923-4' ;
79
- const gaObj = new GA ( gaID , uid ) ;
80
- function sendEvent ( eventCategory , eventAction , eventLabel = '' , eventValue = '' ) {
85
+ const gaObj = new GA ( gaID , uid , debug ) ;
86
+ function sendEvent ( eventCategory , eventAction , eventLabel = '' , eventValue = 1 ) {
81
87
if ( store . getters . config . ga === false ) return ;
82
88
gaObj . ga ( 'event' , eventCategory , eventAction , eventLabel , eventValue ) ;
83
89
}
@@ -253,7 +259,7 @@ chrome.bookmarks.onRemoved.addListener((id, removeInfo) => {
253
259
// 安装/升级检测
254
260
chrome . runtime . onInstalled . addListener ( detail => {
255
261
if ( detail . reason == 'update' ) {
256
- sendEvent ( currentVersion , 'update_extension' , uid , '' ) ;
262
+ sendEvent ( currentVersion , 'update_extension' , uid , 1 ) ;
257
263
// 弹出推广页面
258
264
window . open ( 'https://creatorsdaily.com/9999e88d-0b00-46dc-8ff1-e1d311695324' ) ;
259
265
return ;
@@ -268,7 +274,7 @@ chrome.runtime.onInstalled.addListener(detail => {
268
274
) ;
269
275
}
270
276
if ( detail . reason === 'install' ) {
271
- sendEvent ( currentVersion , 'install_extension' , uid , '' ) ;
277
+ sendEvent ( currentVersion , 'install_extension' , uid , 1 ) ;
272
278
console . log ( 'installed' ) ;
273
279
// 初始化数据
274
280
BookmarkLib . init ( ) ;
0 commit comments