-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpopup.js
32 lines (29 loc) · 912 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
29
30
31
32
$(function(){
let color
$('#btnChange').click(function(){
color = $('#fontColor').val();
// Save color to chrome storage
chrome.storage.local.set({color}, function() {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{ file: 'content.js' });
});
})
})
$("#fontColor").on("change paste keyup", function() {
color = $(this).val();
});
chrome.storage.local.get('color', function(data) {
if(data.color)
{
$('#fontColor').val(data.color).css('background-color', `#${data.color}`).click()
// Activate script
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{ file: 'content.js' });
});
}
})
});