let bindEvent = async () => {
let buttons = [];
let retry = 6 + 1;
while (buttons.length == 0 && retry > 0) {
await new Promise(resolve => setTimeout(resolve, 500));
buttons = document.querySelectorAll('[data-mode=play],[data-mode=resume],[data-action=resume]');
retry -= 1;
}
for (let button of buttons) {
let nextElementSibling = button.nextElementSibling;
let parentElement = button.parentElement;
let outerHTML = button.outerHTML;
button.parentElement.removeChild(button);
let newButton = document.createElement('button');
if (nextElementSibling) {
parentElement.insertBefore(newButton, nextElementSibling);
} else {
parentElement.append(newButton);
}
newButton.outerHTML = outerHTML;
}
buttons = document.querySelectorAll('[data-mode=play],[data-mode=resume]');
for (let button of buttons) {
button.removeAttribute('data-mode');
button.addEventListener('click', e => {
e.stopPropagation();
let itemid = /id=(.*?)&serverId/.exec(window.location.hash)[1];
openPotplayer(itemid);
});
}
buttons = document.querySelectorAll('[data-action=resume]');
for (let button of buttons) {
button.removeAttribute('data-action');
button.addEventListener('click', e => {
e.stopPropagation();
let item = e.target;
while (!item.hasAttribute('data-id')) { item = item.parentNode }
let itemid = item.getAttribute('data-id');
openPotplayer(itemid);
});
}
};
let lazyload = () => {
let items = document.querySelectorAll('[data-src].lazy');
let y = document.scrollingElement.scrollTop;
let intersectinglist = [];
for (let item of items) {
let windowHeight = document.body.offsetHeight;
let itemTop = item.getBoundingClientRect().top;
let itemHeight = item.offsetHeight;
if (itemTop + itemHeight >= 0 && itemTop <= windowHeight) {
intersectinglist.push(item);
}
}
for (let item of intersectinglist) {
item.style.setProperty('background-image', url("${item.getAttribute('data-src')}"));
item.classList.remove('lazy');
item.removeAttribute('data-src');
};
};
Jellyfin 23 Apr download latest Firefox on Windows 10.
Same file errors on the JS file as others have previously reported
Please help..... What am I doing wrong?
Doc included below
##########################################################
I am adapting it to run mpv. I can launch the powershell script and it opens mpv properly.
registry entry is correct
potplayer.reg
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\potplayer] @="URL:potplayer protocol" "URL Protocol"="" [HKEY_CLASSES_ROOT\potplayer\shell] [HKEY_CLASSES_ROOT\potplayer\shell\open] [HKEY_CLASSES_ROOT\potplayer\shell\open\command] @="powershell -File D:\apps\Jellyfin-mpv-master\potplayer.ps1 %1"
potplayer.ps1
Add-Type -Assembly System.Web $path=$args[0] $path=$path -replace "potplayer://" , "" $path= [System.Web.HttpUtility]::UrlDecode($path) echo $path & "D:\Apps\mpv_default\mpv.exe" $path
userscript.js
// ==UserScript== // @name Jellyfin with Potplayer // @version 0.1 // @description play video with Potplayer // @author Tccoin // @match http://DLNAWebserver:8096/jellyfin/web/index.html // ==/UserScript==
(function() { 'use strict'; let openPotplayer = async (itemid) => { let userid = (await ApiClient.getCurrentUser()).Id; ApiClient.getItem(userid, itemid).then(r => { if (r.Path) { let path = r.Path.replace(/\/g, '/'); path = path.replace('E:', 'Q:'); console.log(path); window.open('potplayer://' + path) } else { ApiClient.getItems(userid, itemid).then(r => openPotplayer(r.Items[0].Id)); } }) };
let bindEvent = async () => { let buttons = []; let retry = 6 + 1; while (buttons.length == 0 && retry > 0) { await new Promise(resolve => setTimeout(resolve, 500)); buttons = document.querySelectorAll('[data-mode=play],[data-mode=resume],[data-action=resume]'); retry -= 1; } for (let button of buttons) { let nextElementSibling = button.nextElementSibling; let parentElement = button.parentElement; let outerHTML = button.outerHTML; button.parentElement.removeChild(button); let newButton = document.createElement('button'); if (nextElementSibling) { parentElement.insertBefore(newButton, nextElementSibling); } else { parentElement.append(newButton); } newButton.outerHTML = outerHTML; } buttons = document.querySelectorAll('[data-mode=play],[data-mode=resume]'); for (let button of buttons) { button.removeAttribute('data-mode'); button.addEventListener('click', e => { e.stopPropagation(); let itemid = /id=(.*?)&serverId/.exec(window.location.hash)[1]; openPotplayer(itemid); }); } buttons = document.querySelectorAll('[data-action=resume]'); for (let button of buttons) { button.removeAttribute('data-action'); button.addEventListener('click', e => { e.stopPropagation(); let item = e.target; while (!item.hasAttribute('data-id')) { item = item.parentNode } let itemid = item.getAttribute('data-id'); openPotplayer(itemid); }); } };
let lazyload = () => { let items = document.querySelectorAll('[data-src].lazy'); let y = document.scrollingElement.scrollTop; let intersectinglist = []; for (let item of items) { let windowHeight = document.body.offsetHeight; let itemTop = item.getBoundingClientRect().top; let itemHeight = item.offsetHeight; if (itemTop + itemHeight >= 0 && itemTop <= windowHeight) { intersectinglist.push(item); } } for (let item of intersectinglist) { item.style.setProperty('background-image',
url("${item.getAttribute('data-src')}")
); item.classList.remove('lazy'); item.removeAttribute('data-src'); }; };window.addEventListener('scroll', lazyload);
window.addEventListener('viewshow', async() => { bindEvent(); window.addEventListener('hashchange', bindEvent); }); })();