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-gdpr-single-choice-overlay]'),
document.querySelector('[data-id="cookie-policy"]'), document.querySelector('[data-id="cookie-policy"]'),
...document.getElementsByClassName('dimmed'), ...document.getElementsByClassName('dimmed'),
document.getElementById('div_bar_cookies_info'),
document.getElementById('eu-cookie-law'), document.getElementById('eu-cookie-law'),
...document.getElementsByClassName('eupopup-container'), ...document.getElementsByClassName('eupopup-container'),
document.getElementById('footer_tc_privacy'), document.getElementById('footer_tc_privacy'),

View File

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