1
0
mirror of https://github.com/S2-/ping.git synced 2025-08-04 13:10:09 +02:00

initial draft

This commit is contained in:
s2
2019-03-18 14:42:14 +01:00
commit adb84ffd71
18 changed files with 295 additions and 0 deletions

34
src/background-pinger.js Normal file
View File

@@ -0,0 +1,34 @@
import { loadOptions } from './utils.js';
let options = {};
function ping(server) {
console.log('pinging ' + server);
}
function reloadConfig() {
loadOptions().then((savedOptions) => {
options.server = savedOptions.server;
options.interval = savedOptions.interval;
if (options.server && options.interval >= 1) {
ping(options.server);
if (options.pinger) {
clearInterval(options.pinger);
}
options.pinger = setInterval(function() {
ping(options.server);
}, options.interval * 1000);
}
});
}
browser.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request === 'configChanged') {
reloadConfig();
}
});
//startup
reloadConfig();