forked from mirrors/gecko-dev
Bug 1812719 - Disable PiP scrubber and timestamp for live videos on Twitch. r=pip-reviewers,kpatenio
Differential Revision: https://phabricator.services.mozilla.com/D168846
This commit is contained in:
parent
e917b98b54
commit
a021a3adbb
4 changed files with 46 additions and 5 deletions
|
|
@ -12,6 +12,7 @@ let AVAILABLE_PIP_OVERRIDES;
|
|||
// See PictureInPictureControls.sys.mjs for these values.
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const TOGGLE_POLICIES = browser.pictureInPictureChild.getPolicies();
|
||||
const KEYBOARD_CONTROLS = browser.pictureInPictureChild.getKeyboardControls();
|
||||
|
||||
AVAILABLE_PIP_OVERRIDES = {
|
||||
// The keys of this object are match patterns for URLs, as documented in
|
||||
|
|
@ -178,9 +179,21 @@ let AVAILABLE_PIP_OVERRIDES;
|
|||
},
|
||||
|
||||
twitch: {
|
||||
"https://*.twitch.tv/*": { policy: TOGGLE_POLICIES.ONE_QUARTER },
|
||||
"https://*.twitch.tech/*": { policy: TOGGLE_POLICIES.ONE_QUARTER },
|
||||
"https://*.twitch.a2z.com/*": { policy: TOGGLE_POLICIES.ONE_QUARTER },
|
||||
"https://*.twitch.tv/*": {
|
||||
videoWrapperScriptPath: "video-wrappers/twitch.js",
|
||||
policy: TOGGLE_POLICIES.ONE_QUARTER,
|
||||
disabledKeyboardControls: KEYBOARD_CONTROLS.LIVE_SEEK,
|
||||
},
|
||||
"https://*.twitch.tech/*": {
|
||||
videoWrapperScriptPath: "video-wrappers/twitch.js",
|
||||
policy: TOGGLE_POLICIES.ONE_QUARTER,
|
||||
disabledKeyboardControls: KEYBOARD_CONTROLS.LIVE_SEEK,
|
||||
},
|
||||
"https://*.twitch.a2z.com/*": {
|
||||
videoWrapperScriptPath: "video-wrappers/twitch.js",
|
||||
policy: TOGGLE_POLICIES.ONE_QUARTER,
|
||||
disabledKeyboardControls: KEYBOARD_CONTROLS.LIVE_SEEK,
|
||||
},
|
||||
},
|
||||
|
||||
udemy: {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ FINAL_TARGET_FILES.features["pictureinpicture@mozilla.org"]["video-wrappers"] +=
|
|||
"video-wrappers/piped.js",
|
||||
"video-wrappers/primeVideo.js",
|
||||
"video-wrappers/tubi.js",
|
||||
"video-wrappers/twitch.js",
|
||||
"video-wrappers/videojsWrapper.js",
|
||||
"video-wrappers/voot.js",
|
||||
"video-wrappers/washingtonpost.js",
|
||||
|
|
|
|||
19
browser/extensions/pictureinpicture/video-wrappers/twitch.js
Normal file
19
browser/extensions/pictureinpicture/video-wrappers/twitch.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
class PictureInPictureVideoWrapper {
|
||||
isLive(video) {
|
||||
return !document.querySelector(".seekbar-bar");
|
||||
}
|
||||
getDuration(video) {
|
||||
if (this.isLive(video)) {
|
||||
return Infinity;
|
||||
}
|
||||
return video.duration;
|
||||
}
|
||||
}
|
||||
|
||||
this.PictureInPictureVideoWrapper = PictureInPictureVideoWrapper;
|
||||
|
|
@ -2299,7 +2299,11 @@ export class PictureInPictureChild extends JSWindowActorChild {
|
|||
break;
|
||||
case "leftArrow": /* Seek back 5 seconds */
|
||||
case "accel-leftArrow" /* Seek back 10% */:
|
||||
if (this.isKeyDisabled(lazy.KEYBOARD_CONTROLS.SEEK)) {
|
||||
if (
|
||||
this.isKeyDisabled(lazy.KEYBOARD_CONTROLS.SEEK) ||
|
||||
(isVideoStreaming &&
|
||||
this.isKeyDisabled(lazy.KEYBOARD_CONTROLS.LIVE_SEEK))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2313,7 +2317,11 @@ export class PictureInPictureChild extends JSWindowActorChild {
|
|||
break;
|
||||
case "rightArrow": /* Seek forward 5 seconds */
|
||||
case "accel-rightArrow" /* Seek forward 10% */:
|
||||
if (this.isKeyDisabled(lazy.KEYBOARD_CONTROLS.SEEK)) {
|
||||
if (
|
||||
this.isKeyDisabled(lazy.KEYBOARD_CONTROLS.SEEK) ||
|
||||
(isVideoStreaming &&
|
||||
this.isKeyDisabled(lazy.KEYBOARD_CONTROLS.LIVE_SEEK))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue