#32 added options check for all JS enhancements

This commit is contained in:
Serraniel 2020-11-07 17:48:27 +01:00
parent f1d96ebcea
commit 1bbca43444
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3
6 changed files with 56 additions and 35 deletions

View file

@ -1,3 +1,4 @@
import { getGlobalConfiguration } from '../configuration/configuration';
import * as core from '../utils/aniwatchCore'; import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers'; import * as helper from '../utils/helpers';
@ -5,11 +6,13 @@ const SCREENSHOT_TOOLTIP_ID = 'anilyr-screenshots-tooltip';
const PLAYER_ID = 'player'; const PLAYER_ID = 'player';
export function init() { export function init() {
if (getGlobalConfiguration().playerAutoplayAfterScreenshot) {
core.registerScript(node => { core.registerScript(node => {
if (helper.isHtmlElement(node) && node.id === SCREENSHOT_TOOLTIP_ID) { if (helper.isHtmlElement(node) && node.id === SCREENSHOT_TOOLTIP_ID) {
observeScreenshotTooltip(node); observeScreenshotTooltip(node);
} }
}, "^/anime/[0-9]*/[0-9]*$"); }, "^/anime/[0-9]*/[0-9]*$");
}
} }
function observeScreenshotTooltip(tooltip) { function observeScreenshotTooltip(tooltip) {
@ -18,7 +21,7 @@ function observeScreenshotTooltip(tooltip) {
// Switched to invisible // Switched to invisible
if (!mutation.oldValue.includes('display: none') && mutation.target.style.display == 'none') { if (!mutation.oldValue.includes('display: none') && mutation.target.style.display == 'none') {
let player = findPlayer(); let player = findPlayer();
if(typeof player !== 'undefined'){ if (typeof player !== 'undefined') {
resumePlayer(player); resumePlayer(player);
} }
} }

View file

@ -1,8 +1,10 @@
import { getGlobalConfiguration } from '../configuration/configuration';
import * as core from '../utils/aniwatchCore'; import * as core from '../utils/aniwatchCore';
import * as color from '../utils/colors'; import * as color from '../utils/colors';
import * as helper from '../utils/helpers'; import * as helper from '../utils/helpers';
export function init() { export function init() {
if (getGlobalConfiguration().requestBeautifyPage) {
core.registerScript(node => { core.registerScript(node => {
// run the scripts // run the scripts
if (helper.isHtmlElement(node)) { if (helper.isHtmlElement(node)) {
@ -11,6 +13,7 @@ export function init() {
removeUnknownUsers(node); removeUnknownUsers(node);
} }
}, "/requests"); }, "/requests");
}
} }
function changeFollowedStarColor(node) { function changeFollowedStarColor(node) {
@ -71,7 +74,7 @@ function removeUnknownUsers(node) {
let parsedDocument = parser.parseFromString(profileData, 'text/html'); let parsedDocument = parser.parseFromString(profileData, 'text/html');
lowerDiv.innerHTML = ''; lowerDiv.innerHTML = '';
while(parsedDocument.body.hasChildNodes()){ while (parsedDocument.body.hasChildNodes()) {
lowerDiv.appendChild(parsedDocument.body.removeChild(parsedDocument.body.firstChild)); lowerDiv.appendChild(parsedDocument.body.removeChild(parsedDocument.body.firstChild));
} }
} }

View file

@ -1,13 +1,16 @@
import { getGlobalConfiguration } from '../configuration/configuration';
import * as core from '../utils/aniwatchCore'; import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers'; import * as helper from '../utils/helpers';
export function init() { export function init() {
if (getGlobalConfiguration().animeLanguageDisplay) {
core.registerScript(node => { core.registerScript(node => {
// run the scripts // run the scripts
if (helper.isHtmlElement(node)) { if (helper.isHtmlElement(node)) {
updateLanguageDisplay(node) updateLanguageDisplay(node)
} }
}, "^/anime/[0-9]*$"); }, "^/anime/[0-9]*$");
}
} }
function updateLanguageDisplay(node) { function updateLanguageDisplay(node) {

View file

@ -1,7 +1,9 @@
import { getGlobalConfiguration } from '../configuration/configuration';
import * as core from '../utils/aniwatchCore'; import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers'; import * as helper from '../utils/helpers';
export function init() { export function init() {
if (getGlobalConfiguration().websiteShowNotificationsCountInTab) {
core.runAfterLoad(() => { core.runAfterLoad(() => {
updateNotificationsInTitle(); updateNotificationsInTitle();
}, ".*"); }, ".*");
@ -9,6 +11,7 @@ export function init() {
core.runAfterLocationChange(() => { core.runAfterLocationChange(() => {
updateNotificationsInTitle(); updateNotificationsInTitle();
}, ".*"); }, ".*");
}
} }
function getNotificationCount() { function getNotificationCount() {

View file

@ -1,3 +1,4 @@
import { getGlobalConfiguration } from '../configuration/configuration';
import * as core from '../utils/aniwatchCore'; import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers'; import * as helper from '../utils/helpers';
@ -5,9 +6,15 @@ const quickSearchID = 'ea-quickSearch';
const quickSearchLink = 'ea-quickSearchLink'; const quickSearchLink = 'ea-quickSearchLink';
export function init() { export function init() {
let config = getGlobalConfiguration();
console.log(config);
console.log(config.websiteDisplayQuickSearch);
console.log(getGlobalConfiguration().websiteDisplayQuickSearch)
if (getGlobalConfiguration().websiteDisplayQuickSearch) {
core.runAfterLoad(() => { core.runAfterLoad(() => {
initSearch(); initSearch();
}, ".*"); }, ".*");
}
} }
function initSearch() { function initSearch() {

View file

@ -1,12 +1,14 @@
import * as core from '../utils/aniwatchCore'; import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers'; import * as helper from '../utils/helpers';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { getGlobalConfiguration } from '../configuration/configuration';
export function init() { export function init() {
// UPS // runAfterLoad is not what we want...wait for runAfterLocationChange.... if (getGlobalConfiguration().w2gDisplayCharacterCounter) {
core.runAfterLocationChange(() => { core.runAfterLocationChange(() => {
manipulateChatInput(); manipulateChatInput();
}, "^/watch2gether/.*$"); }, "^/watch2gether/.*$");
}
} }
function manipulateChatInput() { function manipulateChatInput() {