refactor: prettierize all project
This commit is contained in:
parent
09d74504ea
commit
55edffd4b2
@ -1,11 +1,11 @@
|
|||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
if (!!window.chrome) {
|
if (!!window.chrome) {
|
||||||
const target =
|
const target =
|
||||||
document.head
|
document.head ||
|
||||||
|| document.getElementsByTagName('head')[0]
|
document.getElementsByTagName("head")[0] ||
|
||||||
|| document.body
|
document.body ||
|
||||||
|| document.getElementsByTagName('body')[0];
|
document.getElementsByTagName("body")[0];
|
||||||
|
|
||||||
// Create logic script
|
// Create logic script
|
||||||
const script = document.createElement("script");
|
const script = document.createElement("script");
|
||||||
@ -14,4 +14,4 @@ if (!!window.chrome) {
|
|||||||
|
|
||||||
// Inject logic script
|
// Inject logic script
|
||||||
if (!!target) target.appendChild(script);
|
if (!!target) target.appendChild(script);
|
||||||
};
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export const UNTOUCHABLE_SITES = [
|
export const UNTOUCHABLE_SITES = [
|
||||||
'www.aviva.co.uk',
|
"www.aviva.co.uk",
|
||||||
'www.gamemania.be',
|
"www.gamemania.be",
|
||||||
'www.guysandstthomas.nhs.uk',
|
"www.guysandstthomas.nhs.uk",
|
||||||
'www.youtube.com',
|
"www.youtube.com",
|
||||||
];
|
];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { UNTOUCHABLE_SITES } from './constants.js'
|
import { UNTOUCHABLE_SITES } from "./constants.js";
|
||||||
import { getNotRemovableElements, getRemovableElements } from './helpers.js';
|
import { getNotRemovableElements, getRemovableElements } from "./helpers.js";
|
||||||
|
|
||||||
// Observer
|
// Observer
|
||||||
const observer = new MutationObserver((mutations, observer) => {
|
const observer = new MutationObserver((mutations, observer) => {
|
||||||
@ -13,46 +13,60 @@ const observer = new MutationObserver((mutations, observer) => {
|
|||||||
// Remover
|
// Remover
|
||||||
const doMagic = () => {
|
const doMagic = () => {
|
||||||
// Getting elements
|
// Getting elements
|
||||||
const notRemovable = getNotRemovableElements(document)
|
const notRemovable = getNotRemovableElements(document).filter(
|
||||||
.filter(element => !!element);
|
(element) => !!element
|
||||||
const removable = getRemovableElements(document)
|
);
|
||||||
.filter(element => !!element);
|
const removable = getRemovableElements(document).filter(
|
||||||
|
(element) => !!element
|
||||||
|
);
|
||||||
|
|
||||||
// Fixing main elements
|
// Fixing main elements
|
||||||
if (!UNTOUCHABLE_SITES.includes(document.location.host)) {
|
if (!UNTOUCHABLE_SITES.includes(document.location.host)) {
|
||||||
document.documentElement.style.setProperty('margin-top', 'unset', 'important');
|
document.documentElement.style.setProperty(
|
||||||
document.documentElement.style.setProperty('overflow', 'unset', 'important');
|
"margin-top",
|
||||||
document.documentElement.style.setProperty('position', 'unset', 'important');
|
"unset",
|
||||||
document.body.style.setProperty('overflow', 'unset', 'important');
|
"important"
|
||||||
|
);
|
||||||
|
document.documentElement.style.setProperty(
|
||||||
|
"overflow",
|
||||||
|
"unset",
|
||||||
|
"important"
|
||||||
|
);
|
||||||
|
document.documentElement.style.setProperty(
|
||||||
|
"position",
|
||||||
|
"unset",
|
||||||
|
"important"
|
||||||
|
);
|
||||||
|
document.body.style.setProperty("overflow", "unset", "important");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove irritating all removable elements
|
// Remove irritating all removable elements
|
||||||
removable.forEach(element => {
|
removable.forEach((element) => {
|
||||||
const isRemovable =
|
const isRemovable =
|
||||||
element.tagName.toLowerCase() !== 'body'
|
element.tagName.toLowerCase() !== "body" &&
|
||||||
&& element.tagName.toLowerCase() !== 'html';
|
element.tagName.toLowerCase() !== "html";
|
||||||
|
|
||||||
if (isRemovable) {
|
if (isRemovable) {
|
||||||
const exists =
|
const exists =
|
||||||
document.getElementById(element.id)
|
document.getElementById(element.id) ||
|
||||||
|| document.getElementsByName(element.name).length > 0
|
document.getElementsByName(element.name).length > 0 ||
|
||||||
|| document.getElementsByClassName(element.className).length > 0;
|
document.getElementsByClassName(element.className).length > 0;
|
||||||
|
|
||||||
if (exists) element.remove();
|
if (exists) element.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove irritating styles from elements not removable
|
// Remove irritating styles from elements not removable
|
||||||
notRemovable.forEach(element => {
|
notRemovable.forEach((element) => {
|
||||||
element.style.setProperty('margin-top', 'unset', 'important');
|
element.style.setProperty("margin-top", "unset", "important");
|
||||||
element.style.setProperty('overflow', 'unset', 'important');
|
element.style.setProperty("overflow", "unset", "important");
|
||||||
element.style.setProperty('padding-top', 'unset', 'important');
|
element.style.setProperty("padding-top", "unset", "important");
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
element.classList.remove('cli-barmodal-open');
|
element.classList.remove("cli-barmodal-open");
|
||||||
element.classList.remove('cookiesAccepted');
|
element.classList.remove("cookiesAccepted");
|
||||||
element.classList.remove('cookiewall-active');
|
element.classList.remove("cookiewall-active");
|
||||||
element.classList.remove('noScroll');
|
element.classList.remove("noScroll");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user