From 14d955dfaf936f7c69b15153a6a95b1c6a6a1a04 Mon Sep 17 00:00:00 2001 From: and94x Date: Mon, 15 Aug 2022 15:36:54 +0200 Subject: [PATCH] make use of chrome.runtime instead of spawning a tab --- base/popup/popup.js | 9 +-------- base/script.js | 15 ++++----------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/base/popup/popup.js b/base/popup/popup.js index dca19b1..f87a66c 100644 --- a/base/popup/popup.js +++ b/base/popup/popup.js @@ -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); diff --git a/base/script.js b/base/script.js index 30c5297..3c12bd1 100644 --- a/base/script.js +++ b/base/script.js @@ -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) {