2024.05.20.22.29

This commit is contained in:
Luca 2024-05-20 22:50:55 +02:00
parent f12f75f236
commit 9b19f76350
10 changed files with 206 additions and 1 deletions

2
.gitignore vendored
View File

@ -129,4 +129,4 @@ dist
.yarn/build-state.yml .yarn/build-state.yml
.yarn/install-state.gz .yarn/install-state.gz
.pnp.* .pnp.*
.DS_store

View File

@ -1,2 +1,3 @@
# ytdlp-bot-chromeaddon # ytdlp-bot-chromeaddon
I mean it's almost selfexplained what this is for and what it does.

2
pack.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh
# TODO

BIN
src/assets/icon.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

33
src/manifest.json Normal file
View File

@ -0,0 +1,33 @@
{
"manifest_version": 3,
"name": "DC-YTDLP",
"description": "--",
"version": "1.0",
"action": {
"default_popup": "views/popup.html",
"default_icon": "assets/icon.jpg"
},
"icons":{
"16":"assets/icon.jpg",
"48":"assets/icon.jpg",
"128":"assets/icon.jpg"
},
"side_panel":{
"default_path":"views/sidepanel.html"
},
"permissions":[
"storage",
"sidePanel",
"activeTab",
"tabs"
],
"content_scripts": [
{
"js": ["scripts/com.youtube.js"],
"matches": [
"https://www.youtube.com/*",
"https://youtube.com/*"
]
}
]
}

View File

@ -0,0 +1,22 @@
setTimeout(function(){
let menu = document.getElementById("center");
let dl_send = document.createElement("button");
dl_send.innerText = "TEst";
//menu.append(dl_send)
dl_send.addEventListener("click",sendLink);
async function sendLink(){
let url = window.location;
let u = (await chrome.storage.sync.get("settings_url")).settings_url;
alert(url);
fetch(u,{
method:"POST",
body:{
url:url,
type:"mp3"
}
})
}
},2000)

45
src/scripts/popup.js Normal file
View File

@ -0,0 +1,45 @@
let btn_sendURL;
let btn_sendURL_mp4;
let alertBox;
function startUp() {
btn_sendURL = document.getElementById("sendURL");
btn_sendURL_mp4 = document.getElementById("sendURL_mp4");
alertBox = document.getElementById("alerts")
btn_sendURL.addEventListener("click", sendURL);
btn_sendURL_mp4.addEventListener("click", sendURL_mp4)
}
async function sendURL() {
sendLink("mp3");
}
async function sendURL_mp4() {
sendLink("mp4");
}
async function sendLink(type) {
let tab = await chrome.tabs.query({ windowType: "normal", active: true });
let url = tab[0].url;
let u = (await chrome.storage.sync.get("settings_url")).settings_url;
//alert(url);
let resp = await fetch(`${u}/getSong`, {
method: "POST",
headers: {
"content-type": "application/puppy+json",
// 'Content-Type': 'application/x-www-form-urlencoded',
},
body: JSON.stringify({
url: url,
type: type
})
});
let json_resp = await resp.json();
alertBox.innerHTML = `<div class="alert">${json_resp.text}</div>`;
btn_sendURL.disabled = true;
btn_sendURL_mp4.disabled = true;
}
startUp();

31
src/scripts/settings.js Normal file
View File

@ -0,0 +1,31 @@
let urlField;
let saveButton;
let testButton;
async function startUp(){
urlField = document.getElementById("url");
saveButton = document.getElementById("save");
testButton = document.getElementById("testButton")
saveButton.addEventListener("click",saveSettings)
testButton.addEventListener("click",Test)
urlField.value = (await chrome.storage.sync.get("settings_url")).settings_url;
}
function saveSettings(){
let tmp_val = urlField.value;
chrome.storage.sync.set({ "settings_url": tmp_val });
alert(`Save - ${tmp_val}`);
}
function Test(){
chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => {
let url = tabs[0].url;
alert(url);
// use `url` here inside the callback because it's asynchronous!
});
}
startUp();

47
src/views/popup.html Normal file
View File

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hi</title>
<style>
html {
min-height: 50px;
min-width: 300px;
background:#121212;
}
button{
width:calc(100% - 10px);
padding:5px;
margin:5px;
background-color:#00A6A6;
color:#FFF;
transition: cubic-bezier(0.075, 0.82, 0.165, 1) .5s;
}
button:hover{
transition: cubic-bezier(0.075, 0.82, 0.165, 1) .5s;
text-decoration: underline;
background-color: #009696;
}
button:disabled{
background-color: #676767;
}
.alert{
border: 1px solid #DD0000;
background-color: #414141;
color: #FFF;
}
</style>
</head>
<body>
<button id="sendURL">Send URL - get MP3</button>
<button id="sendURL_mp4">Send URL - get MP4</button>
<div id="alerts">
</div>
<script src="../scripts/popup.js"></script>
</body>
</html>

24
src/views/sidepanel.html Normal file
View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html{min-height:300px;min-width:600px}
body{
width:600px;
min-width: 600px;
}
</style>
</head>
<body>
<div>
URL:<input type="text" id="url"><button id="save">Save</button>
<br/>
<button id="testButton">Test</button>
</div>
<script src="../scripts/settings.js"></script>
</body>
</html>