Skip to content

Commit bc7c987

Browse files
committed
chore: design
1 parent 6b18c4d commit bc7c987

File tree

71 files changed

+7632
-1014
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+7632
-1014
lines changed

.eslintrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,19 @@ module.exports = {
1919
'vue',
2020
],
2121
rules: {
22+
"at-rule-no-unknown": [true, {
23+
ignoreAtRules: [
24+
/apply/,
25+
/tailwind/,
26+
/screen/,
27+
/if/,
28+
/else/,
29+
/return/,
30+
/function/,
31+
/debug/
32+
]
33+
}],
34+
"declaration-block-trailing-semicolon": null,
35+
"no-descending-specificity": null
2236
},
2337
};
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import axios from 'axios';
2+
import store from './store';
3+
import { currentDomain } from './store/getters';
4+
5+
// array to save domain for checking if allready post
6+
const domainsVisited = [];
7+
const browser = require('webextension-polyfill');
8+
9+
const map = store.getters.dataInfo;
10+
11+
12+
// send url to analyzer
13+
async function sendUrl(url, domain, tabId) {
14+
// loading
15+
store.commit('SET_ISLOADING', true);
16+
17+
await axios({
18+
method: 'GET',
19+
url: `https://vue-telemetry.netlify.com/api/analyze?url=${url}&src=extension`,
20+
auth: {
21+
username: 'nuxt-admin',
22+
password: 'vue-telemetry-protected-area',
23+
},
24+
}).then(({ data }) => {
25+
// delete useless jsonKey
26+
delete data.url;
27+
delete data.hostname;
28+
delete data.domain;
29+
delete data.screenshot;
30+
delete data.meta;
31+
32+
setMapData(domain, data);
33+
}).catch((err) => {
34+
browser.browserAction.setIcon({
35+
tabId,
36+
path: {
37+
16: 'icons/icon-vue-telemetry-404error-128.png',
38+
32: 'icons/icon-vue-telemetry-404error-128.png',
39+
},
40+
});
41+
setMapData(domain, 'error');
42+
});
43+
44+
store.commit('SET_ISLOADING', false);
45+
}
46+
47+
// when tab created
48+
function handleCreated(tab) {
49+
setMapData(tab.url, 'noVue');
50+
store.commit('SET_CURRENTDOMAIN', 'noVue');
51+
}
52+
53+
// when tab clicked
54+
async function handleActivated() {
55+
// get active tab
56+
browser.tabs.query({ currentWindow: true, active: true }).then((tabsArray) => {
57+
if (/^chrome/.test(tabsArray[0].url) || /^about/.test(tabsArray[0].url)) {
58+
store.commit('SET_CURRENTDOMAIN', 'noVue');
59+
setMapData(tabsArray[0].url, 'noVue');
60+
} else {
61+
detectVue(tabsArray[0].id, tabsArray[0].url);
62+
}
63+
});
64+
}
65+
66+
// when tab updated
67+
async function handleUpdated(tabId, changeInfo, tabInfo) {
68+
if (changeInfo.status == 'complete') {
69+
detectVue(tabId, tabInfo.url);
70+
}
71+
}
72+
73+
browser.tabs.onCreated.addListener(handleCreated);
74+
browser.tabs.onActivated.addListener(handleActivated);
75+
browser.tabs.onUpdated.addListener(handleUpdated);
76+
77+
78+
// detect vue by calling detector and sendUrl
79+
async function detectVue(tabId, url) {
80+
await hasVue(tabId).then(({ response }) => {
81+
store.commit('SET_CURRENTDOMAIN', response.vueInfo.domain);
82+
83+
if (response.vueInfo.hasVue) {
84+
browser.browserAction.setIcon({
85+
tabId,
86+
path: {
87+
16: 'icons/icon-robot-128.png',
88+
32: 'icons/icon-robot-128.png',
89+
},
90+
});
91+
}
92+
93+
if (!domainsVisited.includes(response.vueInfo.domain)) {
94+
domainsVisited.push(response.vueInfo.domain);
95+
96+
if (response.vueInfo.hasVue) {
97+
sendUrl(url, response.vueInfo.domain, tabId);
98+
} else {
99+
setMapData(response.vueInfo.domain, 'noVue');
100+
store.commit('SET_CURRENTDOMAIN', 'noVue');
101+
}
102+
}
103+
});
104+
}
105+
106+
// check vue in detector.js and get response
107+
function hasVue(tabId) {
108+
return new Promise((resolve) => {
109+
browser.tabs.sendMessage(
110+
tabId,
111+
{ greeting: '' },
112+
).then((response) => {
113+
resolve(response);
114+
});
115+
});
116+
}
117+
118+
function setMapData(domain, data) {
119+
map[domain] = data;
120+
store.commit('SET_DATAINFO', map);
121+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import axios from 'axios';
2+
import store from './store';
3+
import { currentDomain } from './store/getters';
4+
5+
// array to save domain for checking if allready post
6+
const domainsVisited = [];
7+
const browser = require('webextension-polyfill');
8+
9+
const map = store.getters.dataInfo;
10+
11+
12+
// send url to analyzer
13+
async function sendUrl(url, domain, tabId) {
14+
// loading
15+
store.commit('SET_ISLOADING', true);
16+
17+
await axios({
18+
method: 'GET',
19+
url: `https://vue-telemetry.netlify.com/api/analyze?url=${url}&src=extension`,
20+
auth: {
21+
username: 'nuxt-admin',
22+
password: 'vue-telemetry-protected-area',
23+
},
24+
}).then(({ data }) => {
25+
// delete useless jsonKey
26+
delete data.url;
27+
delete data.hostname;
28+
delete data.domain;
29+
delete data.screenshot;
30+
delete data.meta;
31+
32+
setMapData(domain, data);
33+
}).catch((err) => {
34+
browser.browserAction.setIcon({
35+
tabId,
36+
path: {
37+
16: 'icons/icon-vue-telemetry-404error-128.png',
38+
32: 'icons/icon-vue-telemetry-404error-128.png',
39+
},
40+
});
41+
setMapData(domain, 'error');
42+
});
43+
44+
store.commit('SET_ISLOADING', false);
45+
}
46+
47+
// when tab created
48+
function handleCreated(tab) {
49+
setMapData(tab.url, 'noVue');
50+
store.commit('SET_CURRENTDOMAIN', 'noVue');
51+
}
52+
53+
// when tab clicked
54+
async function handleActivated() {
55+
// get active tab
56+
browser.tabs.query({ currentWindow: true, active: true }).then((tabsArray) => {
57+
if (/^chrome/.test(tabsArray[0].url) || /^about/.test(tabsArray[0].url)) {
58+
store.commit('SET_CURRENTDOMAIN', 'noVue');
59+
setMapData(tabsArray[0].url, 'noVue');
60+
} else {
61+
detectVue(tabsArray[0].id, tabsArray[0].url);
62+
}
63+
});
64+
}
65+
66+
// when tab updated
67+
async function handleUpdated(tabId, changeInfo, tabInfo) {
68+
if (changeInfo.status == 'complete') {
69+
detectVue(tabId, tabInfo.url);
70+
}
71+
}
72+
73+
browser.tabs.onCreated.addListener(handleCreated);
74+
browser.tabs.onActivated.addListener(handleActivated);
75+
browser.tabs.onUpdated.addListener(handleUpdated);
76+
77+
78+
// detect vue by calling detector and sendUrl
79+
async function detectVue(tabId, url) {
80+
await hasVue(tabId).then(({ response }) => {
81+
store.commit('SET_CURRENTDOMAIN', response.vueInfo.domain);
82+
83+
if (response.vueInfo.hasVue) {
84+
browser.browserAction.setIcon({
85+
tabId,
86+
path: {
87+
16: 'icons/icon-robot-128.png',
88+
32: 'icons/icon-robot-128.png',
89+
},
90+
});
91+
}
92+
93+
if (!domainsVisited.includes(response.vueInfo.domain)) {
94+
domainsVisited.push(response.vueInfo.domain);
95+
96+
if (response.vueInfo.hasVue) {
97+
sendUrl(url, response.vueInfo.domain, tabId);
98+
} else {
99+
setMapData(response.vueInfo.domain, 'noVue');
100+
store.commit('SET_CURRENTDOMAIN', 'noVue');
101+
}
102+
}
103+
});
104+
}
105+
106+
// check vue in detector.js and get response
107+
function hasVue(tabId) {
108+
return new Promise((resolve) => {
109+
browser.tabs.sendMessage(
110+
tabId,
111+
{ greeting: '' },
112+
).then((response) => {
113+
resolve(response);
114+
});
115+
});
116+
}
117+
118+
function setMapData(domain, data) {
119+
map[domain] = data;
120+
store.commit('SET_DATAINFO', map);
121+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import axios from 'axios';
2+
import store from './store';
3+
import { currentDomain } from './store/getters';
4+
5+
// array to save domain for checking if allready post
6+
const domainsVisited = [];
7+
const browser = require('webextension-polyfill');
8+
9+
const map = store.getters.dataInfo;
10+
11+
12+
// send url to analyzer
13+
async function sendUrl(url, domain, tabId) {
14+
// loading
15+
store.commit('SET_ISLOADING', true);
16+
17+
await axios({
18+
method: 'GET',
19+
url: `https://vue-telemetry.netlify.com/api/analyze?url=${url}&src=extension`,
20+
auth: {
21+
username: 'nuxt-admin',
22+
password: 'vue-telemetry-protected-area',
23+
},
24+
}).then(({ data }) => {
25+
// delete useless jsonKey
26+
delete data.url;
27+
delete data.hostname;
28+
delete data.domain;
29+
delete data.screenshot;
30+
delete data.meta;
31+
32+
setMapData(domain, data);
33+
}).catch((err) => {
34+
browser.browserAction.setIcon({
35+
tabId,
36+
path: {
37+
16: 'icons/icon-vue-telemetry-404error-128.png',
38+
32: 'icons/icon-vue-telemetry-404error-128.png',
39+
},
40+
});
41+
setMapData(domain, 'error');
42+
});
43+
44+
store.commit('SET_ISLOADING', false);
45+
}
46+
47+
// when tab created
48+
function handleCreated(tab) {
49+
setMapData(tab.url, 'noVue');
50+
store.commit('SET_CURRENTDOMAIN', 'noVue');
51+
}
52+
53+
// when tab clicked
54+
async function handleActivated() {
55+
// get active tab
56+
browser.tabs.query({ currentWindow: true, active: true }).then((tabsArray) => {
57+
if (/^chrome/.test(tabsArray[0].url) || /^about/.test(tabsArray[0].url)) {
58+
store.commit('SET_CURRENTDOMAIN', 'noVue');
59+
setMapData(tabsArray[0].url, 'noVue');
60+
} else {
61+
detectVue(tabsArray[0].id, tabsArray[0].url);
62+
}
63+
});
64+
}
65+
66+
// when tab updated
67+
async function handleUpdated(tabId, changeInfo, tabInfo) {
68+
if (changeInfo.status == 'complete') {
69+
detectVue(tabId, tabInfo.url);
70+
}
71+
}
72+
73+
browser.tabs.onCreated.addListener(handleCreated);
74+
browser.tabs.onActivated.addListener(handleActivated);
75+
browser.tabs.onUpdated.addListener(handleUpdated);
76+
77+
78+
// detect vue by calling detector and sendUrl
79+
async function detectVue(tabId, url) {
80+
await hasVue(tabId).then(({ response }) => {
81+
store.commit('SET_CURRENTDOMAIN', response.vueInfo.domain);
82+
83+
if (response.vueInfo.hasVue) {
84+
browser.browserAction.setIcon({
85+
tabId,
86+
path: {
87+
16: 'icons/icon-robot-128.png',
88+
32: 'icons/icon-robot-128.png',
89+
},
90+
});
91+
}
92+
93+
if (!domainsVisited.includes(response.vueInfo.domain)) {
94+
domainsVisited.push(response.vueInfo.domain);
95+
96+
if (response.vueInfo.hasVue) {
97+
sendUrl(url, response.vueInfo.domain, tabId);
98+
} else {
99+
setMapData(response.vueInfo.domain, 'noVue');
100+
store.commit('SET_CURRENTDOMAIN', 'noVue');
101+
}
102+
}
103+
});
104+
}
105+
106+
// check vue in detector.js and get response
107+
function hasVue(tabId) {
108+
return new Promise((resolve) => {
109+
browser.tabs.sendMessage(
110+
tabId,
111+
{ greeting: '' },
112+
).then((response) => {
113+
resolve(response);
114+
});
115+
});
116+
}
117+
118+
function setMapData(domain, data) {
119+
map[domain] = data;
120+
store.commit('SET_DATAINFO', map);
121+
}

.history/src/backgroundts_20200505175101.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)