removed artifacts

master
and94x 2 years ago
parent 27425109c9
commit 20f60e73b0

@ -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,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"
}
}

@ -1,45 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Options for StammTV Chrome Extension</title>
<link rel="icon" type="image/x-icon" href="../stammtv-bitty.png">
<link href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"
crossorigin="anonymous">
<link rel="stylesheet" href="options.css"/>
</head>
<body class="bg-dark" style="width: 80%;margin: 0 auto ">
<div style="display: grid">
<h1 class="mb-5 text-center">StammTV Extension Settings <img src="../stammtv-large.png"/></h1>
<form>
<div class="form-group row mb-3">
<label for="stammtv-base-url" class="col-sm-2 col-form-label">StammTV Base URL</label>
<div class="col-sm-10">
<input id="stammtv-base-url" type="url" class="form-control dark"
placeholder="https://..." aria-label="Add" required>
<small class="form-text text-white" id="stammtv-base-url-small">
Enter the StammTV Base URL, beginning with http:// or https://
</small>
</div>
</div>
<div class="form-group row mb-3">
<label for="stammtv-wss-url" class="col-sm-2 col-form-label">StammTV WSS URL</label>
<div class="col-sm-10">
<input id="stammtv-wss-url" type="url" class="form-control dark"
placeholder="wss://..." aria-label="Add" required>
<small class="form-text text-white" id="stammtv-wss-url-small">
Enter the StammTV WSS URL, beginning with wss://
</small>
</div>
</div>
<div id="status" style="color: #259025"></div>
<button class="btn btn-primary" type="button" id="save" title="Submit and save">
Save
</button>
</form>
</div>
<script src="options.js"></script>
</body>
</html>

@ -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);

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Popup</title>
</head>
<body style="min-width: 8rem; display: flex; align-items: center;">
<a href="" id="open-stammtv" target="_blank">
<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>
</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,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');
}
}
}
Loading…
Cancel
Save