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

Function createNotification

src/injected/web/notifications.js:18–44  ·  view source on GitHub ↗
(text, title, image, onclick)

Source from the content-addressed store, hash-verified

16
17/** @this {GMContext} */
18export function createNotification(text, title, image, onclick) {
19 let options;
20 let tag;
21 if (isObject(text)) {
22 options = nullObjFrom(text);
23 text = options.text;
24 tag = options.tag;
25 } else {
26 options = createNullObj();
27 options.text = text;
28 options.title = title;
29 options.image = image;
30 options.onclick = onclick;
31 }
32 if (!text) throw new SafeError('Notification `text` is required!');
33 const id = `${this.id}:${options.tag = tag ?? safeGetUniqId()}`;
34 const msg = createNullObj();
35 for (const k in options) {
36 msg[k] = isFunction(options[k]) ? true : options[k];
37 }
38 msg.id = id;
39 notifications[id] = options;
40 bridge.post('Notification', msg);
41 return {
42 remove: () => bridge.promise('RemoveNotification', id),
43 };
44}

Callers

nothing calls this directly

Calls 4

isObjectFunction · 0.85
nullObjFromFunction · 0.85
safeGetUniqIdFunction · 0.85
isFunctionFunction · 0.85

Tested by

no test coverage detected