apply 10.8 css changes
- No use optimizing conditionally - Add animation on skipButton entry and exit
This commit is contained in:
parent
a98b9c7a37
commit
196dd4c30c
@ -6,66 +6,78 @@ let introSkipper = {
|
|||||||
};
|
};
|
||||||
introSkipper.d = function (msg) {
|
introSkipper.d = function (msg) {
|
||||||
console.debug("[intro skipper] ", msg);
|
console.debug("[intro skipper] ", msg);
|
||||||
}
|
}
|
||||||
/** Setup event listeners */
|
/** Setup event listeners */
|
||||||
introSkipper.setup = function () {
|
introSkipper.setup = function () {
|
||||||
document.addEventListener("viewshow", introSkipper.viewShow);
|
document.addEventListener("viewshow", introSkipper.viewShow);
|
||||||
window.fetch = introSkipper.fetchWrapper;
|
window.fetch = introSkipper.fetchWrapper;
|
||||||
introSkipper.d("Registered hooks");
|
introSkipper.d("Registered hooks");
|
||||||
}
|
}
|
||||||
/** Wrapper around fetch() that retrieves skip segments for the currently playing item. */
|
/** Wrapper around fetch() that retrieves skip segments for the currently playing item. */
|
||||||
introSkipper.fetchWrapper = async function (...args) {
|
introSkipper.fetchWrapper = async function (...args) {
|
||||||
// Based on JellyScrub's trickplay.js
|
// Based on JellyScrub's trickplay.js
|
||||||
let [resource, options] = args;
|
let [resource, options] = args;
|
||||||
let response = await introSkipper.originalFetch(resource, options);
|
let response = await introSkipper.originalFetch(resource, options);
|
||||||
// Bail early if this isn't a playback info URL
|
// Bail early if this isn't a playback info URL
|
||||||
try {
|
try {
|
||||||
let path = new URL(resource).pathname;
|
let path = new URL(resource).pathname;
|
||||||
if (!path.includes("/PlaybackInfo")) { return response; }
|
if (!path.includes("/PlaybackInfo")) { return response; }
|
||||||
introSkipper.d("Retrieving skip segments from URL");
|
introSkipper.d("Retrieving skip segments from URL");
|
||||||
introSkipper.d(path);
|
introSkipper.d(path);
|
||||||
let id = path.split("/")[2];
|
let id = path.split("/")[2];
|
||||||
introSkipper.skipSegments = await introSkipper.secureFetch(`Episode/${id}/IntroSkipperSegments`);
|
introSkipper.skipSegments = await introSkipper.secureFetch(`Episode/${id}/IntroSkipperSegments`);
|
||||||
introSkipper.d("Successfully retrieved skip segments");
|
introSkipper.d("Successfully retrieved skip segments");
|
||||||
introSkipper.d(introSkipper.skipSegments);
|
introSkipper.d(introSkipper.skipSegments);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error("Unable to get skip segments from", resource, e);
|
console.error("Unable to get skip segments from", resource, e);
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Event handler that runs whenever the current view changes.
|
* Event handler that runs whenever the current view changes.
|
||||||
* Used to detect the start of video playback.
|
* Used to detect the start of video playback.
|
||||||
*/
|
*/
|
||||||
introSkipper.viewShow = function () {
|
introSkipper.viewShow = function () {
|
||||||
const location = window.location.hash;
|
const location = window.location.hash;
|
||||||
introSkipper.d("Location changed to " + location);
|
introSkipper.d("Location changed to " + location);
|
||||||
if (location !== "#/video") {
|
if (location !== "#!/video") {
|
||||||
introSkipper.d("Ignoring location change");
|
introSkipper.d("Ignoring location change");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
introSkipper.injectCss();
|
introSkipper.injectCss();
|
||||||
introSkipper.injectButton();
|
introSkipper.injectButton();
|
||||||
introSkipper.videoPlayer = document.querySelector("video");
|
introSkipper.videoPlayer = document.querySelector("video");
|
||||||
if (introSkipper.videoPlayer != null) {
|
if (introSkipper.videoPlayer != null) {
|
||||||
introSkipper.d("Hooking video timeupdate");
|
introSkipper.d("Hooking video timeupdate");
|
||||||
introSkipper.videoPlayer.addEventListener("timeupdate", introSkipper.videoPositionChanged);
|
introSkipper.videoPlayer.addEventListener("timeupdate", introSkipper.videoPositionChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Injects the CSS used by the skip intro button.
|
* Injects the CSS used by the skip intro button.
|
||||||
* Calling this function is a no-op if the CSS has already been injected.
|
* Calling this function is a no-op if the CSS has already been injected.
|
||||||
*/
|
*/
|
||||||
introSkipper.injectCss = function () {
|
introSkipper.injectCss = function () {
|
||||||
if (introSkipper.testElement("style#introSkipperCss")) {
|
if (introSkipper.testElement("style#introSkipperCss")) {
|
||||||
introSkipper.d("CSS already added");
|
introSkipper.d("CSS already added");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
introSkipper.d("Adding CSS");
|
introSkipper.d("Adding CSS");
|
||||||
let styleElement = document.createElement("style");
|
let styleElement = document.createElement("style");
|
||||||
styleElement.id = "introSkipperCss";
|
styleElement.id = "introSkipperCss";
|
||||||
styleElement.innerText = `
|
styleElement.innerText = `
|
||||||
|
@media (hover:hover) and (pointer:fine) {
|
||||||
|
#skipIntro .paper-icon-button-light:hover:not(:disabled) {
|
||||||
|
color: black !important;
|
||||||
|
background-color: rgba(47, 93, 98, 0) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#skipIntro .paper-icon-button-light.show-focus:focus {
|
||||||
|
transform: scale(1.04) !important;
|
||||||
|
}
|
||||||
|
#skipIntro.upNextContainer {
|
||||||
|
width: unset;
|
||||||
|
}
|
||||||
#skipIntro {
|
#skipIntro {
|
||||||
padding: 0 1px;
|
padding: 0 1px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -81,31 +93,21 @@ introSkipper.injectCss = function () {
|
|||||||
-webkit-transition: ease-out 0.4s;
|
-webkit-transition: ease-out 0.4s;
|
||||||
-moz-transition: ease-out 0.4s;
|
-moz-transition: ease-out 0.4s;
|
||||||
transition: ease-out 0.4s;
|
transition: ease-out 0.4s;
|
||||||
@media (max-width: 1080px) {
|
}
|
||||||
|
#skipIntro #btnSkipSegmentText {
|
||||||
|
padding-right: 3px;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
}
|
||||||
|
@media (max-width: 1080px) {
|
||||||
|
#skipIntro {
|
||||||
right: 10%;
|
right: 10%;
|
||||||
}
|
}
|
||||||
&:hover {
|
}
|
||||||
box-shadow: inset 400px 0 0 0 #f9f9f9;
|
#skipIntro:hover {
|
||||||
-webkit-transition: ease-in 1s;
|
box-shadow: inset 400px 0 0 0 #f9f9f9;
|
||||||
-moz-transition: ease-in 1s;
|
-webkit-transition: ease-in 1s;
|
||||||
transition: ease-in 1s;
|
-moz-transition: ease-in 1s;
|
||||||
}
|
transition: ease-in 1s;
|
||||||
&.upNextContainer {
|
|
||||||
width: unset;
|
|
||||||
}
|
|
||||||
@media (hover:hover) and (pointer:fine) {
|
|
||||||
.paper-icon-button-light:hover:not(:disabled) {
|
|
||||||
color: black !important;
|
|
||||||
background-color: rgba(47, 93, 98, 0) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.paper-icon-button-light.show-focus:focus {
|
|
||||||
transform: scale(1.04) !important;
|
|
||||||
}
|
|
||||||
#btnSkipSegmentText {
|
|
||||||
padding-right: 3px;
|
|
||||||
padding-bottom: 2px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
document.querySelector("head").appendChild(styleElement);
|
document.querySelector("head").appendChild(styleElement);
|
||||||
@ -224,4 +226,4 @@ introSkipper.secureFetch = async function (url) {
|
|||||||
if (res.status !== 200) { throw new Error(`Expected status 200 from ${url}, but got ${res.status}`); }
|
if (res.status !== 200) { throw new Error(`Expected status 200 from ${url}, but got ${res.status}`); }
|
||||||
return await res.json();
|
return await res.json();
|
||||||
}
|
}
|
||||||
introSkipper.setup();
|
introSkipper.setup();
|
Loading…
x
Reference in New Issue
Block a user