From 97042aa26ad1eb26b24aca5c5ffaf4a043526fa9 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Sat, 14 Nov 2020 18:01:55 +0100 Subject: [PATCH] #115 replaced checks for undefined with assigned helper function --- src/javascript/enhancements/anilyr.js | 2 +- src/javascript/enhancements/languageDisplay.js | 5 ++--- src/javascript/enhancements/watch2getherChat.js | 3 ++- src/javascript/utils/aniwatchCore.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/javascript/enhancements/anilyr.js b/src/javascript/enhancements/anilyr.js index b8036f2..2b4d6cb 100644 --- a/src/javascript/enhancements/anilyr.js +++ b/src/javascript/enhancements/anilyr.js @@ -23,7 +23,7 @@ function observeScreenshotTooltip(tooltip) { // Switched to invisible if (!mutation.oldValue.includes('display: none') && mutation.target.style.display == 'none') { let player = findPlayer(); - if (typeof player !== 'undefined') { + if (helper.assigned(player)) { resumePlayer(player); } } diff --git a/src/javascript/enhancements/languageDisplay.js b/src/javascript/enhancements/languageDisplay.js index e96eef3..a76529a 100644 --- a/src/javascript/enhancements/languageDisplay.js +++ b/src/javascript/enhancements/languageDisplay.js @@ -31,8 +31,7 @@ function updateLanguageDisplay(node) { function updateLanguageDisplayListMode(node) { // last column with flags let col = node.querySelector('h3.layout-align-end-center'); - - if (typeof col === 'undefined' || col.awpManipulated) { + if (!helper.assigned(col) || col.awpManipulated) { return; } @@ -43,7 +42,7 @@ function updateLanguageDisplayBoxMode(node) { // last column with flags let col = node.querySelector('div.layout-align-end-start'); - if (typeof col === 'undefined' || col.awpManipulated) { + if (!helper.assigned(col) || col.awpManipulated) { return; } diff --git a/src/javascript/enhancements/watch2getherChat.js b/src/javascript/enhancements/watch2getherChat.js index a3e5dc6..933dbf6 100644 --- a/src/javascript/enhancements/watch2getherChat.js +++ b/src/javascript/enhancements/watch2getherChat.js @@ -1,6 +1,7 @@ import * as core from '../utils/aniwatchCore'; import { v4 as uuidv4 } from 'uuid'; import { getGlobalConfiguration, SETTINGS_w2gDisplayCharacterCounter } from '../configuration/configuration'; +import { assigned } from '../utils/helpers'; export function init() { getGlobalConfiguration().getProperty(SETTINGS_w2gDisplayCharacterCounter, value => { @@ -16,7 +17,7 @@ function manipulateChatInput() { let textarea = document.querySelector('.chat-input textarea'); // avoid duplicate registration - if (typeof textarea.dataset.charCounterId !== 'undefined') { + if (assigned(textarea.dataset.charCounterId)) { return; } diff --git a/src/javascript/utils/aniwatchCore.js b/src/javascript/utils/aniwatchCore.js index db6c599..0900f8d 100644 --- a/src/javascript/utils/aniwatchCore.js +++ b/src/javascript/utils/aniwatchCore.js @@ -82,7 +82,7 @@ function awaitPageLoaded() { }); }; - if (typeof preLoader === 'undefined') { + if (!helper.assigned(preLoader)) { runScripts(); return; }