Skip to content

Commit

Permalink
Merge pull request #13 from ety001/3.0.4
Browse files Browse the repository at this point in the history
3.0.4
  • Loading branch information
ety001 authored Feb 11, 2020
2 parents 59676dd + 0da0913 commit 48e24a7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "review-bookmark",
"version": "3.0.3",
"version": "3.0.4",
"description": "A bookmark manager for Chrome.",
"author": "ETY001 <[email protected]>",
"license": "MIT",
Expand All @@ -15,7 +15,7 @@
"build-firefox": "cross-env NODE_ENV=production BROWSER_PROTO=firefox webpack --hide-modules",
"build:dev": "cross-env NODE_ENV=development BROWSER_PROTO=chrome webpack --hide-modules",
"build-firefox:dev": "cross-env NODE_ENV=development BROWSER_PROTO=firefox webpack --hide-modules",
"build-zip": "node scripts/build-zip.js",
"build-zip": "find dist | xargs touch -mt 202002110000 && cd dist && zip -r -X dist.zip . && mv dist.zip ..",
"watch": "npm run build -- --watch",
"watch-firefox": "npm run build-firefox -- --watch",
"watch:dev": "cross-env HMR=true npm run build:dev -- --watch",
Expand Down
28 changes: 17 additions & 11 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ global.browser = require('webextension-polyfill');

const isFirefox = navigator.userAgent.toUpperCase().indexOf('Firefox') ? true : false;
const isChrome = window.navigator.userAgent.indexOf('Chrome') !== -1;
const isEdge = navigator.userAgent.indexOf('Edg') !== -1;

//清空之前版本的数据
if (window.localStorage.curt_index === undefined) {
window.localStorage.clear();
indexedDB.deleteDatabase('bookmarks');
}

const debug = process.env.NODE_ENV === 'development';

// 检测新标签页,控制迷你和full版本
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (isChrome) {
Expand All @@ -34,10 +37,12 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
}
}
}
if (tab.url === 'edge://newtab/') {
if (store.getters.config.mini === false) {
const url = chrome.runtime.getURL('tab/tab.html');
chrome.tabs.update(tabId, { url });
if (isEdge) {
if (tab.url === 'edge://newtab/') {
if (store.getters.config.mini === false) {
const url = chrome.runtime.getURL('tab/tab.html');
chrome.tabs.update(tabId, { url });
}
}
}
});
Expand Down Expand Up @@ -68,16 +73,17 @@ const GetUid = {
const uid = GetUid.get();

//google analytics
let currentVersion = '3_0_3';
let currentVersion = '3_0_4';
if (isChrome) {
currentVersion = `chrome_${currentVersion}`;
}
if (isFirefox) {
} else if (isFirefox) {
currentVersion = `firefox_${currentVersion}`;
} else if (isEdge) {
currentVersion = `edge_${currentVersion}`;
}
const gaID = 'UA-64832923-4';
const gaObj = new GA(gaID, uid);
function sendEvent(eventCategory, eventAction, eventLabel = '', eventValue = '') {
const gaObj = new GA(gaID, uid, debug);
function sendEvent(eventCategory, eventAction, eventLabel = '', eventValue = 1) {
if (store.getters.config.ga === false) return;
gaObj.ga('event', eventCategory, eventAction, eventLabel, eventValue);
}
Expand Down Expand Up @@ -253,7 +259,7 @@ chrome.bookmarks.onRemoved.addListener((id, removeInfo) => {
// 安装/升级检测
chrome.runtime.onInstalled.addListener(detail => {
if (detail.reason == 'update') {
sendEvent(currentVersion, 'update_extension', uid, '');
sendEvent(currentVersion, 'update_extension', uid, 1);
// 弹出推广页面
window.open('https://creatorsdaily.com/9999e88d-0b00-46dc-8ff1-e1d311695324');
return;
Expand All @@ -268,7 +274,7 @@ chrome.runtime.onInstalled.addListener(detail => {
);
}
if (detail.reason === 'install') {
sendEvent(currentVersion, 'install_extension', uid, '');
sendEvent(currentVersion, 'install_extension', uid, 1);
console.log('installed');
// 初始化数据
BookmarkLib.init();
Expand Down
4 changes: 2 additions & 2 deletions src/libs/GA.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export class GA {
constructor(ua, cid) {
constructor(ua, cid, debug = false) {
this.ua = ua;
this.cid = cid; // client id
this.gaApi = 'https://www.google-analytics.com/collect';
this.gaApi = debug ? 'https://www.google-analytics.com/debug/collect' : 'https://www.google-analytics.com/collect';
this.version = '1';
}
ga(t, ...items) {
Expand Down

0 comments on commit 48e24a7

Please sign in to comment.