-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackground.js
32 lines (28 loc) · 918 Bytes
/
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
// Copyright 2019 Paper.io 2 Stats Counter contributors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
'use strict';
var rule = {
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: {hostEquals: 'paper-io.com'},
})],
actions: [new chrome.declarativeContent.ShowPageAction()]
};
chrome.runtime.onInstalled.addListener(function() {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([rule]);
});
});
chrome.runtime.onMessage.addListener(
function(data, sender, sendResponse) {
var response = "";
switch(data.mode) {
case "paper2_classic":
response = "Rate: "+data.score/data.time+"%/s";
break;
default:
response = "Unknown game mode recieved!";
}
// TODO: See TODO in recorder.js
sendResponse(response);
}
);