Skip to content

Commit

Permalink
Added Rate Us button to Donate modal + stack tracking for nav ↞ [auto…
Browse files Browse the repository at this point in the history
…-sync from `adamlui/chatgpt-apps/chatgpt-widescreen/greasemonkey`]
  • Loading branch information
adamlui authored and kudo-sync-bot committed Sep 30, 2024
1 parent 39e6647 commit e01bb2a
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions greasemonkey/chatgpt-widescreen-mode.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
// @description:zu Engeza izinhlobo zezimodi ze-Widescreen + Fullscreen ku-ChatGPT ukuze kube nokubonakala + ukuncitsha ukusukela
// @author Adam Lui
// @namespace https://github.com/adamlui
// @version 2024.9.30.4
// @version 2024.9.30.5
// @license MIT
// @compatible chrome
// @compatible firefox
Expand Down Expand Up @@ -528,9 +528,11 @@
// Define MODAL functions

const modals = {
stack: [],

about: {
show() {
modals.stack.unshift('about') ; modals.stack = [...new Set(modals.stack)] // track for nav

// Show alert
const chatgptJSver = (/chatgpt-([\d.]+)\.min/.exec(GM_info.script.header) || [null, ''])[1],
Expand All @@ -551,12 +553,7 @@
[ // buttons
function checkForUpdates() { updateCheck() },
function getSupport() { modals.safeWinOpen(app.urls.support) },
function rateUs() { // show new modal
const reviewModalID = chatgpt.alert(( app.msgs.alert_choosePlatform ) + ':', '',
[ function greasyFork() { modals.safeWinOpen(app.urls.greasyFork + '/feedback#post-discussion') },
function productHunt() { modals.safeWinOpen(app.urls.productHunt + '/reviews/new') }])
document.getElementById(reviewModalID).querySelector('button')
.style.display = 'none' }, // hide dismiss button
function rateUs() { modals.feedback.show() },
function moreChatGPTapps() { modals.safeWinOpen(app.urls.relatedApps) }
], '', 478 // set width
)
Expand All @@ -580,6 +577,7 @@
longCOVIDwikiLink: 'https://en.wikipedia.org/wiki/Long_COVID',

show() {
modals.stack.unshift('donate') ; modals.stack = [...new Set(modals.stack)] // track for nav

// Show alert
const donateModalID = siteAlert(
Expand All @@ -596,7 +594,8 @@
[ // buttons
function paypal() { modals.safeWinOpen(app.urls.donate.payPal) },
function githubSponsors() { modals.safeWinOpen(app.urls.donate.gitHub) },
function cashApp() { modals.safeWinOpen(app.urls.donate.cashApp) }
function cashApp() { modals.safeWinOpen(app.urls.donate.cashApp) },
function rateUs() { modals.feedback.show() }
], '', 478 // set width
)

Expand All @@ -610,13 +609,31 @@
btns.forEach((btn, idx) => {
if (idx == 0) btn.style.display = 'none' // hide Dismiss button
else {
btn.style.cssText = 'padding: 8px 6px !important ; margin-top: -18px ; width: 107px ; line-height: 14px'
if (idx == btns.length -1) btn.classList.remove('primary-modal-btn') // de-emphasize last link
btn.style.cssText = 'padding: 8px 6px !important ; margin-top: -14px ; width: 107px ; line-height: 14px'
if (idx == btns.length -1) // de-emphasize right-most button
btn.classList.remove('primary-modal-btn')
else if (/rate/i.test(btn.textContent)) // localize 'Rate Us' label
btn.textContent = app.msgs.btnLabel_rateUs
}
})
}
},

feedback: {
show() {
const reviewModalID = chatgpt.alert(
`${app.msgs.alert_choosePlatform}:`, '', // title
[ // buttons
function greasyFork() { modals.safeWinOpen(app.urls.greasyFork + '/feedback#post-discussion') },
function productHunt() { modals.safeWinOpen(app.urls.productHunt + '/reviews/new') }
]
)
const reviewModal = document.getElementById(reviewModalID)
reviewModal.querySelector('button').style.display = 'none' // hide Dismiss button
reviewModal.addEventListener('DOMNodeRemoved', () => modals[modals.stack[0]]?.show() ) // nav back on btn/bg clicks
}
},

safeWinOpen(url) { window.open(url, '_blank', 'noopener') } // to prevent backdoor vulnerabilities
}

Expand Down

0 comments on commit e01bb2a

Please sign in to comment.