How to use the webextension-polyfill.notifications function in webextension-polyfill

To help you get started, we’ve selected a few webextension-polyfill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leonekmi / scrobbly / src / daemon.js View on Github external
resolve(lastRequestStorage);
							break;
						default:
							console.warn('Unknown data element !', message.get, message, sender);
							resolve(false);
							break;
					}
					if (message.source == 'settings') {
						activeSettingsTab = sender.tab.id;
					}
					break;
				case 'toggleScrobble':
					console.log('scrobbling engine manage');
					if (workingdb == 'daemonstopped') {
						workingdb = {};
						browser.notifications.create('startDaemon', {
							type: 'basic',
							iconUrl: '/logos/logo512.png',
							title: browser.i18n.getMessage('startDaemonTitle'),
							message: browser.i18n.getMessage('startDaemonMessage')
						});
						console.log('Scrobbly daemon unlock!');
						browser.browserAction.setBadgeText({text: ''});
						resolve('started');
					} else {
						stopScrobble();
						workingdb = 'daemonstopped';
						browser.notifications.create('stopDaemon', {
							type: 'basic',
							iconUrl: '/logos/logo512.png',
							title: browser.i18n.getMessage('stopDaemonTitle'),
							message: browser.i18n.getMessage('stopDaemonMessage')
github web-scrobbler / web-scrobbler / src / core / background / browser / notifications.js View on Github external
}
	}

	function i18n(tag, ...context) {
		return browser.i18n.getMessage(tag, context);
	}


	function clearNotificationTimeout() {
		if (notificationTimeoutId) {
			clearTimeout(notificationTimeoutId);
			notificationTimeoutId = null;
		}
	}

	browser.notifications.onClicked.addListener((notificationId) => {
		console.log(`Notification onClicked: ${notificationId}`);

		if (clickListeners[notificationId]) {
			clickListeners[notificationId](notificationId);
		}
	});
	browser.notifications.onClosed.addListener((notificationId) => {
		removeOnClickedListener(notificationId);
	});

	return {
		clearNowPlaying, showNowPlaying, showError, showSignInError,
		showAuthNotification, showSongNotRecognized
	};
});
github waynecz / dadda-translate-crx / src / tools / toast.ts View on Github external
type: 'basic',
    title: wordTxt,
    message,
    priority: 2,
    requireInteraction: true,
    slient: true,
    eventTime: Date.now() + 1000000,
    buttons: [
      {
        title: '😏 我已经会这个单词了!'
      }
    ]
  }
  const notificationID = TR_ID_PREFIX + wordTxt

  browser.notifications.clear(notificationID)
  browser.notifications.create(notificationID, options)
}
github cnwangjie / better-onetab / src / common / service / boss.js View on Github external
setTimeout(() => {
    browser.notifications.clear(loginNotificationId)
  }, 5000)
  await refresh()
github dessant / clear-browsing-data / src / utils / app.js View on Github external
function showNotification({message, messageId, title, type = 'info'}) {
  if (!title) {
    title = getText('extensionName');
  }
  if (messageId) {
    message = getText(messageId);
  }
  return browser.notifications.create(`cbd-notification-${type}`, {
    type: 'basic',
    title: title,
    message: message,
    iconUrl: '/src/icons/app/icon-48.png'
  });
}
github web-scrobbler / web-scrobbler / src / core / background / browser / notifications.js View on Github external
function remove(notificationId) {
		if (notificationId) {
			browser.notifications.clear(notificationId);
		}
	}
github picwellwisher12pk / Excited-Gem / src / scripts / ActiveTabs.js View on Github external
browser.storage.local.set(jsonObj).then(tempResult => {
        browser.notifications.create(
          "reminder",
          {
            type: "basic",
            iconUrl: "../images/logo.svg",
            title: "Settings Saved",
            message: "Search settings updated"
          },
          function(notificationId) {}
        );
      });
    });
github web-scrobbler / web-scrobbler / src / core / background / browser / notifications.js View on Github external
}

		if (typeof onClicked === 'function') {
			options.isClickable = true;
		}

		for (let key in DEFAULT_OPTIONS_VALUES) {
			if (options[key]) {
				continue;
			}

			let defaultValue = DEFAULT_OPTIONS_VALUES[key];
			options[key] = defaultValue;
		}

		const notificationId = await browser.notifications.create('', options);
		if (typeof onClicked === 'function') {
			addOnClickedListener(notificationId, onClicked);
		}

		return notificationId;
	}
github cnwangjie / better-onetab / src / common / service / boss.js View on Github external
const login = async token => {
  if (await hasToken()) return
  await setToken(token)
  const {uid} = await getInfo()
  await sendMessage({logged: {uid}})
  const loginNotificationId = 'login'
  browser.notifications.create(loginNotificationId, {
    type: 'basic',
    iconUrl: 'assets/icons/icon_128.png',
    title: 'you have login to boss successfully',
    message: '',
  })
  setTimeout(() => {
    browser.notifications.clear(loginNotificationId)
  }, 5000)
  await refresh()
}
github dessant / buster / src / utils / app.js View on Github external
function showNotification({message, messageId, title, type = 'info'}) {
  if (!title) {
    title = getText('extensionName');
  }
  if (messageId) {
    message = getText(messageId);
  }
  return browser.notifications.create(`sbi-notification-${type}`, {
    type: 'basic',
    title: title,
    message: message,
    iconUrl: '/src/icons/app/icon-48.png'
  });
}