Feature/autoplay focus change #174
|
@ -44,6 +44,12 @@
|
||||||
<input type="checkbox" id="playerAutoplayAfterScreenshot" data-default-value="true" />
|
<input type="checkbox" id="playerAutoplayAfterScreenshot" data-default-value="true" />
|
||||||
<label for="playerAutoplayAfterScreenshot">Autoplay after screenshots</label><br />
|
<label for="playerAutoplayAfterScreenshot">Autoplay after screenshots</label><br />
|
||||||
|
|
||||||
|
<input type="checkbox" id="playerAutopauseAfterFocusLost" data-default-value="true" />
|
||||||
|
<label for="playerAutopauseAfterFocusLost">Autopause after tab unfocused</label><br />
|
||||||
|
|
||||||
|
<input type="checkbox" id="playerAutoplayAfterFocusGain" data-default-value="true" />
|
||||||
|
<label for="playerAutoplayAfterFocusGain">Autoplay after tab focused</label><br />
|
||||||
|
|
||||||
<h3>Watch2gether</h3>
|
<h3>Watch2gether</h3>
|
||||||
<input type="checkbox" id="w2gDisplayCharacterCounter" data-default-value="true" />
|
<input type="checkbox" id="w2gDisplayCharacterCounter" data-default-value="true" />
|
||||||
<label for="w2gDisplayCharacterCounter">Display character count in chat</label><br />
|
<label for="w2gDisplayCharacterCounter">Display character count in chat</label><br />
|
||||||
|
|
|
@ -14,6 +14,8 @@ export const SETTINGS_animeLanguageDisplay = 'animeLanguageDisplay';
|
||||||
export const SETTINGS_requestBeautifyPage = 'requestBeautifyPage';
|
export const SETTINGS_requestBeautifyPage = 'requestBeautifyPage';
|
||||||
// player
|
// player
|
||||||
export const SETTINGS_playerAutoplayAfterScreenshot = 'playerAutoplayAfterScreenshot';
|
export const SETTINGS_playerAutoplayAfterScreenshot = 'playerAutoplayAfterScreenshot';
|
||||||
|
export const SETTINGS_playerAutopauseAfterFocusLost = 'playerAutopauseAfterFocusLost';
|
||||||
|
export const SETTINGS_playerAutoplayAfterFocusGain = 'playerAutoplayAfterFocusGain';
|
||||||
// w2g
|
// w2g
|
||||||
export const SETTINGS_w2gDisplayCharacterCounter = 'w2gDisplayCharacterCounter';
|
export const SETTINGS_w2gDisplayCharacterCounter = 'w2gDisplayCharacterCounter';
|
||||||
class Configuration {
|
class Configuration {
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
import { getGlobalConfiguration, SETTINGS_playerAutoplayAfterScreenshot } from '../configuration/configuration';
|
import { getGlobalConfiguration,
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
SETTINGS_playerAutoplayAfterScreenshot,
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
SETTINGS_playerAutopauseAfterFocusLost,
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
SETTINGS_playerAutoplayAfterFocusGain } from '../configuration/configuration';
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
import * as core from '../utils/aniwatchCore';
|
import * as core from '../utils/aniwatchCore';
|
||||||
import * as helper from '../utils/helpers';
|
import * as helper from '../utils/helpers';
|
||||||
|
|
||||||
const SCREENSHOT_TOOLTIP_ID = 'anilyr-screenshots-tooltip';
|
const SCREENSHOT_TOOLTIP_ID = 'anilyr-screenshots-tooltip';
|
||||||
const PLAYER_ID = 'player';
|
const PLAYER_ID = 'player';
|
||||||
|
let resumePlayerOnVisible: boolean;
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
|
||||||
export function init(): void {
|
export function init(): void {
|
||||||
getGlobalConfiguration().getProperty(SETTINGS_playerAutoplayAfterScreenshot, value => {
|
getGlobalConfiguration().getProperty(SETTINGS_playerAutoplayAfterScreenshot, value => {
|
||||||
|
@ -16,6 +20,18 @@ export function init(): void {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
}, "^/anime/[0-9]*/[0-9]*$");
|
}, "^/anime/[0-9]*/[0-9]*$");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
getGlobalConfiguration().getProperty(SETTINGS_playerAutopauseAfterFocusLost, value => {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
if (value) {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
core.registerScript((node: Node) => {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
window.addEventListener('visibilitychange', observeTabFocus, false);
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
}, "^/anime/[0-9]*/[0-9]*$");
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
}
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
});
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
getGlobalConfiguration().getProperty(SETTINGS_playerAutoplayAfterFocusGain, value => {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
resumePlayerOnVisible = value;
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
});
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
}
|
}
|
||||||
|
|
||||||
function observeScreenshotTooltip(tooltip: HTMLElement): void {
|
function observeScreenshotTooltip(tooltip: HTMLElement): void {
|
||||||
|
@ -38,6 +54,21 @@ function observeScreenshotTooltip(tooltip: HTMLElement): void {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function observeTabFocus(): void {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
let docState = document.visibilityState;
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
let playerElement = findPlayerElement();
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
if (docState === 'hidden') {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
if (helper.assigned(playerElement)) {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
pausePlayer(playerElement);
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
}
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
}
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
else if (docState === 'visible' && resumePlayerOnVisible) {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
if (helper.assigned(playerElement)) {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
resumePlayer(playerElement);
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
}
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
}
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
}
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
function findPlayerElement(): HTMLVideoElement {
|
function findPlayerElement(): HTMLVideoElement {
|
||||||
let playerCandidate = document.getElementById(PLAYER_ID);
|
let playerCandidate = document.getElementById(PLAYER_ID);
|
||||||
if (playerCandidate instanceof HTMLVideoElement) {
|
if (playerCandidate instanceof HTMLVideoElement) {
|
||||||
|
@ -49,4 +80,8 @@ function findPlayerElement(): HTMLVideoElement {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
|
||||||
function resumePlayer(player: HTMLVideoElement) {
|
function resumePlayer(player: HTMLVideoElement) {
|
||||||
player.play();
|
player.play();
|
||||||
|
}
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
function pausePlayer(player: HTMLVideoElement) {
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
|
player.pause()
|
||||||
Maybe would rename it to indicate it's a Boolean.
Maybe would rename it to indicate it's a Boolean. `onSomething` mostly is used for events or listeners.
```suggestion
let restartPlayerOnVisible: boolean;
```
I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better. I agree, instead of 'restart' I used 'resume' since it fits the overall functionality better.
|
|||||||
}
|
}
|
Maybe would rename it to indicate it's a Boolean.
onSomething
mostly is used for events or listeners.