Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SailPoint Structured Data Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iam-pub
SailPoint Structured Data Viewer
Commits
037f641a
Commit
037f641a
authored
Jul 25, 2024
by
Ryan Rumbaugh
Browse files
Options
Downloads
Patches
Plain Diff
Using manifest for chrome & edge
parent
58d2b58a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
content.js
+96
-83
96 additions, 83 deletions
content.js
manifest.json
+3
-1
3 additions, 1 deletion
manifest.json
with
99 additions
and
84 deletions
content.js
+
96
−
83
View file @
037f641a
...
...
@@ -67,7 +67,12 @@ function addToggleButton() {
const
rows
=
document
.
querySelectorAll
(
'
tr
'
);
rows
.
forEach
(
row
=>
{
const
titleCell
=
row
.
querySelector
(
'
td.attributeTitleColumn > span[style*="padding:5px"]
'
);
if
(
titleCell
&&
titleCell
.
textContent
.
trim
()
===
'
Structured Data
'
)
{
if
(
!
titleCell
)
{
console
.
error
(
'
titleCell not found in row:
'
,
row
);
return
;
}
if
(
titleCell
.
textContent
.
trim
()
===
'
Structured Data
'
)
{
console
.
log
(
'
Found Structured Data row
'
);
let
toggleButton
=
row
.
querySelector
(
'
.toggle-button
'
);
if
(
!
toggleButton
)
{
...
...
@@ -77,7 +82,7 @@ function addToggleButton() {
toggleButton
.
className
=
'
toggle-button
'
;
toggleButton
.
addEventListener
(
'
click
'
,
(
event
)
=>
{
event
.
preventDefault
();
// Prevent any default action
toggleXML
();
toggleXML
(
titleCell
);
});
// Append the button directly next to the "Structured Data" text
...
...
@@ -87,19 +92,8 @@ function addToggleButton() {
});
}
function
formatXML
()
{
const
rows
=
document
.
querySelectorAll
(
'
tr
'
);
let
xmlContainer
=
null
;
rows
.
forEach
(
row
=>
{
const
titleCell
=
row
.
querySelector
(
'
td.attributeTitleColumn > span[style*="padding:5px"]
'
);
if
(
titleCell
&&
titleCell
.
textContent
.
trim
()
===
'
Structured Data
'
)
{
xmlContainer
=
row
.
querySelector
(
'
td.left > span[style*="padding:5px"]
'
);
}
});
if
(
xmlContainer
)
{
const
xmlString
=
xmlContainer
.
innerHTML
.
replace
(
/</g
,
'
<
'
).
replace
(
/>/g
,
'
>
'
);
function
formatXML
(
xmlString
)
{
const
parser
=
new
DOMParser
();
const
xmlDoc
=
parser
.
parseFromString
(
xmlString
,
'
text/xml
'
);
const
xsltProcessor
=
new
XSLTProcessor
();
...
...
@@ -118,11 +112,11 @@ function addToggleButton() {
</xsl:template>
<xsl:template match="*">
<div class="xml-element">
<b
><xsl:value-of select="name()"/></
b
>
<span class="xml-element-name"
><xsl:value-of select="name()"/></
span
>
<xsl:if test="count(@*) > 0">
<span class="xml-attributes"> [</span>
<xsl:for-each select="@*">
<span class="xml-attribute"><
b
><xsl:value-of select="name()"/></
b
>: "<xsl:value-of select="."/>"</span>
<span class="xml-attribute"><
span class="xml-attribute-name"
><xsl:value-of select="name()"/></
span
>: "<
span class="xml-attribute-value"><
xsl:value-of select="."/>
</span>
"</span>
<xsl:if test="position() != last()">
<span class="xml-attribute-separator">, </span>
</xsl:if>
...
...
@@ -132,7 +126,7 @@ function addToggleButton() {
<xsl:if test="normalize-space(text()) != ''">
: <span class="xml-text-value">"<xsl:value-of select="normalize-space(text())"/>"</span>
</xsl:if>
<div
style="margin-left: 20px;
">
<div
class="xml-children
">
<xsl:apply-templates/>
</div>
</div>
...
...
@@ -143,28 +137,47 @@ function addToggleButton() {
xslStylesheet
.
appendChild
(
xslTemplateNode
);
xsltProcessor
.
importStylesheet
(
xslStylesheet
);
const
resultDocument
=
xsltProcessor
.
transformToFragment
(
xmlDoc
,
document
);
xmlContainer
.
innerHTML
=
''
;
xmlContainer
.
appendChild
(
resultDocument
);
}
// Create a container to hold the transformed XML
const
container
=
document
.
createElement
(
'
div
'
);
container
.
appendChild
(
resultDocument
);
return
container
.
innerHTML
;
}
function
toggleXML
()
{
const
rows
=
document
.
querySelectorAll
(
'
tr
'
);
let
xmlContainer
=
null
;
rows
.
forEach
(
row
=>
{
const
titleCell
=
row
.
querySelector
(
'
td.attributeTitleColumn > span[style*="padding:5px"]
'
);
if
(
titleCell
&&
titleCell
.
textContent
.
trim
()
===
'
Structured Data
'
)
{
xmlContainer
=
row
.
querySelector
(
'
td.left > span[style*="padding:5px"]
'
)
;
function
toggleXML
(
titleCell
)
{
if
(
!
titleCell
)
{
console
.
error
(
'
titleCell is undefined
'
);
return
;
}
});
if
(
xmlContainer
)
{
if
(
xmlContainer
.
innerHTML
.
includes
(
'
<
'
))
{
formatXML
();
}
else
{
xmlContainer
.
style
.
display
=
xmlContainer
.
style
.
display
===
'
none
'
?
'
block
'
:
'
none
'
;
const
parentRow
=
titleCell
.
closest
(
'
tr
'
);
if
(
!
parentRow
)
{
console
.
error
(
'
Parent row not found
'
);
return
;
}
const
xmlContainer
=
parentRow
.
querySelector
(
'
td.left > span[style*="padding:5px"]
'
);
if
(
!
xmlContainer
)
{
console
.
error
(
'
XML container not found
'
);
return
;
}
if
(
!
xmlContainer
.
dataset
.
originalXml
)
{
// Save the original XML data
xmlContainer
.
dataset
.
originalXml
=
xmlContainer
.
innerHTML
;
console
.
log
(
'
Original XML saved
'
);
}
if
(
xmlContainer
.
innerHTML
===
xmlContainer
.
dataset
.
originalXml
)
{
// Format and display the XML
console
.
log
(
'
Formatting XML
'
);
const
formattedXML
=
formatXML
(
xmlContainer
.
dataset
.
originalXml
.
replace
(
/</g
,
'
<
'
).
replace
(
/>/g
,
'
>
'
));
xmlContainer
.
innerHTML
=
''
;
xmlContainer
.
innerHTML
=
formattedXML
;
}
else
{
// Revert to the original XML
console
.
log
(
'
Reverting to original XML
'
);
xmlContainer
.
innerHTML
=
xmlContainer
.
dataset
.
originalXml
;
}
}
This diff is collapsed.
Click to expand it.
manifest.json
+
3
−
1
View file @
037f641a
...
...
@@ -6,7 +6,9 @@
"permissions"
:
[
"activeTab"
],
"content_scripts"
:
[
{
"matches"
:
[
"https://iga*.nebraska.edu/*"
],
"matches"
:
[
"https://iga.nebraska.edu/*"
,
"https://iga-tst.nebraska.edu/*"
,
"https://iga-dev.nebraska.edu/*"
],
"js"
:
[
"content.js"
],
"css"
:
[
"styles.css"
],
"run_at"
:
"document_end"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment