-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new Logic for tabbing images, videos instead screenshots (later…
… on both by config)
- Loading branch information
1 parent
d105bf3
commit a9edf61
Showing
15 changed files
with
955 additions
and
1,934 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "Test", | ||
"urlsToAnalyze": [ | ||
"https://www.kurier.at" | ||
], | ||
"saveImages": true, | ||
"cookieSelector":"button", | ||
"cookieText":"^(Alle akzeptieren|Akzeptieren|Verstanden|Zustimmen|Okay|OK|Alle Cookies akzeptieren|Einverstanden)$", | ||
"debugMode": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
export interface ElementsFromEvaluation { | ||
elementsByVisibility: ElementVisibility[]; | ||
elementsByVisibility: string[]; | ||
focusableNonStandardElements: string[]; | ||
currentIndex: number; | ||
} | ||
|
||
export interface ElementVisibility { | ||
element: string; | ||
visible: boolean; | ||
spanElements: SpanElement[]; | ||
} | ||
|
||
export interface ListenerObject { | ||
listeners: Event[]; | ||
} | ||
export interface SpanElement { | ||
elementId: string; | ||
spanId: string; | ||
visible: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function exposeDepsJs (deps: Record<string, (...args: any) => any>): string { | ||
return Object.keys(deps) | ||
.map((key) => { | ||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions | ||
return `window["${key}"] = ${deps[key]};`; | ||
}) | ||
.join("\n"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// old method | ||
//export function isElementVisible (elementstring: string | null): boolean { | ||
// let elementVisible = false; | ||
// const dom = elementstring ? document.getElementById(elementstring) : null; | ||
// if (dom) { | ||
// let currentDom = dom; | ||
|
||
// const tolerance = 0.01; | ||
// const percentX = 90; | ||
// const percentY = 90; | ||
|
||
// const elementRect = currentDom.getBoundingClientRect(); | ||
|
||
// const parentRects: DOMRect[] = []; | ||
// while (currentDom.parentElement != null && currentDom.parentElement.tagName.toUpperCase() !== 'HTML') { | ||
// parentRects.push( | ||
// currentDom.parentElement.getBoundingClientRect() | ||
// ); | ||
// currentDom = currentDom.parentElement; | ||
// } | ||
// elementVisible = parentRects.every(function (parentRect) { | ||
// const visiblePixelX = | ||
// Math.min(elementRect.right, parentRect.right) - | ||
// Math.max(elementRect.left, parentRect.left); | ||
// const visiblePixelY = | ||
// Math.min(elementRect.bottom, parentRect.bottom) - | ||
// Math.max(elementRect.top, parentRect.top); | ||
// const visiblePercentageX = | ||
// (visiblePixelX / elementRect.width) * 100; | ||
// const visiblePercentageY = | ||
// (visiblePixelY / elementRect.height) * 100; | ||
// return ( visiblePercentageX + tolerance > percentX && | ||
// visiblePercentageY + tolerance > percentY && | ||
// elementRect.top < window.innerHeight && | ||
// elementRect.bottom >= 0); | ||
// }); | ||
// } | ||
// return elementVisible; | ||
// }; | ||
|
||
export function isElementVisible(elementstring: string | null): boolean { | ||
const elem = elementstring ? document.getElementById(elementstring) : null; | ||
if (!(elem instanceof Element)) return false; | ||
const style = getComputedStyle(elem); | ||
if (style.display === 'none') return false; | ||
if (style.visibility !== 'visible') return false; | ||
if (style.opacity === '0') return false; | ||
if (elem.offsetWidth + elem.offsetHeight + elem.getBoundingClientRect().height + | ||
elem.getBoundingClientRect().width === 0) { | ||
return false; | ||
} | ||
const elementPoints = { | ||
'center': { | ||
x: elem.getBoundingClientRect().left + elem.offsetWidth / 2, | ||
y: elem.getBoundingClientRect().top + elem.offsetHeight / 2 | ||
}, | ||
'top-left': { | ||
x: elem.getBoundingClientRect().left, | ||
y: elem.getBoundingClientRect().top | ||
}, | ||
'top-right': { | ||
x: elem.getBoundingClientRect().right, | ||
y: elem.getBoundingClientRect().top | ||
}, | ||
'bottom-left': { | ||
x: elem.getBoundingClientRect().left, | ||
y: elem.getBoundingClientRect().bottom | ||
}, | ||
'bottom-right': { | ||
x: elem.getBoundingClientRect().right, | ||
y: elem.getBoundingClientRect().bottom | ||
} | ||
} | ||
|
||
for(const index in elementPoints) { | ||
const point = elementPoints[index]; | ||
if (point.x < 0) return false; | ||
if (point.x > (document.documentElement.clientWidth || window.innerWidth)) return false; | ||
if (point.y < 0) return false; | ||
if (point.y > (document.documentElement.clientHeight || window.innerHeight)) return false; | ||
let pointContainer = document.elementFromPoint(point.x, point.y); | ||
if (pointContainer !== null) { | ||
do { | ||
if (pointContainer === elem) return !elementIntersected(elem.getBoundingClientRect()); | ||
} while (pointContainer = pointContainer.parentNode as HTMLElement); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
export function elementIntersected(elementRect: DOMRect): boolean { | ||
return Array.from(document.body.getElementsByTagName("*")).filter( | ||
x => getComputedStyle(x, null).getPropertyValue("position") === "fixed" | ||
).some(fixedElem => { | ||
const fixedElementClientRect = fixedElem.getBoundingClientRect(); | ||
const isIntersected = !( | ||
elementRect.top > fixedElementClientRect.bottom || | ||
elementRect.right < fixedElementClientRect.left || | ||
elementRect.bottom < fixedElementClientRect.top || | ||
elementRect.left > fixedElementClientRect.right | ||
); | ||
if ( isIntersected && fixedElementClientRect.height + elementRect.height > window.adjustScrollingBehindFixed + elementRect.height) { | ||
window.adjustScrollingBehindFixed = fixedElementClientRect.height + elementRect.height | ||
} | ||
return isIntersected; | ||
}) | ||
} | ||
|
||
|
||
export function highestZIndex(): number { | ||
return Math.max( | ||
...Array.from(document.querySelectorAll('body *'), (elem) => | ||
parseFloat(getComputedStyle(elem).zIndex) | ||
).filter((zIndex) => !isNaN(zIndex)) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.