admin管理员组文章数量:1417070
I've developed some Chrome apps and Chrome extensions these day for fun.
and I'm wondering if I can schedule launch Chrome app and run certain mands periodically like cron jobs.
I know Chrome provide "chrome.alarm api" to run a certain function periodically, but I believe it requires users to keep my chrome app open or to keep chrome browser open which my chrome extension is installed to.
Please tell me if I can do such a thing in the first of all, and if I can do, please tell me how I can acplish that!
I've developed some Chrome apps and Chrome extensions these day for fun.
and I'm wondering if I can schedule launch Chrome app and run certain mands periodically like cron jobs.
I know Chrome provide "chrome.alarm api" to run a certain function periodically, but I believe it requires users to keep my chrome app open or to keep chrome browser open which my chrome extension is installed to.
Please tell me if I can do such a thing in the first of all, and if I can do, please tell me how I can acplish that!
Share Improve this question edited Sep 4, 2014 at 12:51 abraham 48k10 gold badges107 silver badges157 bronze badges asked Sep 4, 2014 at 7:25 W3QW3Q 9091 gold badge12 silver badges19 bronze badges2 Answers
Reset to default 7A Chrome App doesn't have to be running to use the chrome.alarms
API. See https://developer.chrome./apps/alarms for details about how to use it.
Basically, here's how it works:
// background page (aka event page)
chrome.alarms.onAlarm.addListener(function() {
// Do something useful...
});
// Register an alarm that will wake my background page every hour.
chrome.alarms.create('', { periodInMinutes: 60 });
For info, here are some good Chrome App samples that use chrome.alarms
at https://github./GoogleChrome/chrome-app-samples/search?utf8=%E2%9C%93&q=alarms
A Chrome Extension can stay active even before/after Chrome is launched, unless the user specifically forbids that. Kind of like Google Now operates in recent Chrome versions.
For that, you need to declare "background"
permission.
Makes Chrome start up early and and shut down late, so that apps and extensions can have a longer life.
When any installed hosted app, packaged app, or extension has "background" permission, Chrome runs (invisibly) as soon as the user logs into their puter—before the user launches Chrome. The "background" permission also makes Chrome continue running (even after its last window is closed) until the user explicitly quits Chrome.
I'm afraid it's not an option for a Chrome App though. The wording in the documentation refers to deprecated legacy app types. See François's answer for a possible solution in Apps.
本文标签:
版权声明:本文标题:javascript - Is it possible to schedule to launch Chrome app and run certain commands periodically? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745260233a2650323.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论