diff --git a/src/html/settings.html b/src/html/settings.html
index 41437e5..cec24c1 100644
--- a/src/html/settings.html
+++ b/src/html/settings.html
@@ -54,6 +54,9 @@
+
+
+
diff --git a/src/javascript/app.ts b/src/javascript/app.ts
index 0e714aa..0725fe3 100644
--- a/src/javascript/app.ts
+++ b/src/javascript/app.ts
@@ -10,7 +10,7 @@ import { init as languageDisplay } from './enhancements/languageDisplay';
import { init as notifications } from './enhancements/notifications';
import { init as quickSearch } from './enhancements/quickSearch';
import { init as timeConversion } from './enhancements/timeConversion';
-import { init as watch2getherChat } from './enhancements/watch2getherChat';
+import { init as watch2gether } from './enhancements/watch2gether';
// css
import { init as cssEnhancements } from './enhancements/cssEnhancements';
@@ -28,7 +28,7 @@ languageDisplay();
notifications();
quickSearch();
timeConversion();
-watch2getherChat();
+watch2gether();
// css
cssEnhancements();
\ No newline at end of file
diff --git a/src/javascript/configuration/configuration.ts b/src/javascript/configuration/configuration.ts
index 3736e35..c95749b 100644
--- a/src/javascript/configuration/configuration.ts
+++ b/src/javascript/configuration/configuration.ts
@@ -18,6 +18,7 @@ export const SETTINGS_playerAutopauseAfterFocusLost = 'playerAutopauseAfterFocus
export const SETTINGS_playerAutoplayAfterFocusGain = 'playerAutoplayAfterFocusGain';
// w2g
export const SETTINGS_w2gDisplayCharacterCounter = 'w2gDisplayCharacterCounter';
+export const SETTINGS_w2gAutotoggleHide = 'w2gAutotoggleHide';
class Configuration {
settingsCache: Map;
diff --git a/src/javascript/enhancements/anilyr.ts b/src/javascript/enhancements/anilyr.ts
index 82a9c98..dd6bbd6 100644
--- a/src/javascript/enhancements/anilyr.ts
+++ b/src/javascript/enhancements/anilyr.ts
@@ -39,7 +39,7 @@ function observeScreenshotTooltip(tooltip: HTMLElement): void {
mutations.forEach(mutation => {
// Switched to invisible
if (!mutation.oldValue.includes('display: none') && helper.isHtmlElement(mutation.target) && (mutation.target as HTMLElement).style.display == 'none') {
- let playerElement = findPlayerElement();
+ let playerElement = findPlayerElement(PLAYER_ID);
if (helper.assigned(playerElement)) {
resumePlayer(playerElement);
}
@@ -54,9 +54,10 @@ function observeScreenshotTooltip(tooltip: HTMLElement): void {
});
}
+
function observeTabFocus(): void {
let docState = document.visibilityState;
- let playerElement = findPlayerElement();
+ let playerElement = findPlayerElement(PLAYER_ID);
if (docState === 'hidden') {
if (helper.assigned(playerElement)) {
pausePlayer(playerElement);
@@ -69,8 +70,8 @@ function observeTabFocus(): void {
}
}
-function findPlayerElement(): HTMLVideoElement {
- let playerCandidate = document.getElementById(PLAYER_ID);
+export function findPlayerElement(id: string): HTMLVideoElement {
+ let playerCandidate = document.getElementById(id);
if (playerCandidate instanceof HTMLVideoElement) {
return playerCandidate;
}
diff --git a/src/javascript/enhancements/watch2getherChat.ts b/src/javascript/enhancements/watch2gether.ts
similarity index 59%
rename from src/javascript/enhancements/watch2getherChat.ts
rename to src/javascript/enhancements/watch2gether.ts
index 8ca0526..b4e9590 100644
--- a/src/javascript/enhancements/watch2getherChat.ts
+++ b/src/javascript/enhancements/watch2gether.ts
@@ -1,16 +1,33 @@
import * as core from '../utils/aniwatchCore';
import { v4 as uuidv4 } from 'uuid';
-import { getGlobalConfiguration, SETTINGS_w2gDisplayCharacterCounter } from '../configuration/configuration';
+import { getGlobalConfiguration, SETTINGS_w2gDisplayCharacterCounter, SETTINGS_w2gAutotoggleHide } from '../configuration/configuration';
import { assigned } from '../utils/helpers';
+import { findPlayerElement } from "../enhancements/anilyr";
+
+const PLAYER_ID = 'wPlayer';
+let hidden: boolean;
export function init(): void {
getGlobalConfiguration().getProperty(SETTINGS_w2gDisplayCharacterCounter, value => {
if (value) {
+ core.runAfterLoad(() => {
+ manipulateChatInput();
+ }, "^/watch2gether/.*$");
core.runAfterLocationChange(() => {
manipulateChatInput();
}, "^/watch2gether/.*$");
}
});
+ getGlobalConfiguration().getProperty(SETTINGS_w2gAutotoggleHide, value => {
+ if (value) {
+ core.runAfterLoad(() => {
+ addAutohideListener();
+ }, "^/watch2gether/.*$");
+ core.runAfterLocationChange(() => {
+ addAutohideListener();
+ }, "^/watch2gether/.*$");
+ }
+ });
}
function manipulateChatInput(): void {
@@ -62,4 +79,28 @@ function updateCharCounter(textarea: HTMLTextAreaElement, charCounterSpan: HTMLS
charCounterSpan.classList.remove(SHAKE_CLASS);
}, 200);
}
-}
\ No newline at end of file
+}
+
+function addAutohideListener(): void {
+ let playerElement = findPlayerElement(PLAYER_ID);
+ let hideButton: HTMLButtonElement = document.getElementsByClassName('no-margin md-button md-ink-ripple layout-align-center-center layout-row')[0] as HTMLButtonElement;
+ if (assigned(playerElement) && assigned(hideButton)) {
+ if (hideButton.textContent.includes('HIDE')) {
+ hidden = false;
+ } else if (hideButton.textContent.includes('SHOW')) {
+ hidden = true;
+ }
+ playerElement.addEventListener('play', fn => {
+ if (!hidden) {
+ hideButton.click();
+ hidden = !hidden;
+ }
+ })
+ playerElement.addEventListener('pause', fn => {
+ if (hidden) {
+ hideButton.click();
+ hidden = !hidden;
+ }
+ })
+ }
+}