From c8bb13c4951ab3daa1549d49d42c8b277339118e Mon Sep 17 00:00:00 2001 From: Frederic Hemberger Date: Sun, 2 Sep 2018 16:46:00 +0200 Subject: [PATCH] Set default paths on extension installation and update --- extension/js/background.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/extension/js/background.js b/extension/js/background.js index 0ebc6b2..4ba2787 100755 --- a/extension/js/background.js +++ b/extension/js/background.js @@ -3,6 +3,14 @@ (function () { 'use strict' + const defaultPaths = [ + '^/metrics', + '^/federate', + '^/probe', + '^/prometheus', + '^/actuator/prometheus' + ] + // Listen for requests from content pages wanting to set up a port chrome.extension.onConnect.addListener(port => { if (port.name !== 'promformat') { @@ -50,4 +58,13 @@ port.disconnect() }) }) + + // Set default paths on extension installation and update + chrome.runtime.onInstalled.addListener(() => { + chrome.storage.sync.get({ paths: [] }, data => { + if (!data.paths.length) { + chrome.storage.sync.set({ paths: defaultPaths }) + } + }) + }) }())