#48 Added types for css enhancements

This commit is contained in:
Serraniel 2020-12-28 22:46:28 +01:00
parent f99034ceb3
commit 8a0f4a3db2
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3

View file

@ -2,13 +2,12 @@ import { getGlobalConfiguration, SETTINGS_websiteHideUnusedTabs, SETTINGS_websit
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(): void {
getGlobalConfiguration().getProperty(SETTINGS_websiteHideUnusedTabs, value => { getGlobalConfiguration().getProperty(SETTINGS_websiteHideUnusedTabs, value => {
// if disabled, add class to avoid our css optimizations // if disabled, add class to avoid our css optimizations
if (!value) { if (!value) {
let disableFunc = node => { let disableFunc = (node: Element) => {
if (helper.isHtmlElement(node)) { let disableNode = (node: Element) => {
let disableNode = node => {
node.classList.add('awp-hide-unused-disabled') node.classList.add('awp-hide-unused-disabled')
} }
@ -18,11 +17,12 @@ export function init() {
else { else {
node.querySelectorAll('md-tab-item').forEach(node => disableNode(node)); node.querySelectorAll('md-tab-item').forEach(node => disableNode(node));
} }
}
}; };
core.registerScript(node => { core.registerScript(node => {
if (node instanceof Element) {
disableFunc(node); disableFunc(node);
}
}, ".*"); }, ".*");
core.runAfterLoad(() => { core.runAfterLoad(() => {
@ -34,9 +34,8 @@ export function init() {
getGlobalConfiguration().getProperty(SETTINGS_websiteOptimizeListAppearance, value => { getGlobalConfiguration().getProperty(SETTINGS_websiteOptimizeListAppearance, value => {
// if disabled, add class to avoid our css optimizations // if disabled, add class to avoid our css optimizations
if (!value) { if (!value) {
let disableFunc = node => { let disableFunc = (node: Element) => {
if (helper.isHtmlElement(node)) { let disableNode = (node: Element) => {
let disableNode = node => {
node.classList.add('awp-list-disabled') node.classList.add('awp-list-disabled')
} }
@ -47,10 +46,11 @@ export function init() {
node.querySelectorAll('md-list-item').forEach(node => disableNode(node)); node.querySelectorAll('md-list-item').forEach(node => disableNode(node));
} }
} }
}
core.registerScript(node => { core.registerScript(node => {
if (node instanceof Element) {
disableFunc(node); disableFunc(node);
}
}, ".*"); }, ".*");
core.runAfterLoad(() => { core.runAfterLoad(() => {