Added locale to new profile selection for match ip
This commit is contained in:
parent
5cfb9c9fda
commit
cb3bdf9e92
3 changed files with 12 additions and 76 deletions
|
|
@ -1,16 +1,17 @@
|
|||
import React, { useState, useEffect } from 'react'
|
||||
import profiles from '../../utils/profiles'
|
||||
import countryLocales from '../../utils/countryLocales'
|
||||
|
||||
const DebugSettings = ({ type, title, ip, profile, setProfile }) => {
|
||||
const [value, setValue] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
if (profile === 'match') {
|
||||
console.log(1)
|
||||
|
||||
if (ip) {
|
||||
setValue(ip[type])
|
||||
chrome.storage.sync.set({ [type]: ip[type] })
|
||||
const ipTypeValue =
|
||||
type === 'locale' ? countryLocales[ip.countryCode].locale : ip[type]
|
||||
setValue(ipTypeValue)
|
||||
chrome.storage.sync.set({ [type]: ipTypeValue })
|
||||
}
|
||||
} else if (profile === 'custom') {
|
||||
console.log(2)
|
||||
|
|
|
|||
|
|
@ -1,71 +0,0 @@
|
|||
import React, { useState, useEffect, useRef } from 'react'
|
||||
import countryLocales from '../../utils/countryLocales'
|
||||
import detachDebugger from '../../utils/detachDebugger'
|
||||
|
||||
const LocaleSettings = ({ ip }) => {
|
||||
const [value, setValue] = useState('')
|
||||
const [matchIP, setMatchIP] = useState(false)
|
||||
const locale = useRef(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (ip) {
|
||||
locale.current = countryLocales[ip.countryCode].locale
|
||||
|
||||
chrome.storage.sync.get(['locale', 'localeMatchIP'], (result) => {
|
||||
result.localeMatchIP && setMatchIP(result.localeMatchIP)
|
||||
|
||||
if (result.localeMatchIP) {
|
||||
setValue(locale.current)
|
||||
chrome.storage.sync.set({ locale: locale.current })
|
||||
} else if (result.locale) {
|
||||
setValue(result.locale)
|
||||
}
|
||||
})
|
||||
}
|
||||
}, [ip])
|
||||
|
||||
const changeTextValue = (e) => {
|
||||
chrome.storage.sync.set({ locale: e.target.value })
|
||||
setValue(e.target.value)
|
||||
if (matchIP) {
|
||||
chrome.storage.sync.set({ localeMatchIP: !matchIP })
|
||||
setMatchIP(!matchIP)
|
||||
}
|
||||
detachDebugger()
|
||||
}
|
||||
|
||||
const toggleMatchIP = (e) => {
|
||||
chrome.storage.sync.set({ locale: locale.current, localeMatchIP: !matchIP })
|
||||
!matchIP && setValue(locale.current)
|
||||
setMatchIP(e.target.value)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
margin: '12px 0 0 0',
|
||||
}}
|
||||
>
|
||||
<label>
|
||||
<input
|
||||
type="text"
|
||||
value={value}
|
||||
onChange={changeTextValue}
|
||||
style={{
|
||||
width: '120px',
|
||||
margin: '0 5px 0 0',
|
||||
}}
|
||||
/>
|
||||
Locale
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" checked={matchIP} onChange={toggleMatchIP} />
|
||||
Match IP
|
||||
</label>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default LocaleSettings
|
||||
|
|
@ -106,6 +106,13 @@ const Popup = () => {
|
|||
profile={profile}
|
||||
setProfile={setProfile}
|
||||
/>
|
||||
<DebugSettings
|
||||
type="locale"
|
||||
title="Locale"
|
||||
ip={ip}
|
||||
profile={profile}
|
||||
setProfile={setProfile}
|
||||
/>
|
||||
<DebugSettings
|
||||
type="lat"
|
||||
title="Latitude"
|
||||
|
|
@ -120,7 +127,6 @@ const Popup = () => {
|
|||
profile={profile}
|
||||
setProfile={setProfile}
|
||||
/>
|
||||
{/* <LocaleSettings ip={ip} /> */}
|
||||
<UserAgentSettings ip={ip} type="lat" title="Latitude" />
|
||||
<div
|
||||
style={{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue