added build script for ff, fixed a bug and did some more shit
parent
2a3b3fd495
commit
c7bb0b8956
@ -1,9 +0,0 @@
|
|||||||
<component name="ArtifactManager">
|
|
||||||
<artifact name="firefox">
|
|
||||||
<output-path>$PROJECT_DIR$/out/artifacts/firefox</output-path>
|
|
||||||
<root id="root">
|
|
||||||
<element id="dir-copy" path="$PROJECT_DIR$/base" />
|
|
||||||
<element id="dir-copy" path="$PROJECT_DIR$/firefox" />
|
|
||||||
</root>
|
|
||||||
</artifact>
|
|
||||||
</component>
|
|
@ -1,5 +1,9 @@
|
|||||||
## Build
|
## Build
|
||||||
|
```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/*
|
||||||
|
```
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
- Chromium based Browser (Chrome, Edge, ..)
|
- Chromium based Browser (Chrome, Edge, ..)
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
PWD=$(pwd)
|
||||||
|
BASE_DIR=${PWD}/base
|
||||||
|
MANIFEST_DIR=${PWD}/firefox
|
||||||
|
OUT="../out/artifacts/firefox/extension.zip"
|
||||||
|
|
||||||
|
echo $BASE_DIR
|
||||||
|
echo $MANIFEST_DIR
|
||||||
|
echo $OUT
|
||||||
|
|
||||||
|
rm -f ${OUT}
|
||||||
|
cd "$BASE_DIR" || return
|
||||||
|
zip -r ${OUT} *
|
||||||
|
cd "${MANIFEST_DIR}" || return
|
||||||
|
zip -r ${OUT} manifest.json
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="GENERAL_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$/.." />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="GENERAL_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$/.." />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "StammTV Firefox Extension",
|
|
||||||
"description": "Adds a context-menu option to send URLs to StammTV",
|
|
||||||
"version": "1.0",
|
|
||||||
"manifest_version": 2,
|
|
||||||
"background": {
|
|
||||||
"scripts": ["script.js"]
|
|
||||||
},
|
|
||||||
"options_page": "options/options.html",
|
|
||||||
"permissions": [
|
|
||||||
"storage",
|
|
||||||
"contextMenus"
|
|
||||||
],
|
|
||||||
"action": {
|
|
||||||
"default_popup": "popup/popup.html"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Options for StammTV Chrome Extension</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div style="display: grid;">
|
|
||||||
<label>
|
|
||||||
StammTV Base URL: <input type="url" id="stammtv-base-url" style="min-width: 20rem;">
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
StammTV WSS URL: <input type="url" id="stammtv-wss-url" style="min-width: 20rem;">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="status" style="color: #259025"></div>
|
|
||||||
<button id="save">Save</button>
|
|
||||||
|
|
||||||
<script src="options.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,32 +0,0 @@
|
|||||||
// Saves options to chrome.storage
|
|
||||||
function save_options() {
|
|
||||||
var stammTVBaseUrl = document.getElementById('stammtv-base-url').value;;
|
|
||||||
var stammTVWSSUrl = document.getElementById('stammtv-wss-url').value;;
|
|
||||||
chrome.storage.local.set({
|
|
||||||
baseURL: stammTVBaseUrl,
|
|
||||||
wssURL: stammTVWSSUrl
|
|
||||||
}, function () {
|
|
||||||
// Update status to let user know options were saved.
|
|
||||||
var status = document.getElementById('status');
|
|
||||||
status.textContent = 'Saved.';
|
|
||||||
status.style.color = '00FF00';
|
|
||||||
setTimeout(function () {
|
|
||||||
status.textContent = '';
|
|
||||||
}, 1500);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
|
@ -1,11 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Popup</title>
|
|
||||||
</head>
|
|
||||||
<body style="min-width: 10rem; min-height: 5rem; display: flex; justify-content: center; align-items: center;">
|
|
||||||
<a href="" id="open-stammtv" target="_blank" style="font-weight: bold; color: #ff0000; border: 1px solid black">→ Take me to StammTV!</a>
|
|
||||||
<script src="popup.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -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);
|
|
@ -1,58 +0,0 @@
|
|||||||
const CONTEXT_MENU_ID = "STAMMTV_ADD_URL_TO_PLAYLIST";
|
|
||||||
const YOUTUBE_URL_REGEX = /^(?:https?:\/\/(?:www\.)?youtu(?:\.be\/|be\.com\/watch\?v=|be\.com\/shorts\/)){1}([^#&?]*)(?:[?&]t=\d+)?.*/;
|
|
||||||
let WEBSOCKET_URL = "";
|
|
||||||
|
|
||||||
let websocket;
|
|
||||||
|
|
||||||
chrome.storage.local.get('wssURL', function (result) {
|
|
||||||
WEBSOCKET_URL = result.wssURL;
|
|
||||||
});
|
|
||||||
|
|
||||||
chrome.contextMenus.create({
|
|
||||||
title: "Zu StammTV Playlist hinzufügen...",
|
|
||||||
contexts: ["link"],
|
|
||||||
id: CONTEXT_MENU_ID
|
|
||||||
});
|
|
||||||
|
|
||||||
chrome.contextMenus.onClicked.addListener(addToStammTV);
|
|
||||||
|
|
||||||
function parseYoutubeURL(url) {
|
|
||||||
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) {
|
|
||||||
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);
|
|
||||||
console.log('websocket created');
|
|
||||||
}
|
|
||||||
|
|
||||||
websocket.onopen = function () {
|
|
||||||
console.log('websocket ready');
|
|
||||||
websocket.send(JSON.stringify(playerReady));
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue