Skip to content

Commit

Permalink
Set default paths on extension installation and update
Browse files Browse the repository at this point in the history
  • Loading branch information
fhemberger committed Sep 2, 2018
1 parent 5b96fc6 commit c8bb13c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions extension/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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 })
}
})
})
}())

0 comments on commit c8bb13c

Please sign in to comment.