make use of chrome.runtime instead of spawning a tab

This commit is contained in:
and94x 2022-08-15 15:36:54 +02:00
parent a8edb5c1c9
commit 14d955dfaf
2 changed files with 5 additions and 19 deletions

View File

@ -3,16 +3,9 @@ function restore_options() {
if(result && result.baseURL.startsWith('http')) {
document.getElementById('open-stammtv').href = result.baseURL;
} else {
openSettings();
chrome.runtime.openOptionsPage();
}
});
}
function openSettings() {
chrome.tabs.create({
active: true,
url: 'settings/settings.html'
}, null);
}
document.addEventListener('DOMContentLoaded', restore_options);

View File

@ -1,3 +1,5 @@
chrome.contextMenus.onClicked.addListener(addToStammTV);
let WEBSOCKET_URL = "";
let websocket;
const CONTEXT_MENU_ID = "STAMMTV_ADD_URL_TO_PLAYLIST";
@ -5,7 +7,7 @@ const CONTEXT_MENU_ID = "STAMMTV_ADD_URL_TO_PLAYLIST";
chrome.storage.local.get('firstRun', function (result) {
if (result.firstRun === false) {
chrome.storage.local.set({'firstRun': false}, function (result) {
openSettings();
chrome.runtime.openOptionsPage();
});
} else {
chrome.storage.local.get(['baseURL', 'wssURL'], function (items) {
@ -13,19 +15,12 @@ chrome.storage.local.get('firstRun', function (result) {
WEBSOCKET_URL = items.wssURL;
init();
} else {
openSettings();
chrome.runtime.openOptionsPage();
}
});
}
});
function openSettings() {
chrome.tabs.create({
active: true,
url: 'settings/settings.html'
}, null);
}
function init() {
chrome.contextMenus.removeAll(function() {
chrome.contextMenus.create({
@ -34,8 +29,6 @@ function init() {
id: CONTEXT_MENU_ID
});
});
chrome.contextMenus.onClicked.addListener(addToStammTV);
}
function parseYoutubeURL(url) {