From 2d9342f089f14cb0c52a635d85e8b624d8356972 Mon Sep 17 00:00:00 2001 From: and94x Date: Fri, 12 Aug 2022 22:42:42 +0200 Subject: [PATCH] =?UTF-8?q?=E0=BC=BC=20=E3=81=A4=20=E2=97=95=5F=E2=97=95?= =?UTF-8?q?=20=E0=BC=BD=E3=81=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + README.md | 20 ++++++++++++++------ base/contextMenuHandler.js | 0 base/popup/popup.html | 14 +++++++++++--- base/script.js | 19 +++++++++---------- firefox/manifest.json | 21 +++++++++++++-------- out/artifacts/chrome/popup/popup.html | 14 +++++++++++--- out/artifacts/chrome/script.js | 19 +++++++++---------- 8 files changed, 68 insertions(+), 40 deletions(-) create mode 100644 .gitignore delete mode 100644 base/contextMenuHandler.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0907cbc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/out/* \ No newline at end of file diff --git a/README.md b/README.md index 2a4dcdf..d4ea4d3 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,17 @@ -## Build +# Build + +1. Checkout and dir into project folder ```shell -cd base; find base -type f -exec zip out/artifacts/firefox/extension.crx {} + -find firefox -type f -exec zip out/artifacts/firefox/extension.crx {} + -zip -r out/artifacts/firefox/extension.crx base/* firefox/* +git checkout https://lab.thereno.cloud/stammtv-extension +cd stammtv-extension ``` -## Prerequisites -- Chromium based Browser (Chrome, Edge, ..) +2.1 For Firefox +```shell +./build-ff.sh +``` + +2.2 For Chrome +```shell +./build-chrome.sh +``` \ No newline at end of file diff --git a/base/contextMenuHandler.js b/base/contextMenuHandler.js deleted file mode 100644 index e69de29..0000000 diff --git a/base/popup/popup.html b/base/popup/popup.html index 56ff8e3..020c02e 100644 --- a/base/popup/popup.html +++ b/base/popup/popup.html @@ -4,9 +4,17 @@ Popup - -→ Take me to StammTV! -⚙ Settings + + + StammTV Logo + +⚙ Settings \ No newline at end of file diff --git a/base/script.js b/base/script.js index 18b8f50..e1c7c8c 100644 --- a/base/script.js +++ b/base/script.js @@ -3,7 +3,6 @@ let websocket; const CONTEXT_MENU_ID = "STAMMTV_ADD_URL_TO_PLAYLIST"; chrome.storage.local.get('firstRun', function (result) { - console.log(result); if (result.firstRun === false) { chrome.storage.local.set({'firstRun': false}, function (result) { openSettings(); @@ -58,14 +57,6 @@ function addToStammTV(info, tab) { if (info.menuItemId === CONTEXT_MENU_ID) { //if OUR menu item was clicked let videoId = parseYoutubeURL(info.linkUrl) if (videoId) { - const playerReady = {"type": "playerReady"}; - - const setVideo = { - type: "setVideo", - video: videoId, - }; - - console.log(websocket); if (websocket === undefined || websocket.readyState !== WebSocket.OPEN) { websocket = new WebSocket(WEBSOCKET_URL); @@ -73,8 +64,16 @@ function addToStammTV(info, tab) { } websocket.onopen = function () { - console.log('websocket ready'); + 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); }; diff --git a/firefox/manifest.json b/firefox/manifest.json index 30261ba..0ada2a8 100644 --- a/firefox/manifest.json +++ b/firefox/manifest.json @@ -1,24 +1,29 @@ { - "name": "StammTV Firefox Extension", - "description": "Adds a context-menu option to send URLs to StammTV", + "name": "StammTV Context Menu", + "description": "Adds a context-menu option to send URLs to your instance of StammTV", "version": "1.0", "manifest_version": 2, "background": { "scripts": [ "script.js" - ] + ], + "persistent": true + }, + "options_ui":{ + "page": "options/options.html", + "open_in_tab": true }, - "options_page": "options/options.html", "permissions": [ "storage", "contextMenus" ], - "action": { + "browser_action": { + "default_title": "StammTV Context-Menu", "default_popup": "popup/popup.html" }, "icons": { - "16": "icon-bitty.png", - "48": "icon-small.png", - "128": "icon-large.png" + "16": "stammtv-bitty.png", + "48": "stammtv-small.png", + "128": "stammtv-large.png" } } \ No newline at end of file diff --git a/out/artifacts/chrome/popup/popup.html b/out/artifacts/chrome/popup/popup.html index 56ff8e3..020c02e 100644 --- a/out/artifacts/chrome/popup/popup.html +++ b/out/artifacts/chrome/popup/popup.html @@ -4,9 +4,17 @@ Popup - -→ Take me to StammTV! -⚙ Settings + + + StammTV Logo + +⚙ Settings \ No newline at end of file diff --git a/out/artifacts/chrome/script.js b/out/artifacts/chrome/script.js index 18b8f50..e1c7c8c 100644 --- a/out/artifacts/chrome/script.js +++ b/out/artifacts/chrome/script.js @@ -3,7 +3,6 @@ let websocket; const CONTEXT_MENU_ID = "STAMMTV_ADD_URL_TO_PLAYLIST"; chrome.storage.local.get('firstRun', function (result) { - console.log(result); if (result.firstRun === false) { chrome.storage.local.set({'firstRun': false}, function (result) { openSettings(); @@ -58,14 +57,6 @@ function addToStammTV(info, tab) { if (info.menuItemId === CONTEXT_MENU_ID) { //if OUR menu item was clicked let videoId = parseYoutubeURL(info.linkUrl) if (videoId) { - const playerReady = {"type": "playerReady"}; - - const setVideo = { - type: "setVideo", - video: videoId, - }; - - console.log(websocket); if (websocket === undefined || websocket.readyState !== WebSocket.OPEN) { websocket = new WebSocket(WEBSOCKET_URL); @@ -73,8 +64,16 @@ function addToStammTV(info, tab) { } websocket.onopen = function () { - console.log('websocket ready'); + 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); };