Skip to content

Commit c6415e6

Browse files
committed
add design
1 parent a7f7329 commit c6415e6

28 files changed

+10122
-60
lines changed

package-lock.json

Lines changed: 9464 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"watch:dev": "cross-env HMR=true npm run build:dev -- --watch"
1919
},
2020
"dependencies": {
21+
"@babel/polyfill": "^7.8.7",
22+
"@lottiefiles/lottie-player": "^0.5.1",
2123
"axios": "^0.19.0",
2224
"vue": "^2.6.10",
2325
"vue-telemetry-analyzer": "^0.1.6",
@@ -48,6 +50,7 @@
4850
"eslint-plugin-standard": "^4.0.1",
4951
"eslint-plugin-vue": "^6.0.1",
5052
"file-loader": "^5.0.2",
53+
"google-fonts-webpack-plugin": "^0.4.4",
5154
"mini-css-extract-plugin": "^0.9.0",
5255
"node-sass": "^4.13.1",
5356
"puppeteer": "^2.1.1",

src/background.js

Lines changed: 74 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,44 @@ import store from './store'
44

55
// map to save id + url for checking if allready post
66
let domainsVisited = []
7+
let dataMap = new Map()
78

89
// send url to analyzer
9-
async function sendUrl(url) {
10+
async function sendUrl(url, domain) {
11+
12+
//loading
13+
store.commit('SET_ISLOADING', true);
14+
1015
try {
1116
await axios({
1217
method: 'GET',
13-
url: `https://vue-telemetry.netlify.com/api/analyze?url=${url}`,
18+
url: `https://vue-telemetry.netlify.com/api/analyze?url=${url}&src=extension`,
1419
auth: {
1520
username: 'nuxt-admin',
1621
password: 'vue-telemetry-protected-area'
17-
}
22+
},
1823
}).then(({ data }) => {
19-
store.dispatch('setData', data)
24+
//not need tag meta
25+
delete data.url
26+
delete data.hostname
27+
delete data.domain
28+
delete data.screenshot
29+
delete data.meta
30+
dataMap.set(domain, data)
31+
store.commit('SET_DATA', dataMap)
2032
}).catch((err) => {
21-
console.error(err)
33+
store.commit('SET_CURRENTDOMAIN', "WSError")
2234
})
2335
} catch (e) {
24-
console.error(e)
36+
store.commit('SET_CURRENTDOMAIN', "WSError")
2537
}
38+
store.commit('SET_ISLOADING', false);
2639
}
2740

28-
// when tab updated with new url
29-
async function handleUpdated(tabId, changeInfo) {
30-
if (changeInfo.url) {
31-
const { response } = await detectVue(tabId)
32-
// check if not already analyzed
33-
if (response.vueInfo.hasVue && !domainsVisited.includes(response.vueInfo.domain)) {
34-
domainsVisited.push(response.vueInfo.domain)
35-
sendUrl(changeInfo.url, tabId)
36-
}
41+
// when tab updated
42+
async function handleUpdated(tabId, changeInfo, tabInfo) {
43+
if (changeInfo.status == "complete") {
44+
await detectVue(tabId, tabInfo.url)
3745
}
3846
}
3947

@@ -43,25 +51,64 @@ tabs.onUpdated.addListener(handleUpdated)
4351
async function handleActivated() {
4452
// get active tab
4553
tabs.query({ currentWindow: true, active: true }).then(async function (tabsArray) {
46-
47-
const { response } = await detectVue(tabsArray[0].id)
48-
// check if not already analyzed
49-
if (response.vueInfo.hasVue && !domainsVisited.includes(response.vueInfo.domain)) {
50-
domainsVisited.push(response.vueInfo.domain)
51-
sendUrl(tabsArray[0].url, tabsArray[0].id)
52-
}
54+
await detectVue(tabsArray[0].id, tabsArray[0].url)
5355
})
5456
}
5557

5658
tabs.onActivated.addListener(handleActivated)
5759

58-
function detectVue(tabId) {
60+
//function to detect vue and send url
61+
async function detectVue(tabId, url) {
62+
63+
store.commit('SET_CURRENTDOMAIN', 'noVue')
64+
65+
//Check vue
66+
await hasVue(tabId).then(({ response }) => {
67+
68+
//set store current domain
69+
70+
if (response.vueInfo.hasVue) {
71+
72+
store.commit('SET_CURRENTDOMAIN', response.vueInfo.domain)
73+
74+
browser.browserAction.setIcon({
75+
tabId: tabId,
76+
path: {
77+
16: `icons/icon-nuxtjs.png`,
78+
48: `icons/icon-nuxtjs.png`,
79+
128: `icons/icon-nuxtjs.png`
80+
}
81+
})
82+
}
83+
84+
// if not already analyzed
85+
if (!domainsVisited.includes(response.vueInfo.domain)) {
86+
87+
domainsVisited.push(response.vueInfo.domain)
88+
89+
//send url and change icon extension
90+
if (response.vueInfo.hasVue) {
91+
sendUrl(url, response.vueInfo.domain)
92+
}
93+
}
94+
95+
return response.vueInfo.hasVue;
96+
97+
}).catch((err) => {
98+
//set store current domain to error
99+
store.commit('SET_CURRENTDOMAIN', "noVUe")
100+
return false;
101+
})
102+
}
103+
104+
//check vue in detector.js and get response
105+
function hasVue(tabId) {
59106
return new Promise(resolve => {
60107
browser.tabs.sendMessage(
61108
tabId,
62109
{ greeting: '' }
63-
).then(response => {
64-
resolve(response)
65-
})
110+
).then(response => {
111+
resolve(response)
66112
})
67-
}
113+
})
114+
}

src/detector.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const isBrowser = typeof navigator !== 'undefined'
22
const isFirefox = isBrowser && navigator.userAgent.indexOf('Firefox') > -1
3+
import "@babel/polyfill";
34

45
if (document instanceof HTMLDocument) {
56
installScript(detectVue)
@@ -27,7 +28,23 @@ browser.runtime.onMessage.addListener(handleMessage)
2728

2829
function detectVue(win) {
2930
setTimeout(() => {
30-
const hasVue = Boolean(window.Vue || window.$nuxt || [...document.querySelectorAll('*')].map((el) => Boolean(el.__vue__)).filter(Boolean).length)
31+
const hasVue = Boolean(window.Vue || window.$nuxt) //|| [...document.querySelectorAll('*')].map((el) => Boolean(el.__vue__)).filter(Boolean).length)
32+
33+
if (hasVue == false) {
34+
const all = document.querySelectorAll('*')
35+
let el
36+
for (let i = 0; i < all.length; i++) {
37+
if (all[i].__vue__) {
38+
el = all[i]
39+
break
40+
}
41+
}
42+
if (el) {
43+
hasVue = true;
44+
}
45+
}
46+
47+
3148
win.postMessage({
3249
__vue_telemetry__: true,
3350
domain: document.domain,
@@ -38,7 +55,7 @@ function detectVue(win) {
3855

3956
function installScript(fn) {
4057
const source = ';(' + fn.toString() + ')(window)'
41-
58+
4259
if (isFirefox) {
4360
// eslint-disable-next-line no-eval
4461
window.eval(source) // in Firefox, this evaluates on the content window

src/icons/brightness.png

8.81 KB
Loading

src/icons/icon-nuxtjs-disabled.png

26.2 KB
Loading

src/icons/icon-nuxtjs.png

14.4 KB
Loading

src/icons/logo-nuxtjs.svg

Lines changed: 48 additions & 0 deletions
Loading

src/icons/moon.png

23.1 KB
Loading

src/images/broken.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)