Skip to content

Commit

Permalink
fix: update menu layout to follow chatgpt layout changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pionxzh committed Dec 17, 2022
1 parent 5101b41 commit aa0abec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
21 changes: 10 additions & 11 deletions packages/userscript/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import html2canvas from 'html2canvas'
import { chatGPTAvatarSVG, fileCode, iconCamera, iconCopy } from './icons'
import './style.scss'
import { copyToClipboard, downloadFile, downloadUrl, escapeHtml, getBase64FromImg, onloadSafe, sleep, timestamp } from './utils'
import templateHtml from './template.html?raw'

Expand All @@ -23,17 +22,19 @@ main()

function main() {
onloadSafe(() => {
const container = document.querySelector('nav > a')?.parentElement
if (!container) {
console.error('Failed to find the container element.')
alert('Failed to find the container element. Please report this issue to the developer.')
const firstMenuItem = document.querySelector('nav > a')
const container = firstMenuItem?.parentElement
if (!firstMenuItem || !container) {
console.error('Failed to locate the menu container element.')
alert('Failed to locate the menu container element. Please report this issue to the developer.')
return
}

const divider = document.createElement('div')
divider.className = 'Navigation__NavMenuDivider'
divider.className = 'border-b border-white/20'
divider.style.marginBottom = '0.5rem'

const copyHtml = `${iconCopy}Copy`
const copyHtml = `${iconCopy}Copy Text`
const copiedHtml = `${iconCopy}Copied`
const onCopyText = (e: MouseEvent) => {
const items = getConversation()
Expand All @@ -49,12 +50,10 @@ function main() {
}, 3000)
}

const textExport = createMenuItem(iconCopy, 'Copy', onCopyText)
const textExport = createMenuItem(iconCopy, 'Copy Text', onCopyText)
const pngExport = createMenuItem(iconCamera, 'Screenshot', exportToPng)
const htmlExport = createMenuItem(fileCode, 'Export WebPage', exportToHtml)

container.appendChild(divider)
divider.after(textExport, pngExport, htmlExport)
firstMenuItem.after(divider, textExport, pngExport, htmlExport)
})
}

Expand Down
5 changes: 0 additions & 5 deletions packages/userscript/src/style.scss

This file was deleted.

0 comments on commit aa0abec

Please sign in to comment.