Save and load custom values

This commit is contained in:
z0ccc 2022-05-06 13:28:24 -04:00
parent c350da3cc3
commit 62bac340de
4 changed files with 8 additions and 7 deletions

View file

@ -6,24 +6,27 @@ const DebugSettings = ({ type, title, ip, profile, setProfile }) => {
useEffect(() => {
if (profile === 'match') {
console.log(ip)
console.log(1)
if (ip) {
setValue(ip[type])
chrome.storage.sync.set({ [type]: ip[type] })
}
} else if (profile === 'custom') {
console.log(111)
console.log(2)
chrome.storage.sync.get([type], (result) => {
console.log(type)
console.log(result)
result[type] && setValue(result[type])
})
} else {
} else if (profile !== 'default') {
setValue(profiles[profile][type])
chrome.storage.sync.set({ [type]: profiles[profile][type] })
}
}, [ip, profile, type])
const changeTextValue = (e) => {
chrome.storage.sync.set({ [type]: e.target.value })
chrome.storage.sync.set({ timezone: e.target.value })
setValue(e.target.value)
chrome.storage.sync.set({ profile: 'custom' })
setProfile('custom')

View file

@ -15,7 +15,7 @@ const getIP = () =>
const Popup = () => {
const [ip, setIP] = useState(null)
const [profile, setProfile] = useState('none')
const [profile, setProfile] = useState('default')
useEffect(() => {
chrome.storage.sync.get(['profile', 'ipData'], (result) => {

View file

@ -35,7 +35,6 @@ const UserAgentSettings = () => {
}
const changeInterval = (e) => {
console.log(e.target.value)
chrome.storage.sync.set({ interval: e.target.value })
setInterval(e.target.value)
}

View file

@ -1,6 +1,5 @@
const detachDebugger = () => {
chrome.debugger.getTargets((tabs) => {
console.log(tabs)
for (const tab in tabs) {
if (tabs[tab].attached && tabs[tab].tabId) {
chrome.debugger.detach({ tabId: tabs[tab].tabId })