make use of chrome.runtime instead of spawning a tab

master
and94x 2 years ago
parent a8edb5c1c9
commit 14d955dfaf

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

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

Loading…
Cancel
Save