Compare commits
No commits in common. "master" and "v104" have entirely different histories.
@ -1,13 +1,13 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: default
|
name: default
|
||||||
steps:
|
steps:
|
||||||
- name: compile-extensions
|
- name: compile-chrome
|
||||||
image: roypur/extension-packer:latest
|
image: roypur/chrome-packer:latest
|
||||||
environment:
|
environment:
|
||||||
CHROME_PRIVKEY:
|
CHROME_PRIVKEY:
|
||||||
from_secret: chrome_privkey
|
from_secret: chrome_privkey
|
||||||
commands:
|
commands:
|
||||||
- ./pack-browsers.sh
|
- ./pack-chrome.sh
|
||||||
- name: gitea_release
|
- name: gitea_release
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
settings:
|
settings:
|
||||||
@ -15,6 +15,6 @@ steps:
|
|||||||
from_secret: gitea_token
|
from_secret: gitea_token
|
||||||
base_url: https://git.purser.it
|
base_url: https://git.purser.it
|
||||||
title: ${DRONE_TAG}
|
title: ${DRONE_TAG}
|
||||||
files: out/proxy-stream-${DRONE_TAG}.crx out/proxy-stream-${DRONE_TAG}.xpi
|
files: out/proxy-stream-${DRONE_TAG}.crx
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,5 +11,4 @@ android/.gradle/*
|
|||||||
android/gradle/*
|
android/gradle/*
|
||||||
chrome/*.png
|
chrome/*.png
|
||||||
*.crx
|
*.crx
|
||||||
*.xpi
|
|
||||||
sources.json
|
sources.json
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
"48": "icon-48.png",
|
"48": "icon-48.png",
|
||||||
"128": "icon-128.png"
|
"128": "icon-128.png"
|
||||||
},
|
},
|
||||||
"version": "111.0",
|
"version": "104.0",
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"host_permissions": ["http://127.0.0.1:4000/jsonrpc"],
|
"host_permissions": ["http://127.0.0.1:8083/jsonrpc", "http://127.0.0.1:8080/jsonrpc"],
|
||||||
"permissions": ["tabs"],
|
"permissions": ["tabs"],
|
||||||
"action": {
|
"action": {
|
||||||
"default_title": "Proxy Stream",
|
"default_title": "Proxy Stream",
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
<title>Proxy Stream</title>
|
<title>Proxy Stream</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button id="proxy-button">Proxy Stream</button>
|
<button>Proxy Stream</button>
|
||||||
<button id="kodi-play-button">Play on kodi</button>
|
<button>Play on kodi</button>
|
||||||
<button id="kodi-queue-button">Queue on kodi</button>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
147
chrome/script.js
147
chrome/script.js
@ -1,122 +1,83 @@
|
|||||||
let providers = new Map()
|
let providers = new Map();
|
||||||
providers.set("www.youtube.com", "youtube")
|
providers.set("www.youtube.com", "youtube");
|
||||||
providers.set("youtube.com", "youtube")
|
providers.set("youtube.com", "youtube");
|
||||||
providers.set("youtu.be", "youtube")
|
providers.set("youtu.be", "youtube");
|
||||||
providers.set("tv.nrk.no", "nrk")
|
providers.set("tv.nrk.no", "nrk");
|
||||||
providers.set("seafile.purser.it", "seafile")
|
providers.set("seafile.purser.it", "seafile");
|
||||||
|
|
||||||
const random = () => {
|
|
||||||
const arr = new Uint8Array(32)
|
|
||||||
window.crypto.getRandomValues(arr)
|
|
||||||
return [...arr].map(x => x.toString(16).padStart(2, "0")).join("")
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
const proxyButton = document.getElementById("proxy-button")
|
let [proxyButton, kodiButton] = document.getElementsByTagName("button");
|
||||||
const kodiPlayButton = document.getElementById("kodi-play-button")
|
proxyButton.addEventListener("click", (ev) => {
|
||||||
const kodiQueueButton = document.getElementById("kodi-queue-button")
|
chrome.tabs.query({currentWindow: true, active: true}, (tabs) => {
|
||||||
|
let oldurl = new URL(tabs[0].url);
|
||||||
async function handleProxyButton(ev) {
|
let newurl = new URL("https://stream.purser.it");
|
||||||
const [tab] = chrome.tabs.query({currentWindow: true, active: true})
|
let search = new URLSearchParams();
|
||||||
const oldurl = new URL(tab.url)
|
let hostname = oldurl.hostname.toLowerCase();
|
||||||
const search = new URLSearchParams()
|
|
||||||
const hostname = oldurl.hostname.toLowerCase()
|
|
||||||
let newurl = new URL("https://stream.purser.it")
|
|
||||||
|
|
||||||
if(providers.has(hostname)) {
|
if(providers.has(hostname)) {
|
||||||
if(hostname.includes("youtube.com")) {
|
if(hostname.includes("youtube.com")) {
|
||||||
let newpath = oldurl.searchParams.get("v")
|
let newpath = oldurl.searchParams.get("v");
|
||||||
if(newpath) {
|
if((newpath instanceof String) || ((typeof newpath) === "string")) {
|
||||||
newurl.pathname = "/" + newpath
|
newurl.pathname = "/" + newpath;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newurl.pathname = oldurl.pathname
|
newurl.pathname = oldurl.pathname;
|
||||||
}
|
}
|
||||||
search.append("provider", providers.get(hostname))
|
search.append("provider", providers.get(hostname));
|
||||||
} else {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
newurl.search = search.toString();
|
||||||
newurl.search = search.toString()
|
let tab = {};
|
||||||
const newtab = {}
|
tab.url = newurl.href;
|
||||||
newtab.url = newurl.href
|
chrome.tabs.create(tab);
|
||||||
chrome.tabs.create(newtab)
|
});
|
||||||
}
|
});
|
||||||
|
kodiButton.addEventListener("click", (ev) => {
|
||||||
async function handleKodiButton(ev, method, playlistid) {
|
chrome.tabs.query({currentWindow: true, active: true}, (tabs) => {
|
||||||
const [tab] = await chrome.tabs.query({currentWindow: true, active: true})
|
let oldurl = new URL(tabs[0].url);
|
||||||
const oldurl = new URL(tab.url)
|
let newurl = new URL(tabs[0].url);
|
||||||
const search = new URLSearchParams()
|
let search = new URLSearchParams();
|
||||||
const hostname = oldurl.hostname.toLowerCase()
|
let hostname = oldurl.hostname.toLowerCase();
|
||||||
let newurl = new URL("https://stream.purser.it")
|
|
||||||
|
|
||||||
if(providers.has(hostname)) {
|
|
||||||
if(hostname.includes("youtube.com")) {
|
if(hostname.includes("youtube.com")) {
|
||||||
newurl = new URL("plugin://plugin.video.youtube")
|
newurl = new URL("plugin://plugin.video.youtube")
|
||||||
search.append("action", "play_video")
|
search.append("action", "play_video")
|
||||||
const video_id = oldurl.searchParams.get("v")
|
let video_id = oldurl.searchParams.get("v");
|
||||||
if(video_id) {
|
if(video_id) {
|
||||||
search.append("videoid", 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")
|
|
||||||
const video_id = oldurl.pathname.replace("/", "")
|
|
||||||
if(video_id) {
|
|
||||||
search.append("videoid", video_id)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newurl.pathname = oldurl.pathname
|
|
||||||
search.append("provider", provider)
|
|
||||||
search.append("raw", "true")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
newurl.search = search.toString();
|
||||||
|
|
||||||
newurl.search = search.toString()
|
let req = {
|
||||||
|
|
||||||
const req = {
|
|
||||||
jsonrpc: "2.0",
|
jsonrpc: "2.0",
|
||||||
method: method,
|
method: "Player.Open",
|
||||||
id: random(),
|
id: 12345,
|
||||||
params: {
|
params: {
|
||||||
item: {
|
item: {
|
||||||
file: newurl.href
|
file: newurl.href
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
if(playlistid) {
|
fetch("http://127.0.0.1:8080/jsonrpc", {
|
||||||
req.params.playlistid = playlistid
|
|
||||||
}
|
|
||||||
|
|
||||||
const resp = await fetch("http://127.0.0.1:4000/jsonrpc", {
|
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(req),
|
body: JSON.stringify(req),
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json; charset=utf-8"
|
"Content-Type": "application/json; charset=utf-8"
|
||||||
}
|
}
|
||||||
})
|
}).then(resp => console.log(resp))
|
||||||
console.log(resp)
|
} catch(e) {
|
||||||
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
kodiPlayButton.addEventListener("click", async ev => {
|
fetch("http://127.0.0.1:8083/jsonrpc", {
|
||||||
await handleKodiButton(ev, "Player.Open")
|
method: "POST",
|
||||||
})
|
body: JSON.stringify(req),
|
||||||
|
headers: {
|
||||||
kodiQueueButton.addEventListener("click", async ev => {
|
"Content-Type": "application/json; charset=utf-8"
|
||||||
await handleKodiButton(ev, "Playlist.Add", 1)
|
}
|
||||||
})
|
}).then(resp => console.log(resp))
|
||||||
|
} catch(e) {
|
||||||
proxyButton.addEventListener("click", handleProxyButton)
|
console.log(e)
|
||||||
})
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -4,14 +4,6 @@ temp_name=$(head -c 20 /dev/random | xxd -p | tr -dc a-f0-9)
|
|||||||
temp_dir="/tmp/${temp_name}"
|
temp_dir="/tmp/${temp_name}"
|
||||||
chrome_dir="${temp_dir}/chrome"
|
chrome_dir="${temp_dir}/chrome"
|
||||||
|
|
||||||
if [[ ! -n "${DRONE_TAG}" ]]
|
|
||||||
then
|
|
||||||
export DRONE_TAG=$(git describe --abbrev=0 | tr -dc v0-9)
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "${dir}/out"
|
|
||||||
rm -rf "${dir}/out"
|
|
||||||
|
|
||||||
mkdir -p "${temp_dir}/out"
|
mkdir -p "${temp_dir}/out"
|
||||||
mkdir -p "${chrome_dir}"
|
mkdir -p "${chrome_dir}"
|
||||||
|
|
||||||
@ -30,15 +22,12 @@ then
|
|||||||
dbus-daemon --session --address="${DBUS_SESSION_BUS_ADDRESS}" &
|
dbus-daemon --session --address="${DBUS_SESSION_BUS_ADDRESS}" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -n "${DISPLAY}" ]]
|
if [[ "${DISPLAY}test" == "test" ]]
|
||||||
then
|
then
|
||||||
export DISPLAY=:8819
|
export DISPLAY=:8819
|
||||||
Xvfb "${DISPLAY}" &
|
Xvfb "${DISPLAY}" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "DRONE_TAG=${DRONE_TAG}"
|
|
||||||
echo "DISPLAY=${DISPLAY}"
|
|
||||||
|
|
||||||
${dir}/icons.sh
|
${dir}/icons.sh
|
||||||
|
|
||||||
browser=$(which chromium-browser 2> /dev/null)
|
browser=$(which chromium-browser 2> /dev/null)
|
||||||
@ -50,14 +39,7 @@ fi
|
|||||||
release_folder="${temp_dir}/out/proxy-stream-${DRONE_TAG}"
|
release_folder="${temp_dir}/out/proxy-stream-${DRONE_TAG}"
|
||||||
cp -r "${dir}/chrome" "${release_folder}"
|
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"
|
${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"
|
||||||
else
|
|
||||||
${browser} --user-data-dir=${chrome_dir} --pack-extension="${temp_dir}/out/proxy-stream-${DRONE_TAG}" --pack-extension-key="${temp_dir}/privkey.pem"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -rf "${release_folder}"
|
rm -rf "${release_folder}"
|
||||||
mv "${temp_dir}/out" "${dir}/out"
|
mv "${temp_dir}/out" "${dir}/out"
|
Loading…
Reference in New Issue
Block a user