Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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')
}
}
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
};
});
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)
}
setTimeout(() => {
browser.notifications.clear(loginNotificationId)
}, 5000)
await refresh()
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'
});
}
function remove(notificationId) {
if (notificationId) {
browser.notifications.clear(notificationId);
}
}
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) {}
);
});
});
}
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;
}
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()
}
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'
});
}