feat(script): add remove unnecessary top margins

This commit is contained in:
wanhose 2020-05-24 19:08:57 +02:00
parent 7515c0eab3
commit d5f79c0eeb
2 changed files with 14 additions and 3 deletions

View File

@ -3,12 +3,12 @@
if (!!window.chrome && navigator.vendor.includes("Google")) { if (!!window.chrome && navigator.vendor.includes("Google")) {
// Get document head // Get document head
const head = document.head || document.getElementsByTagName('head')[0]; const head = document.head || document.getElementsByTagName('head')[0];
// Create logic script // Create logic script
const script = document.createElement("script"); const script = document.createElement("script");
script.setAttribute("src", chrome.runtime.getURL("js/modules/script.js")); script.setAttribute("src", chrome.runtime.getURL("js/modules/script.js"));
script.setAttribute("type", "module"); script.setAttribute("type", "module");
// Inject logic script // Inject logic script
head.appendChild(script); head.appendChild(script);
}; };

View File

@ -17,6 +17,11 @@ const doMagic = () => {
const removable = getRemovableElements(document) const removable = getRemovableElements(document)
.filter(element => !!element); .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');
// Remove irritating all removable elements // Remove irritating all removable elements
removable.forEach(element => { removable.forEach(element => {
const exists = const exists =
@ -28,7 +33,13 @@ const doMagic = () => {
}); });
// Remove irritating styles from elements not removable // Remove irritating styles from elements not removable
notRemovable.forEach(element => element.style.setProperty('overflow', 'unset', 'important')); notRemovable.forEach(element => {
element.style.setProperty('margin-top', 'unset', 'important');
element.style.setProperty('overflow', 'auto', 'important');
// Miscellaneous
element.classList.remove('cli-barmodal-open');
});
}; };
// Observer starts observe when call this function // Observer starts observe when call this function