Search code examples
google-chrome-appgoogle-chrome-os

How to make a Chrome OS app quit itself via Javascript


I need to have a chrome app quit based on a js script, but after I've looked through Google's list of JS APIs for Chrome Apps, I'm not convinced there is a way sadly. I've tried having the program throw errors at itself, but chrome simply ignores them and moves on. By the way, this is for Chrome OS.


Solution

  • Perhaps the simplest hack to make a chrome app "quit" would be to set chrome.storage.local.set({dont_start:1}) and then chrome.runtime.reload() and make sure the onLaunched event listener, instead of doing the normal thing like opening an app window, instead checks first if dont_start is set, and deletes that key, and just does nothing (instead of launching the app). Then in about 30 seconds or so the event page will go inactive.