Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
0eedf53fc8 | |||
1e6316f2b3 | |||
da2c738c52 | |||
a190acd1d8 | |||
93547547f1 | |||
050cf89b45 |
@ -1,13 +1,13 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
steps:
|
||||
- name: compile-chrome
|
||||
image: roypur/chrome-packer:latest
|
||||
- name: compile-extensions
|
||||
image: roypur/extension-packer:latest
|
||||
environment:
|
||||
CHROME_PRIVKEY:
|
||||
from_secret: chrome_privkey
|
||||
commands:
|
||||
- ./pack-chrome.sh
|
||||
- ./pack-browsers.sh
|
||||
- name: gitea_release
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
@ -15,6 +15,6 @@ steps:
|
||||
from_secret: gitea_token
|
||||
base_url: https://git.purser.it
|
||||
title: ${DRONE_TAG}
|
||||
files: out/proxy-stream-${DRONE_TAG}.crx
|
||||
files: out/proxy-stream-${DRONE_TAG}.crx out/proxy-stream-${DRONE_TAG}.xpi
|
||||
when:
|
||||
event: tag
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,4 +11,5 @@ android/.gradle/*
|
||||
android/gradle/*
|
||||
chrome/*.png
|
||||
*.crx
|
||||
*.xpi
|
||||
sources.json
|
||||
|
@ -7,7 +7,7 @@
|
||||
"48": "icon-48.png",
|
||||
"128": "icon-128.png"
|
||||
},
|
||||
"version": "108.0",
|
||||
"version": "111.0",
|
||||
"manifest_version": 3,
|
||||
"host_permissions": ["http://127.0.0.1:4000/jsonrpc"],
|
||||
"permissions": ["tabs"],
|
||||
|
@ -4,7 +4,8 @@
|
||||
<title>Proxy Stream</title>
|
||||
</head>
|
||||
<body>
|
||||
<button>Proxy Stream</button>
|
||||
<button>Play on kodi</button>
|
||||
<button id="proxy-button">Proxy Stream</button>
|
||||
<button id="kodi-play-button">Play on kodi</button>
|
||||
<button id="kodi-queue-button">Queue on kodi</button>
|
||||
</body>
|
||||
</html>
|
||||
|
140
chrome/script.js
140
chrome/script.js
@ -12,75 +12,111 @@ 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)
|
||||
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")
|
||||
if((newpath instanceof String) || ((typeof newpath) === "string")) {
|
||||
newurl.pathname = "/" + newpath
|
||||
}
|
||||
} else {
|
||||
newurl.pathname = oldurl.pathname
|
||||
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")
|
||||
|
||||
if(providers.has(hostname)) {
|
||||
if(hostname.includes("youtube.com")) {
|
||||
let newpath = oldurl.searchParams.get("v")
|
||||
if(newpath) {
|
||||
newurl.pathname = "/" + newpath
|
||||
}
|
||||
search.append("provider", providers.get(hostname))
|
||||
} else {
|
||||
newurl.pathname = oldurl.pathname
|
||||
}
|
||||
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)
|
||||
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")) {
|
||||
search.append("provider", providers.get(hostname))
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
newurl.search = search.toString()
|
||||
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")
|
||||
|
||||
if(providers.has(hostname)) {
|
||||
if(hostname.includes("youtube.com")) {
|
||||
newurl = new URL("plugin://plugin.video.youtube")
|
||||
search.append("action", "play_video")
|
||||
const video_id = oldurl.searchParams.get("v")
|
||||
if(video_id) {
|
||||
search.append("videoid", video_id)
|
||||
}
|
||||
} else {
|
||||
search.append("provider", providers.get(hostname))
|
||||
search.append("raw", "true")
|
||||
newurl.pathname = oldurl.pathname
|
||||
}
|
||||
} else if(hostname == "stream.purser.it") {
|
||||
const provider = oldurl.searchParams.get("provider")
|
||||
if(provider) {
|
||||
if(provider == "youtube") {
|
||||
newurl = new URL("plugin://plugin.video.youtube")
|
||||
search.append("action", "play_video")
|
||||
let video_id = oldurl.searchParams.get("v")
|
||||
const video_id = oldurl.pathname.replace("/", "")
|
||||
if(video_id) {
|
||||
search.append("videoid", video_id)
|
||||
}
|
||||
} else {
|
||||
search.append("provider", providers.get(hostname))
|
||||
search.append("raw", "true")
|
||||
newurl.pathname = oldurl.pathname
|
||||
search.append("provider", provider)
|
||||
search.append("raw", "true")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
newurl.search = search.toString()
|
||||
newurl.search = search.toString()
|
||||
|
||||
let req = {
|
||||
jsonrpc: "2.0",
|
||||
method: "Player.Open",
|
||||
id: random(),
|
||||
params: {
|
||||
item: {
|
||||
file: newurl.href
|
||||
}
|
||||
const req = {
|
||||
jsonrpc: "2.0",
|
||||
method: method,
|
||||
id: random(),
|
||||
params: {
|
||||
item: {
|
||||
file: newurl.href
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
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)
|
||||
if(playlistid) {
|
||||
req.params.playlistid = playlistid
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
})
|
||||
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)
|
||||
})
|
||||
|
@ -50,6 +50,8 @@ fi
|
||||
release_folder="${temp_dir}/out/proxy-stream-${DRONE_TAG}"
|
||||
cp -r "${dir}/chrome" "${release_folder}"
|
||||
|
||||
(cd "${release_folder}" && zip -r "${temp_dir}/out/proxy-stream-${DRONE_TAG}.xpi" .)
|
||||
|
||||
if grep "/proc/1/cgroup" -q -F -e docker
|
||||
then
|
||||
${browser} --disable-gpu --no-sandbox --user-data-dir=${chrome_dir} --pack-extension="${temp_dir}/out/proxy-stream-${DRONE_TAG}" --pack-extension-key="${temp_dir}/privkey.pem"
|
Loading…
Reference in New Issue
Block a user