Added timer feature to user agent option
This commit is contained in:
parent
bdb3ea0d72
commit
dd6d152c85
6 changed files with 32 additions and 57 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
"name": "Vytal",
|
"name": "Vytal",
|
||||||
"description": "Vytal",
|
"description": "Vytal",
|
||||||
"options_page": "options.html",
|
"options_page": "options.html",
|
||||||
"permissions": ["storage", "debugger", "activeTab"],
|
"permissions": ["storage", "debugger", "activeTab", "alarms"],
|
||||||
"background": { "service_worker": "background.bundle.js" },
|
"background": { "service_worker": "background.bundle.js" },
|
||||||
"action": {
|
"action": {
|
||||||
"default_popup": "popup.html",
|
"default_popup": "popup.html",
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import userAgents from '../../utils/userAgents'
|
||||||
|
|
||||||
const attachTab = (tabId) => {
|
const attachTab = (tabId) => {
|
||||||
chrome.storage.sync.get(
|
chrome.storage.sync.get(
|
||||||
[
|
[
|
||||||
|
|
@ -102,52 +104,17 @@ chrome.tabs.onUpdated.addListener((tabId, change, tab) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// const attachTabs = (ipData) => {
|
chrome.alarms.onAlarm.addListener((alarm) => {
|
||||||
// chrome.debugger.getTargets((tabs) => {
|
if (alarm.name === 'userAgentAlarm') {
|
||||||
// console.log(tabs);
|
chrome.storage.sync.get(['randomUA'], (result) => {
|
||||||
// for (const tab in tabs) {
|
if (result.randomUA) {
|
||||||
// if (!tabs[tab].attached && tabs[tab].tabId) {
|
console.log('userAgentAlarm')
|
||||||
// console.log('------------');
|
const randomUserAgent =
|
||||||
// attachTab(tabs[tab].tabId, ipData);
|
userAgents[Math.floor(Math.random() * userAgents.length)]
|
||||||
// }
|
chrome.storage.sync.set({
|
||||||
// }
|
userAgent: randomUserAgent,
|
||||||
// });
|
})
|
||||||
// };
|
}
|
||||||
|
})
|
||||||
// fetch('http://ip-api.com/json/')
|
}
|
||||||
// .then((response) => response.json())
|
})
|
||||||
// .then((ipData) => {});
|
|
||||||
|
|
||||||
// Detects if there are posts for current url
|
|
||||||
// chrome.tabs.onCreated.addListener((tab) => {
|
|
||||||
// console.log(tab.id)
|
|
||||||
// attachTab(tab.id);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// chrome.tabs.onUpdated.addListener((tabId, change, tab) => {
|
|
||||||
// console.log(tabId)
|
|
||||||
// });
|
|
||||||
|
|
||||||
// chrome.tabs.onUpdated.addListener((tabId, change, tab) => {
|
|
||||||
// chrome.debugger.attach({ tabId: tabId }, "1.3", function () {
|
|
||||||
// if (!chrome.runtime.lastError) {
|
|
||||||
// // console.log("attached debugger to tab: " + tabId);
|
|
||||||
// // // https://chromedevtools.github.io/devtools-protocol/tot/ - "geolocation"
|
|
||||||
|
|
||||||
// chrome.debugger.sendCommand(
|
|
||||||
// { tabId: tabId },
|
|
||||||
// "Emulation.setTimezoneOverride",
|
|
||||||
// { timezoneId: "Asia/Shanghai" }
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// chrome.debugger.sendCommand(
|
|
||||||
// { tabId: tabId },
|
|
||||||
// "Emulation.setAutomationOverride",
|
|
||||||
// {
|
|
||||||
// enabled:
|
|
||||||
// true,
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ const DebugSettings = ({ type, title, ip, profile, setProfile }) => {
|
||||||
value={value}
|
value={value}
|
||||||
onChange={changeTextValue}
|
onChange={changeTextValue}
|
||||||
style={{
|
style={{
|
||||||
width: '168px',
|
width: '200px',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<label>{title}</label>
|
<label>{title}</label>
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ const Popup = () => {
|
||||||
value={profile}
|
value={profile}
|
||||||
onChange={changeProfile}
|
onChange={changeProfile}
|
||||||
style={{
|
style={{
|
||||||
width: '176px',
|
width: '208px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<option value="none">None</option>
|
<option value="none">None</option>
|
||||||
|
|
@ -134,8 +134,8 @@ const Popup = () => {
|
||||||
fontSize: '10px',
|
fontSize: '10px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Tabs need to be initialized for full protection.
|
Tabs need to be initialized for full protection.{' '}
|
||||||
{/* <a href="/">Read more</a> */}
|
<a href="/">Read more</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,20 @@ const UserAgentSettings = () => {
|
||||||
})
|
})
|
||||||
e.target.checked ? setUserAgent(randomUserAgent) : setUserAgent('')
|
e.target.checked ? setUserAgent(randomUserAgent) : setUserAgent('')
|
||||||
setRandomUA(e.target.checked)
|
setRandomUA(e.target.checked)
|
||||||
|
|
||||||
|
chrome.alarms.create('userAgentAlarm', {
|
||||||
|
delayInMinutes: parseInt(interval),
|
||||||
|
periodInMinutes: parseInt(interval),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeInterval = (e) => {
|
const changeInterval = (e) => {
|
||||||
chrome.storage.sync.set({ interval: e.target.value })
|
chrome.storage.sync.set({ interval: e.target.value })
|
||||||
setInterval(e.target.value)
|
setInterval(e.target.value)
|
||||||
|
chrome.alarms.create('userAgentAlarm', {
|
||||||
|
delayInMinutes: parseInt(e.target.value),
|
||||||
|
periodInMinutes: parseInt(e.target.value),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -53,7 +62,7 @@ const UserAgentSettings = () => {
|
||||||
value={userAgent}
|
value={userAgent}
|
||||||
onChange={changeUserAgent}
|
onChange={changeUserAgent}
|
||||||
style={{
|
style={{
|
||||||
width: '168px',
|
width: '200px',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<label>User Agent</label>
|
<label>User Agent</label>
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@ body {
|
||||||
background-color: var(--background);
|
background-color: var(--background);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
line-height: 22px;
|
line-height: 22px;
|
||||||
width: 270px;
|
width: 305px;
|
||||||
height: 300px;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: 'Segoe UI', Tahoma, sans-serif;
|
font-family: 'Segoe UI', Tahoma, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue