-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground-tfs-print.js
34 lines (31 loc) · 1.27 KB
/
background-tfs-print.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//@ts-check
"use strict";
chrome.runtime.onInstalled.addListener(() => {
chrome.declarativeContent.onPageChanged.removeRules(undefined, () => {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostPrefix: "tfs" },
})],
actions: [new chrome.declarativeContent.ShowPageAction()]
},{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostEquals: "dev.azure.com" },
})],
actions: [new chrome.declarativeContent.ShowPageAction()]
},{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostSuffix: "visualstudio.com" },
})],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
});
chrome.pageAction.onClicked.addListener(() => {
chrome.tabs.query({ currentWindow: true, active: true }, (tabArray) => {
if (tabArray.length === 0) {
console.error("Unable to find current active window. Print view cannot be toggled.");
return;
}
chrome.tabs.sendMessage(tabArray[0].id, { type: "TOGGLE_PRINT_VIEW" })
});
});