mirror of https://github.com/dessant/buster
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
import browser from 'webextension-polyfill';
|
|
|
|
import {getText, createTab, getActiveTab} from 'utils/common';
|
|
|
|
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'
|
|
});
|
|
}
|
|
|
|
function getOptionLabels(data, scope = 'optionValue') {
|
|
const labels = {};
|
|
for (const [group, items] of Object.entries(data)) {
|
|
labels[group] = [];
|
|
items.forEach(function(value) {
|
|
labels[group].push({
|
|
id: value,
|
|
label: getText(`${scope}_${group}_${value}`)
|
|
});
|
|
});
|
|
}
|
|
return labels;
|
|
}
|
|
|
|
async function showContributePage(action = false) {
|
|
const activeTab = await getActiveTab();
|
|
let url = browser.extension.getURL('/src/contribute/index.html');
|
|
if (action) {
|
|
url = `${url}?action=${action}`;
|
|
}
|
|
await createTab(url, {index: activeTab.index + 1});
|
|
}
|
|
|
|
export {showNotification, getOptionLabels, showContributePage};
|