-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd0185b
commit 6bbdce3
Showing
5 changed files
with
22 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
import { GET_PAGE_INFO } from "./util/constant"; | ||
import { IS_VISIBLE, IS_DARK_MODE, IS_NICO_MODE } from "./util/constant"; | ||
|
||
function onChange(event) { | ||
async function onChange(event) { | ||
const el = event.target; | ||
chrome.tabs.query({ currentWindow: true, active: true }, tabs => { | ||
chrome.tabs.sendMessage(tabs[0].id, { type: el.id, value: el.checked }); | ||
}); | ||
const tabs = await browser.tabs.query({ currentWindow: true, active: true }); | ||
await browser.tabs.sendMessage(tabs[0].id, { type: el.id, value: el.checked }); | ||
} | ||
|
||
function bindValue() { | ||
chrome.tabs.query({ currentWindow: true, active: true }, tabs => { | ||
chrome.tabs.sendMessage(tabs[0].id, { type: GET_PAGE_INFO }, info => { | ||
[IS_VISIBLE, IS_DARK_MODE, IS_NICO_MODE].forEach(key => { | ||
const el = document.querySelector(`#${key}`) | ||
el.checked = info[key]; | ||
el.addEventListener("change", onChange); | ||
}); | ||
}); | ||
async function bindValue() { | ||
const tabs = await browser.tabs.query({ currentWindow: true, active: true }); | ||
const info = await browser.tabs.sendMessage(tabs[0].id, { type: GET_PAGE_INFO }); | ||
|
||
[IS_VISIBLE, IS_DARK_MODE, IS_NICO_MODE].forEach(key => { | ||
const el = document.querySelector(`#${key}`) | ||
el.checked = info[key]; | ||
el.addEventListener("change", onChange); | ||
}); | ||
} | ||
|
||
function onLoad() { | ||
bindValue(); | ||
async function onLoad() { | ||
await bindValue(); | ||
} | ||
|
||
onLoad(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters