dev holyblue
unread,Jul 16, 2022, 3:56:48 AM7/16/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions, ComputerWhiz, geet...@gmail.com, Chromium Extensions, Simeon Vincent, chri...@hiregiraffe.com, Erek Speed, Jackie Han, tekka...@gmail.com
I am also facing the same problem.
The chrome extension I created in Manifest v3 is Mouse Gesture.
Immediately after launching the Chrome Browser, the Gesture function is working normally, but after a while, the Gesture function does not work.
At that time, when I checked the details screen of the extension, Service workder was inactive.
Gesture function captures mouse movement in content script,
then sends a message to event.js using [chrome.runtime.sendMessage()] and executes the action in event.js.
When this problem occurs, chrome.runtime.sendMessage() executed in content script does not generate an error,
and event.js returns the expected responce.
So I guess Service Workder(event.js) isn't stopped and the chrome API can't be run inside event.js.
I was looking for the way to make Service Workder Active from the chrome extension.
As a result, when coding [chrome.tabs.onCreated.addListener ((tab) => {})] in event.js
I found that when I created a new tab in the Chromw Browser, the Service Workder changed from NonActive to Acitve.
So I coded the following in event.js:
- - - - - - - - - - - - - - - - - - - -
chrome.tabs.onCreated.addListener ((tab) => {
:
:
})
let tabCreateRemove = async () => {
MyLoggerClass.debug("[event.js][tabCreateRemove]");
chrome.tabs.create({active : false}, (tab)=>{
chrome.tabs.remove(
tab.id);
});
}
chrome.runtime.onMessage.addListener( async(message, sender, sendResponse) =>{
await tabCreateRemove();
:
:
}
- - - - - - - - - - - - - - - - - - - -
Then, when chrome.runtime.sendMessage () is executed from the content script, Tab will be newly created / deleted by chrome.runtime.onMessage.addListener () in event.js.
As a result, SeviceWorkder is always Active and the problem is resolved.
I think this method is a forcible solution.
Please let me know if there is a better solution.
Best Regards,
2022年2月8日火曜日 11:06:02 UTC+9 ComputerWhiz: