谷歌浏览器扩展通知到win系统

记得要开启chrome通知权限,右下角,对话图标,打开通知栏,点右上角管理通知,找到chrome,开启

文档:https://developer.chrome.com/docs/extensions/reference/notifications/

manifest.json

  "permissions": [
    "notifications"
  ],

service-worker.js

// 提醒
function notify(text) {
  chrome.notifications.create(getNotificationId(), {
    title: 'title',
    iconUrl: './images/logo.png',
    type: 'basic',
    message: text
  }, function (ret) {
    console.log('retnotret', ret)
  });
}

// Returns a new notification ID used in the notification.
function getNotificationId() {
  var id = Math.floor(Math.random() * 9007199254740992) + 1;
  return id.toString();
}

 

posted @ 2023-07-08 12:13  jqynr  阅读(160)  评论(0)    收藏  举报