Skip to content

Commit

Permalink
1. adapt mv3 alarm trigger flow. 2. adapt mv3 background event page l…
Browse files Browse the repository at this point in the history
…ife time
  • Loading branch information
suziwen committed Apr 5, 2024
1 parent 45295e1 commit 183a947
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "ZeroOmega--Proxy Switchy manifest v3 version",
"version": "3.2.0",
"version": "3.2.1",
"description": "__MSG_manifest_app_description__",
"icons": {
"16": "img/icons/omega-action-16.png",
Expand Down
2 changes: 1 addition & 1 deletion omega-target-chromium-extension/overlay/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "ZeroOmega--Proxy Switchy manifest v3 version",
"version": "3.2.0",
"version": "3.2.1",
"description": "__MSG_manifest_app_description__",
"icons": {
"16": "img/icons/omega-action-16.png",
Expand Down
19 changes: 11 additions & 8 deletions omega-target-chromium-extension/src/module/options.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ Url = require('url')

TEMPPROFILEKEY = 'tempProfileState'

globalThis.isBrowserRestart = false

chrome.runtime.onStartup.addListener ->
globalThis.isBrowserRestart = true
console.log('delete temp profile')
idbKeyval.del(TEMPPROFILEKEY).then(->
console.log('delete temp profile success')
Expand All @@ -22,6 +25,13 @@ class ChromeOptions extends OmegaTarget.Options

constructor: (args...) ->
super(args...)
chrome.alarms.onAlarm.addListener (alarm) =>
switch alarm.name
when 'omega.updateProfile'
console.log('update profile interval')
@ready.then( =>
@updateProfile()
)
chrome.contextMenus.onClicked.addListener((info, tab) =>
@ready.then( =>
switch info.menuItemId
Expand Down Expand Up @@ -224,18 +234,11 @@ class ChromeOptions extends OmegaTarget.Options
port.onDisconnect.addListener =>
delete @_tabRequestInfoPorts[tabId] if tabId?

_alarms: null
schedule: (name, periodInMinutes, callback) ->
schedule: (name, periodInMinutes) ->
name = 'omega.' + name
if not _alarms?
@_alarms = {}
chrome.alarms.onAlarm.addListener (alarm) =>
@_alarms[alarm.name]?()
if periodInMinutes < 0
delete @_alarms[name]
chrome.alarms.clear(name)
else
@_alarms[name] = callback
chrome.alarms.create(name, {
periodInMinutes: periodInMinutes
})
Expand Down
5 changes: 2 additions & 3 deletions omega-target/src/options.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Options
###
init: ->
@ready = @loadOptions().then(=>
if @_options['-startupProfileName']
if globalThis.isBrowserRestart and @_options['-startupProfileName']
@applyProfile(@_options['-startupProfileName'])
else
@_state.get({
Expand Down Expand Up @@ -384,8 +384,7 @@ class Options
if changes['-enableQuickSwitch']? or quickSwitchProfiles?
@reloadQuickSwitch()
if changes['-downloadInterval']?
@schedule 'updateProfile', @_options['-downloadInterval'], =>
@updateProfile()
@schedule 'updateProfile', @_options['-downloadInterval']
if changes['-showInspectMenu']? or changes == @_options
showMenu = @_options['-showInspectMenu']
if not showMenu?
Expand Down
1 change: 1 addition & 0 deletions omega-web/src/popup/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ html, body {

body {
min-width: 12em;
margin: 5px;
}

.om-hidden {
Expand Down

0 comments on commit 183a947

Please sign in to comment.