set to be only visible in home tab
This commit is contained in:
26
script.js
26
script.js
@ -1,10 +1,11 @@
|
||||
let title = 'Spotlight'; // Title of the slideshow
|
||||
let listFileName = 'list.txt'; // Name of the file containing the list of movie IDs
|
||||
let token = 'YOURAPIKEYHERE'; // Your Jellyfin API key
|
||||
let token = '34fb44ae6a23404895f243d3f089c1fc'; // Your Jellyfin API key
|
||||
let moviesSeriesBoth = 3; // 1 for movies, 2 for series, 3 for both
|
||||
let shuffleInterval = 15000; // Time in milliseconds before the next slide is shown, unless trailer is playing
|
||||
let useTrailers = true; // Set to false to disable trailers
|
||||
let setRandomMovie = true; // Set to false to disable random movie selection from the list
|
||||
let doNotShowOnOtherPages = false; // Set to true to show the slideshow on all pages eg. favorites, requests, etc.
|
||||
let showTitle = false; // Set to false to hide the title
|
||||
let plotMaxLength = 550; // Maximum number of characters in the plot
|
||||
|
||||
@ -422,6 +423,7 @@ const fetchNextMovie = () => {
|
||||
|
||||
const checkNavigation = () => {
|
||||
const newLocation = window.top.location.href;
|
||||
// Check if the user is navigating to or from the homepage
|
||||
if (newLocation !== currentLocation) {
|
||||
currentLocation = newLocation;
|
||||
const isHomePage = url => url.includes('/home') || url.endsWith('/web/') || url.endsWith('/web/index.html');
|
||||
@ -438,6 +440,28 @@ const checkNavigation = () => {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
// Check if parent is available and if the iframe is in an embedded environment
|
||||
if (!doNotShowOnOtherPages && window.parent && window.parent !== window) {
|
||||
const homeTab = window.parent.document.getElementById('homeTab');
|
||||
const isHomeTabActive = homeTab && homeTab.classList.contains('is-active');
|
||||
|
||||
// Check if the user is switching tabs while on the homepage to eg. favorites or requests, if so, stop the slideshow
|
||||
if (isHomeTabActive && !isHomePageActive) {
|
||||
console.log("HomeTab is active, reactivating slideshow");
|
||||
isHomePageActive = true;
|
||||
cleanup();
|
||||
window.parent.document.querySelector('.featurediframe').style.display = 'block';
|
||||
fetchRandomMovie();
|
||||
} else if (!isHomeTabActive && isHomePageActive) {
|
||||
console.log("Leaving HomeTab, cleaning up slideshow");
|
||||
isHomePageActive = false;
|
||||
cleanup();
|
||||
window.parent.document.querySelector('.featurediframe').style.display = 'none';
|
||||
}
|
||||
} else {
|
||||
console.error("Spotlight iframe is not in an embedded environment, has a different domain or doNotShowOnOtherPages is set to true");
|
||||
}
|
||||
};
|
||||
|
||||
setInterval(checkNavigation, 100);
|
||||
|
Reference in New Issue
Block a user