added build script for ff, fixed a bug and did some more shit
This commit is contained in:
parent
2a3b3fd495
commit
c7bb0b8956
2
.idea/artifacts/chrome.xml
generated
2
.idea/artifacts/chrome.xml
generated
@ -1,5 +1,5 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact name="chrome">
|
||||
<artifact build-on-make="true" name="chrome">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/chrome</output-path>
|
||||
<root id="root">
|
||||
<element id="dir-copy" path="$PROJECT_DIR$/base" />
|
||||
|
9
.idea/artifacts/firefox.xml
generated
9
.idea/artifacts/firefox.xml
generated
@ -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
|
||||
|
||||
```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
|
||||
- Chromium based Browser (Chrome, Edge, ..)
|
||||
|
0
base/contextMenuHandler.js
Normal file
0
base/contextMenuHandler.js
Normal file
@ -4,8 +4,9 @@
|
||||
<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>
|
||||
<body style="min-width: 10rem; min-height: 5rem; display: grid; justify-content: center; 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="/options/options.html" id="open-settings" target="_blank" style="font-weight: bold;">⚙ Settings</a>
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,45 +1,64 @@
|
||||
let WEBSOCKET_URL = "";
|
||||
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) {
|
||||
firstRun();
|
||||
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 firstRun(){
|
||||
chrome.storage.local.set({'firstRun': false}, function (result) {
|
||||
chrome.tabs.create
|
||||
});
|
||||
|
||||
function openSettings() {
|
||||
chrome.tabs.create({
|
||||
active: true,
|
||||
url: 'options/options.html'
|
||||
}, null);
|
||||
}
|
||||
|
||||
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+)?.*/;
|
||||
function handleValidityCheckResult(validSettings) {
|
||||
if (validSettings) {
|
||||
addContextMenuItem();
|
||||
} else {
|
||||
openSettings();
|
||||
}
|
||||
}
|
||||
|
||||
let WEBSOCKET_URL = "";
|
||||
let websocket;
|
||||
function addContextMenuItem() {
|
||||
chrome.contextMenus.removeAll(function() {
|
||||
chrome.contextMenus.create({
|
||||
title: "Zu StammTV Playlist hinzufügen...",
|
||||
contexts: ["link"],
|
||||
id: CONTEXT_MENU_ID
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
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);
|
||||
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) {
|
||||
const playerReady = {"type":"playerReady"};
|
||||
const playerReady = {"type": "playerReady"};
|
||||
|
||||
const setVideo = {
|
||||
type: "setVideo",
|
||||
@ -69,4 +88,4 @@ function addToStammTV(info, tab) {
|
||||
console.error('o(一︿一+)o not a valid videoId');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
base/stammtv-bitty.png
Normal file
BIN
base/stammtv-bitty.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
base/stammtv-large.png
Normal file
BIN
base/stammtv-large.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
base/stammtv-small.png
Normal file
BIN
base/stammtv-small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
15
build-ff.sh
Normal file
15
build-ff.sh
Normal file
@ -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
|
@ -13,5 +13,10 @@
|
||||
],
|
||||
"action": {
|
||||
"default_popup": "popup/popup.html"
|
||||
},
|
||||
"icons": {
|
||||
"16": "stammtv-bitty.png",
|
||||
"48": "stammtv-small.png",
|
||||
"128": "stammtv-large.png"
|
||||
}
|
||||
}
|
@ -4,7 +4,9 @@
|
||||
"version": "1.0",
|
||||
"manifest_version": 2,
|
||||
"background": {
|
||||
"scripts": ["script.js"]
|
||||
"scripts": [
|
||||
"script.js"
|
||||
]
|
||||
},
|
||||
"options_page": "options/options.html",
|
||||
"permissions": [
|
||||
@ -13,5 +15,10 @@
|
||||
],
|
||||
"action": {
|
||||
"default_popup": "popup/popup.html"
|
||||
},
|
||||
"icons": {
|
||||
"16": "icon-bitty.png",
|
||||
"48": "icon-small.png",
|
||||
"128": "icon-large.png"
|
||||
}
|
||||
}
|
@ -13,5 +13,10 @@
|
||||
],
|
||||
"action": {
|
||||
"default_popup": "popup/popup.html"
|
||||
},
|
||||
"icons": {
|
||||
"16": "stammtv-bitty.png",
|
||||
"48": "stammtv-small.png",
|
||||
"128": "stammtv-large.png"
|
||||
}
|
||||
}
|
@ -4,8 +4,9 @@
|
||||
<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>
|
||||
<body style="min-width: 10rem; min-height: 5rem; display: grid; justify-content: center; 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="/options/options.html" id="open-settings" target="_blank" style="font-weight: bold;">⚙ Settings</a>
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,31 +1,64 @@
|
||||
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;
|
||||
const CONTEXT_MENU_ID = "STAMMTV_ADD_URL_TO_PLAYLIST";
|
||||
|
||||
chrome.storage.local.get('wssURL', function (result) {
|
||||
WEBSOCKET_URL = result.wssURL;
|
||||
chrome.storage.local.get('firstRun', function (result) {
|
||||
console.log(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)
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
chrome.contextMenus.create({
|
||||
title: "Zu StammTV Playlist hinzufügen...",
|
||||
contexts: ["link"],
|
||||
id: CONTEXT_MENU_ID
|
||||
});
|
||||
function openSettings() {
|
||||
chrome.tabs.create({
|
||||
active: true,
|
||||
url: 'options/options.html'
|
||||
}, null);
|
||||
}
|
||||
|
||||
chrome.contextMenus.onClicked.addListener(addToStammTV);
|
||||
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) {
|
||||
const playerReady = {"type":"playerReady"};
|
||||
const playerReady = {"type": "playerReady"};
|
||||
|
||||
const setVideo = {
|
||||
type: "setVideo",
|
||||
@ -55,4 +88,4 @@ function addToStammTV(info, tab) {
|
||||
console.error('o(一︿一+)o not a valid videoId');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
Block a user