diff --git a/out/artifacts/chrome/base.iml b/out/artifacts/chrome/base.iml deleted file mode 100644 index 183c2ef..0000000 --- a/out/artifacts/chrome/base.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/out/artifacts/chrome/chrome.iml b/out/artifacts/chrome/chrome.iml deleted file mode 100644 index 183c2ef..0000000 --- a/out/artifacts/chrome/chrome.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/out/artifacts/chrome/manifest.json b/out/artifacts/chrome/manifest.json deleted file mode 100644 index bd4be07..0000000 --- a/out/artifacts/chrome/manifest.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "StammTV Chrome Extension", - "description": "Adds a context-menu option to send URLs to StammTV", - "version": "1.0", - "manifest_version": 3, - "background": { - "service_worker": "script.js" - }, - "options_page": "options/options.html", - "permissions": [ - "storage", - "contextMenus" - ], - "action": { - "default_popup": "popup/popup.html" - }, - "icons": { - "16": "stammtv-bitty.png", - "48": "stammtv-small.png", - "128": "stammtv-large.png" - } -} \ No newline at end of file diff --git a/out/artifacts/chrome/options/options.html b/out/artifacts/chrome/options/options.html deleted file mode 100644 index 6e70d54..0000000 --- a/out/artifacts/chrome/options/options.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - Options for StammTV Chrome Extension - - - - - -
-

StammTV Extension Settings

- -
-
- -
- - - Enter the StammTV Base URL, beginning with http:// or https:// - -
- -
-
- -
- - - Enter the StammTV WSS URL, beginning with wss:// - -
-
-
- -
-
- - - - \ No newline at end of file diff --git a/out/artifacts/chrome/options/options.js b/out/artifacts/chrome/options/options.js deleted file mode 100644 index 1e1b0f8..0000000 --- a/out/artifacts/chrome/options/options.js +++ /dev/null @@ -1,54 +0,0 @@ -// Saves options to chrome.storage -function save_options() { - let stammTVBaseUrl = document.getElementById('stammtv-base-url'); - let stammTVWSSUrl = document.getElementById('stammtv-wss-url'); - let saveButton = document.getElementById('save'); - - let valid = true; - if (stammTVBaseUrl.value.startsWith('http')) { - stammTVBaseUrl.classList.add('is-valid'); - valid = valid && true; - } else { - stammTVBaseUrl.classList.add('is-invalid'); - valid = false; - } - - if (stammTVWSSUrl.value.startsWith('wss://')) { - stammTVWSSUrl.classList.add('is-valid'); - valid = valid && true; - } else { - stammTVWSSUrl.classList.add('is-invalid'); - valid = false; - } - - if(valid) { - chrome.storage.local.set({ - baseURL: stammTVBaseUrl.value, - wssURL: stammTVWSSUrl.value - }, function () { - // Update form controls to let user know options were saved. - saveButton.classList.replace('btn-primary', 'btn-success'); - saveButton.classList.replace('btn-danger', 'btn-success'); - saveButton.textContent = '... saved!'; - }); - } else { - saveButton.classList.replace('btn-primary', 'btn-danger'); - saveButton.classList.replace('btn-success', 'btn-danger'); - saveButton.textContent = '... failed to save!'; - } -} - -// Restores select box and checkbox state using the preferences -// stored in chrome.storage. -function restore_options() { - chrome.storage.local.get({ - baseURL: 'Please fill in.', - wssURL: 'Please fill in.' - }, function (items) { - document.getElementById('stammtv-base-url').value = items.baseURL; - document.getElementById('stammtv-wss-url').value = items.wssURL; - }); -} - -document.addEventListener('DOMContentLoaded', restore_options); -document.getElementById('save').addEventListener('click', save_options); \ No newline at end of file diff --git a/out/artifacts/chrome/popup/popup.html b/out/artifacts/chrome/popup/popup.html deleted file mode 100644 index 020c02e..0000000 --- a/out/artifacts/chrome/popup/popup.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - Popup - - - - StammTV Logo - -⚙ Settings - - - \ No newline at end of file diff --git a/out/artifacts/chrome/popup/popup.js b/out/artifacts/chrome/popup/popup.js deleted file mode 100644 index 857c049..0000000 --- a/out/artifacts/chrome/popup/popup.js +++ /dev/null @@ -1,7 +0,0 @@ -function restore_options() { - chrome.storage.local.get('baseURL', function (result) { - document.getElementById('open-stammtv').href = result.baseURL; - }); -} - -document.addEventListener('DOMContentLoaded', restore_options); diff --git a/out/artifacts/chrome/script.js b/out/artifacts/chrome/script.js deleted file mode 100644 index e1c7c8c..0000000 --- a/out/artifacts/chrome/script.js +++ /dev/null @@ -1,90 +0,0 @@ -let WEBSOCKET_URL = ""; -let websocket; -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(); - }); - } else { - chrome.storage.local.get(['baseURL', 'wssURL'], function (items) { - if (items.wssURL !== undefined && items.wssURL.startsWith('wss://')) { - WEBSOCKET_URL = items.wssURL; - handleValidityCheckResult(true) - } - }); - } -}); - -function openSettings() { - chrome.tabs.create({ - active: true, - url: 'options/options.html' - }, null); -} - -function handleValidityCheckResult(validSettings) { - if (validSettings) { - addContextMenuItem(); - } else { - openSettings(); - } -} - -function addContextMenuItem() { - chrome.contextMenus.removeAll(function() { - chrome.contextMenus.create({ - title: "Zu StammTV Playlist hinzufügen...", - contexts: ["link"], - id: CONTEXT_MENU_ID - }); - }); - - chrome.contextMenus.onClicked.addListener(addToStammTV); -} - -function parseYoutubeURL(url) { - const YOUTUBE_URL_REGEX = /^(?:https?:\/\/(?:www\.)?youtu(?:\.be\/|be\.com\/watch\?v=|be\.com\/shorts\/)){1}([^#&?]*)(?:[?&]t=\d+)?.*/; - - let match = url.match(YOUTUBE_URL_REGEX); - return (match && match[1].length === 11) ? match[1] : false; -} - - - -function addToStammTV(info, tab) { - if (info.menuItemId === CONTEXT_MENU_ID) { //if OUR menu item was clicked - let videoId = parseYoutubeURL(info.linkUrl) - if (videoId) { - if (websocket === undefined - || websocket.readyState !== WebSocket.OPEN) { - websocket = new WebSocket(WEBSOCKET_URL); - console.log('websocket created'); - } - - websocket.onopen = function () { - console.log('websocket ready - sending'); - - const playerReady = {"type": "playerReady"}; - websocket.send(JSON.stringify(playerReady)); - console.log(playerReady); - - const setVideo = { - type: "setVideo", - video: videoId, - }; - websocket.send(JSON.stringify(setVideo)); - console.log(setVideo); - }; - - setTimeout(function () { - websocket.close(); - console.log('websocket closed'); - }, 1000); - - } else { - console.error('o(一︿一+)o not a valid videoId'); - } - } -}