From 3c09555baef55920030ed84473c7deb732877dc1 Mon Sep 17 00:00:00 2001 From: DrowsyFlesh Date: Sun, 9 Dec 2018 05:18:21 +0800 Subject: [PATCH] clean up code --- src/js/modules/background/index.js | 2 +- src/js/modules/googleAnalytics/index.js | 11 +++++------ src/manifest.json | 1 - 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/js/modules/background/index.js b/src/js/modules/background/index.js index 3995c92..90060fa 100644 --- a/src/js/modules/background/index.js +++ b/src/js/modules/background/index.js @@ -27,7 +27,7 @@ export class Background extends Feature { } else if (reason === 'update' && !hasNewVersion(previousVersion)) { chrome.notifications.create('bilibili-helper-update', { type: 'basic', - iconUrl: '../statics/imgs/icon-256.png', + iconUrl: '../statics/imgs/cat.svg', title: __('extensionNotificationTitle'), message: __('extensionNotificationExtensionUpdate').replace('%v', version), }); diff --git a/src/js/modules/googleAnalytics/index.js b/src/js/modules/googleAnalytics/index.js index d203777..27ae512 100644 --- a/src/js/modules/googleAnalytics/index.js +++ b/src/js/modules/googleAnalytics/index.js @@ -4,7 +4,6 @@ * Description: */ -import store from 'store'; import {Feature} from 'Libs/feature'; import {version} from 'Utils'; @@ -75,11 +74,11 @@ export class GoogleAnalytics extends Feature { insertGAScriptTag = (UA = 'UA-39765420-2') => { return new Promise(resolve => { if (document.getElementsByClassName('ga-script').length === 0) { - const userID = store.get('userID'); + let {userID} = this.store || {}; if (!userID) { - this.gaKey = String(Math.random()).slice(2); - store.set('userID', this.gaKey); - } else this.userID = userID; + userID= String(Math.random()).slice(2); + this.store = {userID: userID}; + } const script = `https://www.google-analytics.com/analytics.js`; //const script = `https://www.google-analytics.com/analytics${debug ? '_debug' : ''}.js`; window['GoogleAnalyticsObject'] = 'ga'; @@ -94,7 +93,7 @@ export class GoogleAnalytics extends Feature { document.head.appendChild(scriptTag); window.ga('create', UA, 'auto'); window.ga('set', 'checkProtocolTask'); - window.ga('set', 'userId', this.userID); + window.ga('set', 'userId', userID); resolve(); } else resolve(); }); diff --git a/src/manifest.json b/src/manifest.json index 88713c3..3af20e9 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -52,7 +52,6 @@ } ], "icons": { - "256": "statics/imgs/icon-256.png", "128": "statics/imgs/icon-128.png", "16": "statics/imgs/icon-16.png", "32": "statics/imgs/icon-32.png"