Skip to content

Commit

Permalink
Abstracted toggles.sidebar.ids ↞ [auto-sync from https://github.com…
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Dec 12, 2024
1 parent 0486589 commit c4ad0e9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions greasemonkey/autoclear-chatgpt-history.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
// @description:zu Ziba itshala lokucabanga okuzoshintshwa ngokuzenzakalelayo uma ukubuka chatgpt.com
// @author Adam Lui
// @namespace https://github.com/adamlui
// @version 2024.12.12
// @version 2024.12.12.1
// @license MIT
// @icon https://media.autoclearchatgpt.com/images/icons/openai/black/icon48.png?a8868ef
// @icon64 https://media.autoclearchatgpt.com/images/icons/openai/black/icon64.png?a8868ef
Expand Down Expand Up @@ -762,12 +762,13 @@
const toggles = {

sidebar: {
ids: { navicon: `${app.cssPrefix}-toggle-navicon`, knobSpan: `${app.cssPrefix}-toggle-knob-span` },

create() {
this.div = document.createElement('div')

// Create/ID/size/position navicon
const navicon = document.createElement('img') ; navicon.id = `${app.cssPrefix}-toggle-navicon`
const navicon = document.createElement('img') ; navicon.id = this.ids.navicon
navicon.style.cssText = 'width: 1.25rem ; height: 1.25rem ; margin-left: 2px ; margin-right: 4px'

// Create/disable/hide checkbox
Expand All @@ -785,7 +786,7 @@
})

// Create/stylize knob, append to switch
const knobSpan = document.createElement('span') ; knobSpan.id = `${app.cssPrefix}-toggle-knob-span`
const knobSpan = document.createElement('span') ; knobSpan.id = this.ids.knobSpan
Object.assign(knobSpan.style, {
position: 'absolute', left: '3px', bottom: '1.25px',
width: '12px', height: '12px', content: '""', borderRadius: '28px',
Expand Down Expand Up @@ -827,8 +828,7 @@
},

insert() {
if (this.status?.startsWith('insert') || document.getElementById(`${app.cssPrefix}-toggle-navicon`))
return
if (this.status?.startsWith('insert') || document.getElementById(this.ids.navicon)) return
this.status = 'inserting' ; if (!this.div) this.create()

// Insert toggle
Expand All @@ -837,8 +837,8 @@
sidebar.insertBefore(this.div, sidebar.children[1])

// Tweak styles
const knobSpan = document.getElementById(`${app.cssPrefix}-toggle-knob-span`),
navicon = document.getElementById(`${app.cssPrefix}-toggle-navicon`)
const knobSpan = document.getElementById(this.ids.knobSpan),
navicon = document.getElementById(this.ids.navicon)
this.div.style.flexGrow = 'unset' // overcome OpenAI .grow
this.div.style.paddingLeft = '8px'
if (knobSpan) knobSpan.style.boxShadow = (
Expand Down Expand Up @@ -923,7 +923,7 @@

// Monitor NODE CHANGES to maintain sidebar toggle visibility
new MutationObserver(() => {
if (!config.toggleHidden && !document.getElementById(`${app.cssPrefix}-toggle-navicon`)
if (!config.toggleHidden && !document.getElementById(toggles.sidebar.ids.navicon)
&& toggles.sidebar.status != 'inserting') {
toggles.sidebar.status = 'missing' ; toggles.sidebar.insert() }
}).observe(document.body, { attributes: true, subtree: true })
Expand Down

0 comments on commit c4ad0e9

Please sign in to comment.