Skip to content

Commit

Permalink
Added createStyle() ↞ [auto-sync from adamlui/chatgpt-apps]
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui authored and kudo-sync-bot committed Jun 30, 2024
1 parent f7a5ddb commit 62adc73
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions greasemonkey/duckduckgpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
// @description:zu Yengeza izimpendulo ze-AI ku-DuckDuckGo (inikwa amandla yi-GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2024.6.30
// @version 2024.6.30.1
// @license MIT
// @icon https://media.ddgpt.com/images/icons/duckduckgpt/icon48.png?af89302
// @icon64 https://media.ddgpt.com/images/icons/duckduckgpt/icon64.png?af89302
Expand Down Expand Up @@ -1447,12 +1447,6 @@

// Define FACTORY functions

function createSVGpath(attrs) {
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path')
for (const attr in attrs) path.setAttributeNS(null, attr, attrs[attr])
return path
}

function createAnchor(linkHref, displayContent, attrs = {}) {
const anchor = document.createElement('a'),
defaultAttrs = { href: linkHref, target: '_blank', rel: 'noopener' },
Expand All @@ -1464,6 +1458,17 @@
}
return anchor
}
function createStyle(content) {
const style = document.createElement('style')
if (content) style.innerText = content
return style
}

function createSVGpath(attrs) {
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path')
for (const attr in attrs) path.setAttributeNS(null, attr, attrs[attr])
return path
}

// Define TOGGLE functions

Expand Down Expand Up @@ -2332,12 +2337,12 @@
})

// Stylize APP elems
const appStyle = document.createElement('style') ; updateAppStyle()
const hljsStyle = document.createElement('style') ; hljsStyle.innerText = GM_getResourceText('hljsCSS')
const appStyle = createStyle() ; updateAppStyle()
const hljsStyle = createStyle(GM_getResourceText('hljsCSS'))
document.head.append(appStyle, hljsStyle)

// Stylize SITE elems
const tweaksStyle = document.createElement('style'),
const tweaksStyle = createStyle(),
wsbStyles = 'section[data-area="mainline"] { max-width: 590px !important }' // max before centered mode changes
+ 'section[data-area="sidebar"] { max-width: 530px !important ; flex-basis: 530px !important }'
+ '#app-chatbar { width: 85.6% }',
Expand All @@ -2349,14 +2354,13 @@
// Create/stylize TOOLTIPs
if (!isMobile) {
var tooltipDiv = document.createElement('div') ; tooltipDiv.classList.add('btn-tooltip', 'no-user-select')
const tooltipStyle = document.createElement('style')
tooltipStyle.innerText = '.btn-tooltip {'
document.head.append(createStyle('.btn-tooltip {'
+ 'background-color: rgba(0, 0, 0, 0.64) ; padding: 4px 6px ; border-radius: 6px ; border: 1px solid #d9d9e3 ;' // bubble style
+ 'font-size: 0.87em ; color: white ;' // font style
+ 'position: absolute ;' // for updateTooltip() calcs
+ 'box-shadow: 3px 5px 16px 0px rgb(0 0 0 / 21%) ;' // drop shadow
+ 'opacity: 0 ; transition: opacity 0.1s ; height: fit-content ; z-index: 9999 }' // visibility
document.head.append(tooltipStyle)
))
}

// Create/classify/fill feedback FOOTER
Expand Down

0 comments on commit 62adc73

Please sign in to comment.