Google Chromeの拡張機能を作っています。
個人の趣味で作っているのですが、毎時丁度(8時,9時,10時...)に1時間作業してるけど大丈夫?
的な通知を出したいのですが、Google Chrome Extensionの中にcron的な処理ってあるのでしょうか??
backroundのscriptの中で1時間単位のsetIntervalをやるとかも考えたのですが、かなり気持ち悪いなぁと思っていて。。。
もしAPIをご存じの方がいらっしゃったらご教示いただけると幸いです。
現状は以下のようにscriptを作っています。
javascript
1var nId = null; 2 3var opt = { 4 type: 'basic', 5 title: '1時間経ったよ!', 6 message: '休憩しなくて大丈夫?', 7 iconUrl: './128.png', 8 buttons: [ 9 { 10 title: "youtubeを見る" 11 }, 12 { 13 title: 'まだ頑張る!' 14 } 15 ] 16} 17 18const showNotification = () => { 19 chrome.notifications.create('aaaaa', opt, (id) => { 20 nId = id; 21 }) 22} 23 24const closeNotification = (id) => { 25 chrome.notifications.clear(id) 26} 27 28chrome.notifications.onButtonClicked.addListener((id, btnIndex) => { 29 if(nId === id){ 30 if(btnIndex === 0){ 31 window.open('https://youtube.com') 32 }else{ 33 34 } 35 closeNotification(nId) 36 } 37}) 38 39showNotification() 40
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。