MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / Notification

Function Notification

src/background/utils/notifications.js:14–45  ·  view source on GitHub ↗

@return {Promise }

({
    image,
    text,
    tag,
    title,
    silent,
    onclick,
    [kZombieUrl]: zombieUrl,
    [kZombieTimeout]: zombieTimeout,
  }, src)

Source from the content-addressed store, hash-verified

12addPublicCommands({
13 /** @return {Promise<string>} */
14 async Notification({
15 image,
16 text,
17 tag,
18 title,
19 silent,
20 onclick,
21 [kZombieUrl]: zombieUrl,
22 [kZombieTimeout]: zombieTimeout,
23 }, src) {
24 if (tag) clearZombieTimer(openers[tag]);
25 const notificationId = await browser.notifications.create(tag, {
26 type: 'basic',
27 title: [title, IS_FIREFOX && i18n('extName')]::trueJoin(' - '), // Chrome already shows the name
28 message: text,
29 iconUrl: image || defaultImage,
30 ...!IS_FIREFOX && {
31 requireInteraction: !!onclick,
32 },
33 ...CHROME >= 70 && {
34 silent,
35 }
36 });
37 if (isFunction(onclick)) {
38 openers[notificationId] = onclick;
39 } else if (src) {
40 openers[notificationId] = src;
41 if (+zombieTimeout > 0) src[kZombieTimeout] = +zombieTimeout;
42 if (zombieUrl != null) src[kZombieUrl] = vetUrl(zombieUrl, src.url);
43 }
44 return notificationId;
45 },
46 RemoveNotification(nid) {
47 clearZombieTimer(openers[nid]);
48 removeNotification(nid);

Callers

nothing calls this directly

Calls 3

vetUrlFunction · 0.90
clearZombieTimerFunction · 0.85
isFunctionFunction · 0.85

Tested by

no test coverage detected