Skip to content

Commit 7491be9

Browse files
authored
Add shadowRoot Extraction (#85)
* Add shadowRoot Extraction * Remove Title on Bug Template * Update Issue Template * Clean Up Extraction
1 parent 955d779 commit 7491be9

2 files changed

Lines changed: 46 additions & 12 deletions

File tree

.github/ISSUE_TEMPLATE/0-bug.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
name: "⚠️ Report an Issue"
22
description: "Something Not Working Right? Please let us know..."
3-
title: "[Bug] "
43
labels: ["bug"]
54
assignees:
65
- smashedr
76

87
body:
9-
- type: markdown
10-
attributes:
11-
value: |
12-
All bugs that we can verify will be fixed. Thank you for taking the time to make this report!
13-
148
- type: input
159
id: website
1610
validations:
@@ -34,6 +28,11 @@ body:
3428
validations:
3529
required: true
3630
attributes:
37-
label: Paste Support Information
31+
label: Support Information
3832
description: Open the extension options, scroll to the bottom, click Copy Support Information and paste below.
3933
render: shell
34+
35+
- type: markdown
36+
attributes:
37+
value: |
38+
All issues/bugs that we can verify will be fixed. Thank you for taking the time to make this report!

src/js/extract.js

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,55 @@ function onMessage(message, sender, sendResponse) {
2424
}
2525
}
2626

27+
// /**
28+
// * Extract links
29+
// * @function extractAllLinks
30+
// * @return {Array}
31+
// */
32+
// function extractAllLinks() {
33+
// console.debug('extractAllLinks')
34+
// const links = []
35+
// for (const element of document.links) {
36+
// if (element.href) {
37+
// pushElement(links, element)
38+
// }
39+
// }
40+
// console.debug('links:', links)
41+
// return links
42+
// }
43+
2744
/**
2845
* Extract links
2946
* @function extractAllLinks
3047
* @return {Array}
3148
*/
3249
function extractAllLinks() {
3350
console.debug('extractAllLinks')
51+
const links = findLinks(document)
52+
console.debug('links:', links)
53+
return links
54+
}
55+
56+
/**
57+
* Recursively Find Links from shadowRoot
58+
* @function findLinks
59+
* @param {Document|ShadowRoot} root
60+
* @return {Array}
61+
*/
62+
function findLinks(root) {
63+
console.debug('findLinks:', root)
3464
const links = []
35-
for (const element of document.links) {
36-
if (element.href) {
37-
pushElement(links, element)
38-
}
65+
if (root.querySelectorAll) {
66+
root.querySelectorAll('a').forEach((el) => {
67+
pushElement(links, el)
68+
})
3969
}
40-
console.debug('links:', links)
70+
const roots = Array.from(root.querySelectorAll('*')).filter(
71+
(el) => el.shadowRoot
72+
)
73+
roots.forEach((el) => {
74+
links.push(...findLinks(el.shadowRoot))
75+
})
4176
return links
4277
}
4378

0 commit comments

Comments
 (0)