-
Notifications
You must be signed in to change notification settings - Fork 2
/
popup.js
30 lines (24 loc) · 846 Bytes
/
popup.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
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
document.addEventListener('DOMContentLoaded', function(){
const ls = document.querySelector('#listen-domain')
const sy = document.querySelector('#sync-url')
const syncBtn = document.querySelector('#save-btn')
// backfill config
chrome.storage.sync.get(
['listenDomain', 'syncURL'],
({ listenDomain = [], syncURL = '' }) => {
ls.value = listenDomain.join('\n')
sy.value = syncURL
}
)
// set new config
syncBtn.onclick = () => {
const listenDomain = ls.value.trim().split(/\n/)
const syncURL = sy.value.trim()
if (listenDomain && syncURL) {
chrome.storage.sync.set({ listenDomain, syncURL })
}
}
})