Skip to content

Commit c16559b

Browse files
committed
update extension icon and add icon badge
1 parent 7d7d652 commit c16559b

File tree

8 files changed

+59
-5
lines changed

8 files changed

+59
-5
lines changed

.DS_Store

0 Bytes
Binary file not shown.
6.46 KB
Loading
407 Bytes
Loading
810 Bytes
Loading
3 KB
Loading

src/angular/src/manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"version": "1.3.3",
66
"description": "Chrome Extension for Mist Developpers to provide easier access to Mist APIs",
77
"icons": {
8-
"16": "assets/icon16.png",
9-
"48": "assets/icon48.png",
10-
"128": "assets/icon128.png"
8+
"16": "assets/favicon-16x16.png",
9+
"48": "assets/favicon-48x48.png",
10+
"128": "assets/favicon-128x128.png"
1111
},
1212
"action": {
1313
"default_popup": "index.html?#/popup",

src/chrome/src/contentPage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@ chrome.runtime.onMessage.addListener((request, sender, respond) => {
88
});
99

1010
handler.then(message => respond(message)).catch(error => respond(error));
11-
1211
return true;
1312
});
14-

src/chrome/src/serviceWorker.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,57 @@
11
console.log('serviceWorker script loaded');
2+
//chrome.action.setBadgeBackgroundColor("#4caf50")
3+
4+
5+
chrome.tabs.onActivated.addListener(info => {
6+
getUrl(info.tabId);
7+
})
8+
9+
chrome.tabs.onUpdated.addListener((tab) => {
10+
getUrl(tab);
11+
12+
})
13+
14+
function getUrl(tabId: number) {
15+
setTimeout(() => {
16+
chrome.tabs.get(tabId, (tab) => {
17+
if (tab) {
18+
checkUrl(tab.url);
19+
} else {
20+
getUrl(tabId);
21+
}
22+
})
23+
}, 100);
24+
}
25+
26+
function checkUrl(tabUrl: string) {
27+
28+
const orgsle_re = /https:\/\/manage\.(?<host>[a-z0-1.]*mist\.com)\/admin\/\?org_id=(?<org_id>[0-9a-f-]*)#!dashboard\/(?<scope>siteComparison|wiredSiteComparison|wanSiteComparison)\/(?<sle>[a-z-]*)\/(?<worstsle>[a-z-]*)\/([a-z-_]*)\/(?<period>[0-9a-z-]*)\/(?<start>[0-9]*)\/(?<stop>[0-9]*)/iys;
29+
const sle_re = /https:\/\/manage\.(?<host>[a-z0-1.]*mist\.com)\/admin\/\?org_id=(?<org_id>[0-9a-f-]*)#!dashboard\/(?<detail>serviceLevels|wiredserviceLevels|wanserviceLevels)\/(?<scope>[a-z-]*)\/(?<scope_id>[a-f0-9-]*)\/(?<period>[0-9a-z-]*)\/(?<start>[0-9]*)\/(?<stop>[0-9]*)\/(?<site_id>[a-f0-9-]*)/iys;
30+
const insights_re = /https:\/\/(manage|integration)\.(?<host>[a-z0-1.]*mist\.com)\/admin\/\?org_id=(?<org_id>[0-9a-f-]*)#!dashboard\/insights\/((?<obj>[a-z]+)\/)?((?<obj_id>[a-z0-9-]+)\/)((?<period>[a-z0-9]+)\/)?((?<start>[0-9]*)\/)?((?<stop>[0-9]*)\/)?(?<site_id>[0-9a-f-]*)?/iys;
31+
const common_re = /https:\/\/(manage|integration)\.(?<host>[a-z0-1.]*mist\.com)\/admin\/\?org_id=(?<org_id>[0-9a-f-]*)#!(?<obj>[a-z]+)\/?((?<detail>detail|template|site|rfTemplate|admin|edgedetail|clusterdetail|new|view)\/)?([0-9]\/)?((?<obj_id>[0-9a-z_-]*)\/)?(?<site_id>[0-9a-f-]*)?/yis;
32+
33+
const orgsle = orgsle_re.exec(tabUrl);
34+
const sle = sle_re.exec(tabUrl);
35+
const insights = insights_re.exec(tabUrl);
36+
const common = common_re.exec(tabUrl);
37+
if (orgsle) {
38+
apiBadge(true);
39+
} else if (sle) {
40+
apiBadge(true);
41+
} else if (insights) {
42+
apiBadge(true);
43+
} else if (common) {
44+
apiBadge(true);
45+
} else {
46+
apiBadge(false);
47+
}
48+
}
49+
50+
function apiBadge(show:boolean) {
51+
if (show){
52+
chrome.action.setBadgeBackgroundColor({color: "#1ba3f2"})
53+
chrome.action.setBadgeText({"text": "API"});
54+
} else {
55+
chrome.action.setBadgeText({"text": ""});
56+
}
57+
}

0 commit comments

Comments
 (0)