feat(packages): implement new tags file
This commit is contained in:
parent
317b271dad
commit
23b9acd118
16
data/tags.txt
Normal file
16
data/tags.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
BASE
|
||||||
|
BODY
|
||||||
|
HEAD
|
||||||
|
HTML
|
||||||
|
IMG
|
||||||
|
LI
|
||||||
|
LINK
|
||||||
|
META
|
||||||
|
NAV
|
||||||
|
OL
|
||||||
|
SCRIPT
|
||||||
|
STYLE
|
||||||
|
SVG
|
||||||
|
TITLE
|
||||||
|
UL
|
||||||
|
VIDEO
|
@ -9,12 +9,14 @@ export default (server: FastifyInstance, options: RouteShorthandOptions, done: (
|
|||||||
const elementsUrl = `${dataUrl}/elements.txt`;
|
const elementsUrl = `${dataUrl}/elements.txt`;
|
||||||
const fixesUrl = `${dataUrl}/fixes.txt`;
|
const fixesUrl = `${dataUrl}/fixes.txt`;
|
||||||
const skipsUrl = `${dataUrl}/skips.txt`;
|
const skipsUrl = `${dataUrl}/skips.txt`;
|
||||||
|
const tagsUrl = `${dataUrl}/tags.txt`;
|
||||||
|
|
||||||
const results = await Promise.all([
|
const results = await Promise.all([
|
||||||
fetch(classesUrl),
|
fetch(classesUrl),
|
||||||
fetch(elementsUrl),
|
fetch(elementsUrl),
|
||||||
fetch(fixesUrl),
|
fetch(fixesUrl),
|
||||||
fetch(skipsUrl),
|
fetch(skipsUrl),
|
||||||
|
fetch(tagsUrl),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
reply.send({
|
reply.send({
|
||||||
@ -23,6 +25,7 @@ export default (server: FastifyInstance, options: RouteShorthandOptions, done: (
|
|||||||
elements: (await results[1].text()).split('\n'),
|
elements: (await results[1].text()).split('\n'),
|
||||||
fixes: (await results[2].text()).split('\n'),
|
fixes: (await results[2].text()).split('\n'),
|
||||||
skips: (await results[3].text()).split('\n'),
|
skips: (await results[3].text()).split('\n'),
|
||||||
|
tags: (await results[4].text()).split('\n'),
|
||||||
},
|
},
|
||||||
success: true,
|
success: true,
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @description Data properties
|
* @description Data properties
|
||||||
* @type {{ classes: string[], fixes: string[], elements: string[], skips: string[] }?}
|
* @type {{ classes: string[], fixes: string[], elements: string[], skips: string[], tags: string[] }?}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let data = null;
|
let data = null;
|
||||||
@ -11,12 +11,6 @@ let data = null;
|
|||||||
|
|
||||||
const dispatch = chrome.runtime.sendMessage;
|
const dispatch = chrome.runtime.sendMessage;
|
||||||
|
|
||||||
/**
|
|
||||||
* @description Forbidden tags to ignore in the DOM
|
|
||||||
*/
|
|
||||||
|
|
||||||
const forbiddenTags = ['BASE', 'BODY', 'HEAD', 'HTML', 'LINK', 'META', 'SCRIPT', 'STYLE', 'TITLE'];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Current hostname
|
* @description Current hostname
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@ -51,7 +45,7 @@ const match = (node) => {
|
|||||||
const isVisible = rect.top <= (window.innerHeight || document.documentElement.clientHeight);
|
const isVisible = rect.top <= (window.innerHeight || document.documentElement.clientHeight);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
!forbiddenTags.includes(node.tagName?.toUpperCase?.()) &&
|
!data?.tags.includes(node.tagName?.toUpperCase?.()) &&
|
||||||
(isFullscreen || isVisible) &&
|
(isFullscreen || isVisible) &&
|
||||||
(node.offsetParent || window.getComputedStyle(node).position === 'fixed') &&
|
(node.offsetParent || window.getComputedStyle(node).position === 'fixed') &&
|
||||||
node.parentElement &&
|
node.parentElement &&
|
||||||
|
Loading…
Reference in New Issue
Block a user