fix(script): solve null errors

This commit is contained in:
wanhose 2020-05-16 17:09:49 +02:00
parent 58f52777bd
commit 2e3274c71a
2 changed files with 30 additions and 21 deletions

View File

@ -6,7 +6,7 @@ if (!!window.chrome && navigator.vendor.includes("Google")) {
// Create logic script // Create logic script
const script = document.createElement("script"); const script = document.createElement("script");
script.setAttribute("src", chrome.runtime.getURL("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

View File

@ -1,4 +1,4 @@
import { notRemovable, removable } from 'js/modules/elements.js'; import { notRemovable, removable } from './elements.js';
// Observer // Observer
const observer = new MutationObserver((mutations, observer) => { const observer = new MutationObserver((mutations, observer) => {
@ -13,27 +13,36 @@ const observer = new MutationObserver((mutations, observer) => {
// Remover // Remover
const doMagic = () => { const doMagic = () => {
// Remove irritating styles // Remove irritating styles
notRemovable.forEach(element => { notRemovable.forEach(element => {
// PLO // PLO
element.classList.remove("plu-no-scroll"); element.classList.remove("plu-no-scroll");
// Quantcast // Quantcast
element.classList.remove("qc-cmp-ui-showing"); element.classList.remove("qc-cmp-ui-showing");
// Miscellaneous // Miscellaneous
element.classList.remove("_2LLC6zrbk-vsnF0seit6vi"); element.classList.remove("_2LLC6zrbk-vsnF0seit6vi");
element.classList.remove("gdpr"); element.classList.remove("gdpr");
element.classList.remove("noScroll"); element.classList.remove("noScroll");
}); });
// Remove irritating elements // Remove irritating elements
removable.forEach(element => !!element && element.remove()); removable.forEach(element => {
if (!!element) {
const exists =
document.getElementById(element.id)
|| document.getElementsByName(element.name).length > 0
|| document.getElementsByClassName(element.className).length > 0;
// Fix stucked pages if (exists) element.remove();
if (document.body.style) { };
document.body.style.removeProperty("overflow"); });
document.body.style.removeProperty("overflowX");
document.body.style.removeProperty("overflowY"); // Fix stucked pages
}; if (document.body.style) {
document.body.style.removeProperty("overflow");
document.body.style.removeProperty("overflowX");
document.body.style.removeProperty("overflowY");
};
}; };
// Observer starts observe when call this function // Observer starts observe when call this function