Skip to content

Commit

Permalink
Added chatgpt.sidebar.exists() + aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed Sep 12, 2024
1 parent faa2635 commit 21d2dc9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions chatgpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
return newElement.id; // Return the element id
},

exists() { return !!chatgpt.getNewChatLink(); },
hide() { this.isOn() ? this.toggle() : console.info('Sidebar already hidden!'); },
show() { this.isOff() ? this.toggle() : console.info('Sidebar already shown!'); },
isOff() { return !this.isOn(); },
Expand Down Expand Up @@ -1903,6 +1904,7 @@ const cjsFuncAliases = [
['deactivateAutoRefresh', 'deactivateAutoRefresher', 'deactivateRefresher', 'deactivateSessionRefresher'],
['detectLanguage', 'getLanguage'],
['executeCode', 'codeExecute'],
['exists', 'isAvailable', 'isExistent', 'isPresent'],
['exportChat', 'chatExport', 'export'],
['getFooterDiv', 'getFooter'],
['getHeaderDiv', 'getHeader'],
Expand Down
12 changes: 12 additions & 0 deletions docs/USERGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
- [toggle](#toggle-1)
- [sidebar `api`](#sidebar-api)
- [append](#append)
- [exists](#exists)
- [isOn](#ison-1)
- [isOff](#isoff-1)
- [hide](#hide)
Expand Down Expand Up @@ -1825,6 +1826,17 @@ const dropdownId = chatgpt.sidebar.append('dropdown', {
console.log(dropdownId); // Example output: 1693294795240
```

### exists

Returns a boolean value. `true` if the sidebar exists , `false` otherwise (e.g. logged out UI).

Example code:

```js
if (!chatgpt.sidebar.exists())
chatgpt.alert('Sidebar is missing!')
```

### isOn

Returns a boolean value. `true` if the sidebar is open, `false` otherwise.
Expand Down

0 comments on commit 21d2dc9

Please sign in to comment.