Skip to content

Commit 7819f07

Browse files
authored
create close-playground.js
1 parent 6dd3acd commit 7819f07

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

fern/assets/close-playground.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
document.addEventListener('click', function () {
2+
function isPlaygroundEndpointButtonVisible() {
3+
const playgroundEndpoint = document.querySelector('.playground-endpoint .fern-button.outlined');
4+
return playgroundEndpoint;
5+
}
6+
7+
function clickPlaygroundEndpointButton() {
8+
const playgroundEndpointButton = document.querySelector('.playground-endpoint .fern-button.outlined');
9+
if (playgroundEndpointButton) {
10+
playgroundEndpointButton.click();
11+
}
12+
}
13+
14+
const fernHeaderButtons = document.querySelectorAll('.fern-header-container button');
15+
fernHeaderButtons.forEach(button => {
16+
button.addEventListener('click', function () {
17+
if (isPlaygroundEndpointButtonVisible()) {
18+
clickPlaygroundEndpointButton();
19+
}
20+
});
21+
});
22+
23+
const fernHeaderTabs = document.querySelectorAll('.fern-header-container .fern-header-tab-button');
24+
fernHeaderTabs.forEach(button => {
25+
button.addEventListener('click', function () {
26+
if (isPlaygroundEndpointButtonVisible()) {
27+
clickPlaygroundEndpointButton();
28+
}
29+
});
30+
});
31+
});

0 commit comments

Comments
 (0)