feat(constants): add untouchable sites to avoid fixing html element

This commit is contained in:
wanhose 2020-05-24 20:00:38 +02:00
parent 3a42195229
commit ff1f62e16c
3 changed files with 10 additions and 5 deletions

View File

@ -0,0 +1,3 @@
export const UNTOUCHABLE_SITES = [
'www.aviva.co.uk',
];

View File

@ -197,6 +197,7 @@ export const getRemovableElements = (document) => Array.from([
document.querySelector('[data-gdpr-single-choice-overlay]'),
document.querySelector('[data-id="cookie-policy"]'),
...document.getElementsByClassName('dimmed'),
document.getElementById('div_bar_cookies_info'),
document.getElementById('eu-cookie-law'),
...document.getElementsByClassName('eupopup-container'),
document.getElementById('footer_tc_privacy'),
@ -239,4 +240,4 @@ export const getRemovableElements = (document) => Array.from([
document.getElementById('userConsent'),
...document.getElementsByClassName('widget_cookies'),
document.getElementById('widget_eu_cookie_law_widget'),
]);
]);

View File

@ -1,3 +1,4 @@
import { UNTOUCHABLE_SITES } from './constants.js'
import { getNotRemovableElements, getRemovableElements } from './helpers.js';
// Observer
@ -18,9 +19,9 @@ const doMagic = () => {
.filter(element => !!element);
// Fixing main elements
document.documentElement.style.setProperty('overflow', 'auto', 'important');
document.documentElement.style.setProperty('overflowX', 'auto', 'important');
document.documentElement.style.setProperty('overflowY', 'auto', 'important');
if (!UNTOUCHABLE_SITES.includes(document.location.host)) {
document.documentElement.style.setProperty('overflow', 'unset', 'important');
}
// Remove irritating all removable elements
removable.forEach(element => {
@ -35,7 +36,7 @@ const doMagic = () => {
// Remove irritating styles from elements not removable
notRemovable.forEach(element => {
element.style.setProperty('margin-top', 'unset', 'important');
element.style.setProperty('overflow', 'auto', 'important');
element.style.setProperty('overflow', 'unset', 'important');
// Miscellaneous
element.classList.remove('cli-barmodal-open');