This commit is contained in:
parent
c1ae22edd3
commit
f6b708b247
@ -7,7 +7,7 @@
|
||||
"48": "icon-48.png",
|
||||
"128": "icon-128.png"
|
||||
},
|
||||
"version": "100.0",
|
||||
"version": "102.0",
|
||||
"manifest_version": 3,
|
||||
"permissions": ["tabs"],
|
||||
"action": {
|
||||
|
@ -5,5 +5,6 @@
|
||||
</head>
|
||||
<body>
|
||||
<button>Proxy Stream</button>
|
||||
<button>Play on kodi</button>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -3,11 +3,11 @@ providers.set("www.youtube.com", "youtube");
|
||||
providers.set("youtube.com", "youtube");
|
||||
providers.set("youtu.be", "youtube");
|
||||
providers.set("tv.nrk.no", "nrk");
|
||||
providers.set("nx12210.your-storageshare.de", "nextcloud");
|
||||
providers.set("seafile.purser.it", "seafile");
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
let [button] = document.getElementsByTagName("button");
|
||||
button.addEventListener("click", (ev) => {
|
||||
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);
|
||||
let newurl = new URL("https://stream.purser.it");
|
||||
@ -30,4 +30,37 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
chrome.tabs.create(tab);
|
||||
});
|
||||
});
|
||||
kodiButton.addEventListener("click", (ev) => {
|
||||
chrome.tabs.query({currentWindow: true, active: true}, (tabs) => {
|
||||
let oldurl = new URL(tabs[0].url);
|
||||
let newurl = new URL(tabs[0].url);
|
||||
let search = new URLSearchParams();
|
||||
let hostname = oldurl.hostname.toLowerCase();
|
||||
if(hostname.includes("youtube.com")) {
|
||||
newurl = new URL("plugin://plugin.video.youtube")
|
||||
search.append("action", "play_video")
|
||||
let video_id = oldurl.searchParams.get("v");
|
||||
if(newpath) {
|
||||
search.append("videoid", video_id)
|
||||
}
|
||||
}
|
||||
newurl.search = search.toString();
|
||||
|
||||
let req = {
|
||||
jsonrpc: "2.0",
|
||||
method: "Player.Open",
|
||||
id: secrets.token_hex(),
|
||||
params: {
|
||||
item: {
|
||||
file: newurl.href
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fetch("http://127.0.0.1:8083/jsonrpc", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(req)
|
||||
}).then(resp => console.log(resp))
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user