|
|
|
@ -12,13 +12,17 @@ const random = () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
|
let [proxyButton, kodiButton] = document.getElementsByTagName("button")
|
|
|
|
|
proxyButton.addEventListener("click", (ev) => {
|
|
|
|
|
chrome.tabs.query({currentWindow: true, active: true}, (tabs) => {
|
|
|
|
|
let oldurl = new URL(tabs[0].url)
|
|
|
|
|
const proxyButton = document.getElementById("proxy-button")
|
|
|
|
|
const kodiPlayButton = document.getElementById("kodi-play-button")
|
|
|
|
|
const kodiQueueButton = document.getElementById("kodi-queue-button")
|
|
|
|
|
|
|
|
|
|
async function handleProxyButton(ev) {
|
|
|
|
|
const [tab] = chrome.tabs.query({currentWindow: true, active: true})
|
|
|
|
|
const oldurl = new URL(tab.url)
|
|
|
|
|
const search = new URLSearchParams()
|
|
|
|
|
const hostname = oldurl.hostname.toLowerCase()
|
|
|
|
|
let newurl = new URL("https://stream.purser.it")
|
|
|
|
|
let search = new URLSearchParams()
|
|
|
|
|
let hostname = oldurl.hostname.toLowerCase()
|
|
|
|
|
|
|
|
|
|
if(providers.has(hostname)) {
|
|
|
|
|
if(hostname.includes("youtube.com")) {
|
|
|
|
|
let newpath = oldurl.searchParams.get("v")
|
|
|
|
@ -31,17 +35,18 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
|
search.append("provider", providers.get(hostname))
|
|
|
|
|
}
|
|
|
|
|
newurl.search = search.toString()
|
|
|
|
|
let tab = {}
|
|
|
|
|
tab.url = newurl.href
|
|
|
|
|
chrome.tabs.create(tab)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
kodiButton.addEventListener("click", (ev) => {
|
|
|
|
|
chrome.tabs.query({currentWindow: true, active: true}, (tabs) => {
|
|
|
|
|
let oldurl = new URL(tabs[0].url)
|
|
|
|
|
const newtab = {}
|
|
|
|
|
newtab.url = newurl.href
|
|
|
|
|
chrome.tabs.create(newtab)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function handleKodiButton(ev, method, playlistid) {
|
|
|
|
|
const [tab] = await chrome.tabs.query({currentWindow: true, active: true})
|
|
|
|
|
const oldurl = new URL(tab.url)
|
|
|
|
|
const search = new URLSearchParams()
|
|
|
|
|
const hostname = oldurl.hostname.toLowerCase()
|
|
|
|
|
let newurl = new URL("https://stream.purser.it")
|
|
|
|
|
let search = new URLSearchParams()
|
|
|
|
|
let hostname = oldurl.hostname.toLowerCase()
|
|
|
|
|
|
|
|
|
|
if(providers.has(hostname)) {
|
|
|
|
|
if(hostname.includes("youtube.com")) {
|
|
|
|
|
newurl = new URL("plugin://plugin.video.youtube")
|
|
|
|
@ -59,9 +64,9 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
|
|
|
|
|
|
newurl.search = search.toString()
|
|
|
|
|
|
|
|
|
|
let req = {
|
|
|
|
|
const req = {
|
|
|
|
|
jsonrpc: "2.0",
|
|
|
|
|
method: "Player.Open",
|
|
|
|
|
method: method,
|
|
|
|
|
id: random(),
|
|
|
|
|
params: {
|
|
|
|
|
item: {
|
|
|
|
@ -70,17 +75,27 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
fetch("http://127.0.0.1:4000/jsonrpc", {
|
|
|
|
|
if(playlistid) {
|
|
|
|
|
req.params.playlistid = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const resp = await fetch("http://127.0.0.1:4000/jsonrpc", {
|
|
|
|
|
method: "POST",
|
|
|
|
|
body: JSON.stringify(req),
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json; charset=utf-8"
|
|
|
|
|
}
|
|
|
|
|
}).then(resp => console.log(resp))
|
|
|
|
|
} catch(e) {
|
|
|
|
|
console.log(e)
|
|
|
|
|
})
|
|
|
|
|
console.log(resp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kodiPlayButton.addEventListener("click", async ev => {
|
|
|
|
|
await handleKodiButton(ev, "Player.Open")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
kodiQueueButton.addEventListener("click", async ev => {
|
|
|
|
|
await handleKodiButton(ev, "Playlist.Add", 1)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
proxyButton.addEventListener("click", handleProxyButton)
|
|
|
|
|
})
|
|
|
|
|