༼ つ ◕_◕ ༽つ

master
and94x 2 years ago
parent eb9a294b1d
commit 2d9342f089

1
.gitignore vendored

@ -0,0 +1 @@
/out/*

@ -1,9 +1,17 @@
## Build # Build
1. Checkout and dir into project folder
```shell ```shell
cd base; find base -type f -exec zip out/artifacts/firefox/extension.crx {} + git checkout https://lab.thereno.cloud/stammtv-extension
find firefox -type f -exec zip out/artifacts/firefox/extension.crx {} + cd stammtv-extension
zip -r out/artifacts/firefox/extension.crx base/* firefox/*
``` ```
## Prerequisites 2.1 For Firefox
- Chromium based Browser (Chrome, Edge, ..) ```shell
./build-ff.sh
```
2.2 For Chrome
```shell
./build-chrome.sh
```

@ -4,9 +4,17 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Popup</title> <title>Popup</title>
</head> </head>
<body style="min-width: 10rem; min-height: 5rem; display: grid; justify-content: center; align-items: center;"> <body style="min-width: 8rem; display: flex; align-items: center;">
<a href="" id="open-stammtv" target="_blank" style="font-weight: bold; color: #ff0000; border: 2px solid black;">→ Take me to StammTV!</a> <a href="" id="open-stammtv" target="_blank">
<a href="/options/options.html" id="open-settings" target="_blank" style="font-weight: bold;">⚙ Settings</a> <img src="/stammtv-large.png" alt="StammTV Logo" height="128px" width="128px"/>
</a>
<a href="/options/options.html" id="open-settings" target="_blank" style="
text-decoration: none;
font-weight: 400;
font-size: 1rem;
width: 6rem;
color: black;
">⚙ Settings</a>
<script src="popup.js"></script> <script src="popup.js"></script>
</body> </body>
</html> </html>

@ -3,7 +3,6 @@ let websocket;
const CONTEXT_MENU_ID = "STAMMTV_ADD_URL_TO_PLAYLIST"; const CONTEXT_MENU_ID = "STAMMTV_ADD_URL_TO_PLAYLIST";
chrome.storage.local.get('firstRun', function (result) { chrome.storage.local.get('firstRun', function (result) {
console.log(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(); openSettings();
@ -58,14 +57,6 @@ function addToStammTV(info, tab) {
if (info.menuItemId === CONTEXT_MENU_ID) { //if OUR menu item was clicked if (info.menuItemId === CONTEXT_MENU_ID) { //if OUR menu item was clicked
let videoId = parseYoutubeURL(info.linkUrl) let videoId = parseYoutubeURL(info.linkUrl)
if (videoId) { if (videoId) {
const playerReady = {"type": "playerReady"};
const setVideo = {
type: "setVideo",
video: videoId,
};
console.log(websocket);
if (websocket === undefined if (websocket === undefined
|| websocket.readyState !== WebSocket.OPEN) { || websocket.readyState !== WebSocket.OPEN) {
websocket = new WebSocket(WEBSOCKET_URL); websocket = new WebSocket(WEBSOCKET_URL);
@ -73,8 +64,16 @@ function addToStammTV(info, tab) {
} }
websocket.onopen = function () { websocket.onopen = function () {
console.log('websocket ready'); console.log('websocket ready - sending');
const playerReady = {"type": "playerReady"};
websocket.send(JSON.stringify(playerReady)); websocket.send(JSON.stringify(playerReady));
console.log(playerReady);
const setVideo = {
type: "setVideo",
video: videoId,
};
websocket.send(JSON.stringify(setVideo)); websocket.send(JSON.stringify(setVideo));
console.log(setVideo); console.log(setVideo);
}; };

@ -1,24 +1,29 @@
{ {
"name": "StammTV Firefox Extension", "name": "StammTV Context Menu",
"description": "Adds a context-menu option to send URLs to StammTV", "description": "Adds a context-menu option to send URLs to your instance of StammTV",
"version": "1.0", "version": "1.0",
"manifest_version": 2, "manifest_version": 2,
"background": { "background": {
"scripts": [ "scripts": [
"script.js" "script.js"
] ],
"persistent": true
},
"options_ui":{
"page": "options/options.html",
"open_in_tab": true
}, },
"options_page": "options/options.html",
"permissions": [ "permissions": [
"storage", "storage",
"contextMenus" "contextMenus"
], ],
"action": { "browser_action": {
"default_title": "StammTV Context-Menu",
"default_popup": "popup/popup.html" "default_popup": "popup/popup.html"
}, },
"icons": { "icons": {
"16": "icon-bitty.png", "16": "stammtv-bitty.png",
"48": "icon-small.png", "48": "stammtv-small.png",
"128": "icon-large.png" "128": "stammtv-large.png"
} }
} }

@ -4,9 +4,17 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Popup</title> <title>Popup</title>
</head> </head>
<body style="min-width: 10rem; min-height: 5rem; display: grid; justify-content: center; align-items: center;"> <body style="min-width: 8rem; display: flex; align-items: center;">
<a href="" id="open-stammtv" target="_blank" style="font-weight: bold; color: #ff0000; border: 2px solid black;">→ Take me to StammTV!</a> <a href="" id="open-stammtv" target="_blank">
<a href="/options/options.html" id="open-settings" target="_blank" style="font-weight: bold;">⚙ Settings</a> <img src="/stammtv-large.png" alt="StammTV Logo" height="128px" width="128px"/>
</a>
<a href="/options/options.html" id="open-settings" target="_blank" style="
text-decoration: none;
font-weight: 400;
font-size: 1rem;
width: 6rem;
color: black;
">⚙ Settings</a>
<script src="popup.js"></script> <script src="popup.js"></script>
</body> </body>
</html> </html>

@ -3,7 +3,6 @@ let websocket;
const CONTEXT_MENU_ID = "STAMMTV_ADD_URL_TO_PLAYLIST"; const CONTEXT_MENU_ID = "STAMMTV_ADD_URL_TO_PLAYLIST";
chrome.storage.local.get('firstRun', function (result) { chrome.storage.local.get('firstRun', function (result) {
console.log(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(); openSettings();
@ -58,14 +57,6 @@ function addToStammTV(info, tab) {
if (info.menuItemId === CONTEXT_MENU_ID) { //if OUR menu item was clicked if (info.menuItemId === CONTEXT_MENU_ID) { //if OUR menu item was clicked
let videoId = parseYoutubeURL(info.linkUrl) let videoId = parseYoutubeURL(info.linkUrl)
if (videoId) { if (videoId) {
const playerReady = {"type": "playerReady"};
const setVideo = {
type: "setVideo",
video: videoId,
};
console.log(websocket);
if (websocket === undefined if (websocket === undefined
|| websocket.readyState !== WebSocket.OPEN) { || websocket.readyState !== WebSocket.OPEN) {
websocket = new WebSocket(WEBSOCKET_URL); websocket = new WebSocket(WEBSOCKET_URL);
@ -73,8 +64,16 @@ function addToStammTV(info, tab) {
} }
websocket.onopen = function () { websocket.onopen = function () {
console.log('websocket ready'); console.log('websocket ready - sending');
const playerReady = {"type": "playerReady"};
websocket.send(JSON.stringify(playerReady)); websocket.send(JSON.stringify(playerReady));
console.log(playerReady);
const setVideo = {
type: "setVideo",
video: videoId,
};
websocket.send(JSON.stringify(setVideo)); websocket.send(JSON.stringify(setVideo));
console.log(setVideo); console.log(setVideo);
}; };

Loading…
Cancel
Save