diff --git a/.gitignore b/.gitignore index ceaea36..64fc9a4 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,4 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* - +.DS_store diff --git a/README.md b/README.md index 2f14d82..d0adf3f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # ytdlp-bot-chromeaddon +I mean it's almost selfexplained what this is for and what it does. \ No newline at end of file diff --git a/pack.sh b/pack.sh new file mode 100644 index 0000000..ead0063 --- /dev/null +++ b/pack.sh @@ -0,0 +1,2 @@ +#!/bin/sh +# TODO \ No newline at end of file diff --git a/src/assets/icon.jpg b/src/assets/icon.jpg new file mode 100644 index 0000000..a668c96 Binary files /dev/null and b/src/assets/icon.jpg differ diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 0000000..48bdc82 --- /dev/null +++ b/src/manifest.json @@ -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/*" + ] + } + ] + } \ No newline at end of file diff --git a/src/scripts/com.youtube.js b/src/scripts/com.youtube.js new file mode 100644 index 0000000..5436207 --- /dev/null +++ b/src/scripts/com.youtube.js @@ -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) + diff --git a/src/scripts/popup.js b/src/scripts/popup.js new file mode 100644 index 0000000..1912241 --- /dev/null +++ b/src/scripts/popup.js @@ -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 = `