-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
40 lines (36 loc) · 1.27 KB
/
background.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
35
36
37
38
39
40
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: {hostEquals: 'teams.microsoft.com'},
})],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
/**
* taken from https://github.com/robol/save-participants-extension by Robol
*/
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.action == "download") {
let msg = request.message;
// Format the date to be appended to the filename
let now = new Date();
let filename = 'teams-chat-' +
now.getFullYear() + '-' +
(now.getMonth() + 1).toString().padStart(2, "0") + '-' +
now.getDate().toString().padStart(2, "0") + '.txt';
var blob = new Blob([msg], {
type: "text/plain"
});
var url = URL.createObjectURL(blob);
chrome.downloads.download({
url: url,
filename: filename
});
sendResponse({
status: 'completed'
});
}
}
);