refactor(browser-extension): restore animations
This commit is contained in:
parent
568cf4d725
commit
00f789ef6f
@ -107,9 +107,6 @@ chrome.runtime.onMessage.addListener((message, sender, callback) => {
|
|||||||
case 'GET_TAB':
|
case 'GET_TAB':
|
||||||
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => callback(tabs[0]));
|
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => callback(tabs[0]));
|
||||||
return true;
|
return true;
|
||||||
case 'INSERT_CONTENT_CSS':
|
|
||||||
if (isPage && tabId) script.insertCSS({ files: ['styles/content.css'], target: { tabId } });
|
|
||||||
break;
|
|
||||||
case 'INSERT_DIALOG_CSS':
|
case 'INSERT_DIALOG_CSS':
|
||||||
if (isPage && tabId) script.insertCSS({ files: ['styles/dialog.css'], target: { tabId } });
|
if (isPage && tabId) script.insertCSS({ files: ['styles/dialog.css'], target: { tabId } });
|
||||||
break;
|
break;
|
||||||
|
@ -53,12 +53,22 @@ let state = { enabled: true };
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const clean = (nodes, skipMatch) => {
|
const clean = (nodes, skipMatch) => {
|
||||||
const targets = nodes.filter((node) => match(node, skipMatch));
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
const node = nodes[i];
|
||||||
|
|
||||||
targets.forEach((node) => {
|
if (match(node, skipMatch)) {
|
||||||
node.remove();
|
const observer = new MutationObserver(() => {
|
||||||
elementCount += 1;
|
node.style.setProperty('display', 'none', 'important');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!node.hasAttribute('data-cookie-dialog-monster')) {
|
||||||
|
elementCount += 1;
|
||||||
|
node.setAttribute('data-cookie-dialog-monster', 'true');
|
||||||
|
node.style.setProperty('display', 'none', 'important');
|
||||||
|
observer.observe(node, { attributes: true, attributeFilter: ['style'] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,9 +118,11 @@ const match = (node, skipMatch) => {
|
|||||||
if (node instanceof HTMLElement) {
|
if (node instanceof HTMLElement) {
|
||||||
const style = window.getComputedStyle(node);
|
const style = window.getComputedStyle(node);
|
||||||
const skipIsInViewport =
|
const skipIsInViewport =
|
||||||
|
(style.animationName !== 'none' && style.animationPlayState === 'running') ||
|
||||||
style.display === 'none' ||
|
style.display === 'none' ||
|
||||||
style.height === '0px' ||
|
style.height === '0px' ||
|
||||||
style.opacity === '0' ||
|
style.opacity === '0' ||
|
||||||
|
style.transitionProperty !== 'none' ||
|
||||||
style.visibility === 'hidden';
|
style.visibility === 'hidden';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -172,9 +184,7 @@ const fix = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skips.includes(hostname)) {
|
if (!skips.some((skip) => skip.includes(hostname))) {
|
||||||
dispatch({ type: 'INSERT_CONTENT_CSS' });
|
|
||||||
|
|
||||||
for (const item of [document.body, document.documentElement]) {
|
for (const item of [document.body, document.documentElement]) {
|
||||||
item?.classList.remove(...(data?.classes ?? []));
|
item?.classList.remove(...(data?.classes ?? []));
|
||||||
item?.style.setProperty('position', 'initial', 'important');
|
item?.style.setProperty('position', 'initial', 'important');
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
*,
|
|
||||||
*:before,
|
|
||||||
*:after {
|
|
||||||
animation: none !important;
|
|
||||||
/* transform: none !important; */
|
|
||||||
transition-property: none !important;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user