|
220 | 220 | // @description:zu *NGOKUPHEPHA* susa ukusetha kabusha ingxoxo yemizuzu eyi-10 + amaphutha enethiwekhi ahlala njalo + Ukuhlolwa kwe-Cloudflare ku-ChatGPT. |
221 | 221 | // @author Adam Lui |
222 | 222 | // @namespace https://github.com/adamlui |
223 | | -// @version 2025.2.12 |
| 223 | +// @version 2025.2.12.1 |
224 | 224 | // @license MIT |
225 | 225 | // @icon https://assets.chatgptautorefresh.com/images/icons/openai/black/icon48.png?v=f11a0a8 |
226 | 226 | // @icon64 https://assets.chatgptautorefresh.com/images/icons/openai/black/icon64.png?v=f11a0a8 |
|
422 | 422 | words: [app.msgs.state_off.toUpperCase(), app.msgs.state_on.toUpperCase()] |
423 | 423 | }, |
424 | 424 |
|
| 425 | + refresh() { |
| 426 | + if (typeof GM_unregisterMenuCommand == 'undefined') return |
| 427 | + for (const id of menu.ids) { GM_unregisterMenuCommand(id) } menu.register() |
| 428 | + }, |
| 429 | + |
425 | 430 | register() { |
426 | 431 |
|
427 | 432 | // Init prompt setting status labels |
|
469 | 474 | + ` ${app.msgs[`menuLabel_${entryType}`]} ${ entryType == 'about' ? app.msgs.appName : '' }`, |
470 | 475 | () => modals.open(entryType), env.scriptManager.supportsTooltips ? { title: ' ' } : undefined |
471 | 476 | ))) |
472 | | - }, |
473 | | - |
474 | | - refresh() { |
475 | | - if (typeof GM_unregisterMenuCommand == 'undefined') return |
476 | | - for (const id of menu.ids) { GM_unregisterMenuCommand(id) } menu.register() |
477 | 477 | } |
478 | 478 | } |
479 | 479 |
|
|
534 | 534 | stack: [], // of types of undismissed modals |
535 | 535 | class: `${app.slug}-modal`, |
536 | 536 |
|
537 | | - alert(title = '', msg = '', btns = '', checkbox = '', width = '') { // generic one from chatgpt.alert() |
538 | | - const alertID = chatgpt.alert(title, msg, btns, checkbox, width), |
539 | | - alert = document.getElementById(alertID).firstChild |
540 | | - this.init(alert) // add classes + rising particles bg |
541 | | - return alert |
542 | | - }, |
543 | | - |
544 | | - open(modalType, modalSubType) { |
545 | | - const modal = modalSubType ? this[modalType][modalSubType]() : this[modalType]() // show modal |
546 | | - if (!modal) return // since no div returned |
547 | | - this.stack.unshift(modalSubType ? `${modalType}_${modalSubType}` : modalType) // add to stack |
548 | | - this.init(modal) // add classes + rising particles bg |
549 | | - this.observeRemoval(modal, modalType, modalSubType) // to maintain stack for proper nav |
550 | | - }, |
551 | | - |
552 | | - init(modal) { |
553 | | - if (!this.styles) this.stylize() // to init/append stylesheet |
554 | | - modal.classList.add('no-user-select', this.class) ; modal.parentNode.classList.add(`${this.class}-bg`) |
555 | | - dom.addRisingParticles(modal) |
556 | | - }, |
557 | | - |
558 | | - stylize() { |
559 | | - if (!this.styles) { |
560 | | - this.styles = dom.create.style(null, { id: `${this.class}-styles` }) |
561 | | - document.head.append(this.styles) |
562 | | - } |
563 | | - this.styles.innerText = ( |
564 | | - `.no-user-select { |
565 | | - user-select: none ; -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none }` |
566 | | - + `.${this.class} {` // modals |
567 | | - + 'font-family: -apple-system, system-ui, BlinkMacSystemFont, Segoe UI, Roboto,' |
568 | | - + 'Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif ;' |
569 | | - + 'padding: 20px 25px 24px 25px !important ; font-size: 20px ;' |
570 | | - + `color: ${ env.ui.scheme == 'dark' ? 'white' : 'black' } !important ;` |
571 | | - + `background-image: linear-gradient(180deg, ${ |
572 | | - env.ui.scheme == 'dark' ? '#99a8a6 -200px, black 200px' : '#b6ebff -296px, white 171px' }) }` |
573 | | - + `.${this.class} [class*=modal-close-btn] {` |
574 | | - + 'position: absolute !important ; float: right ; top: 14px !important ; right: 16px !important ;' |
575 | | - + 'cursor: pointer ; width: 33px ; height: 33px ; border-radius: 20px }' |
576 | | - + `.${this.class} [class*=modal-close-btn] svg { height: 10px }` |
577 | | - + `.${this.class} [class*=modal-close-btn] path {` |
578 | | - + `${ env.ui.scheme == 'dark' ? 'stroke: white ; fill: white' : 'stroke: #9f9f9f ; fill: #9f9f9f' }}` |
579 | | - + ( env.ui.scheme == 'dark' ? // invert dark mode hover paths |
580 | | - `.${this.class} [class*=modal-close-btn]:hover path { stroke: black ; fill: black }` : '' ) |
581 | | - + `.${this.class} [class*=modal-close-btn]:hover { background-color: #f2f2f2 }` // hover underlay |
582 | | - + `.${this.class} [class*=modal-close-btn] svg { margin: 11.5px }` // center SVG for hover underlay |
583 | | - + `.${this.class} a { color: #${ env.ui.scheme == 'dark' ? '00cfff' : '1e9ebb' } !important }` |
584 | | - + `.${this.class} h2 { font-weight: bold }` |
585 | | - + `.${this.class} button {` |
586 | | - + '--btn-transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out ;' |
587 | | - + 'font-size: 14px ; text-transform: uppercase ;' // shrink/uppercase labels |
588 | | - + 'border-radius: 0 !important ;' // square borders |
589 | | - + 'transition: var(--btn-transition) ;' // smoothen hover fx |
590 | | - + '-webkit-transition: var(--btn-transition) ; -moz-transition: var(--btn-transition) ;' |
591 | | - + '-o-transition: var(--btn-transition) ; -ms-transition: var(--btn-transition) ;' |
592 | | - + 'cursor: pointer !important ;' // add finger cursor |
593 | | - + `border: 1px solid ${ env.ui.scheme == 'dark' ? 'white' : 'black' } !important ;` |
594 | | - + 'padding: 8px !important ; min-width: 102px }' // resize |
595 | | - + `.${this.class} button:hover {` // add zoom, re-scheme |
596 | | - + 'transform: scale(1.055) ; color: black !important ;' |
597 | | - + `background-color: #${ env.ui.scheme == 'dark' ? '00cfff' : '9cdaff' } !important }` |
598 | | - + ( !env.browser.isMobile ? `.${this.class} .modal-buttons { margin-left: -13px !important }` : '' ) |
599 | | - + `.about-em { color: ${ env.ui.scheme == 'dark' ? 'white' : 'green' } !important }` |
600 | | - ) |
601 | | - }, |
602 | | - |
603 | | - observeRemoval(modal, modalType, modalSubType) { // to maintain stack for proper nav |
604 | | - const modalBG = modal.parentNode |
605 | | - new MutationObserver(([mutation], obs) => { |
606 | | - mutation.removedNodes.forEach(removedNode => { if (removedNode == modalBG) { |
607 | | - if (modals.stack[0].includes(modalSubType || modalType)) { // new modal not launched so nav back |
608 | | - modals.stack.shift() // remove this modal type from stack 1st |
609 | | - const prevModalType = modals.stack[0] |
610 | | - if (prevModalType) { // open it |
611 | | - modals.stack.shift() // remove type from stack since re-added on open |
612 | | - modals.open(prevModalType) |
613 | | - } |
614 | | - } |
615 | | - obs.disconnect() |
616 | | - }}) |
617 | | - }).observe(modalBG.parentNode, { childList: true, subtree: true }) |
618 | | - }, |
619 | | - |
620 | 537 | about() { |
621 | 538 |
|
622 | 539 | // Show modal |
|
678 | 595 | return aboutModal |
679 | 596 | }, |
680 | 597 |
|
| 598 | + alert(title = '', msg = '', btns = '', checkbox = '', width = '') { // generic one from chatgpt.alert() |
| 599 | + const alertID = chatgpt.alert(title, msg, btns, checkbox, width), |
| 600 | + alert = document.getElementById(alertID).firstChild |
| 601 | + this.init(alert) // add classes + rising particles bg |
| 602 | + return alert |
| 603 | + }, |
| 604 | + |
681 | 605 | donate() { |
682 | 606 |
|
683 | 607 | // Show modal |
|
734 | 658 | return donateModal |
735 | 659 | }, |
736 | 660 |
|
| 661 | + init(modal) { |
| 662 | + if (!this.styles) this.stylize() // to init/append stylesheet |
| 663 | + modal.classList.add('no-user-select', this.class) ; modal.parentNode.classList.add(`${this.class}-bg`) |
| 664 | + dom.addRisingParticles(modal) |
| 665 | + }, |
| 666 | + |
| 667 | + observeRemoval(modal, modalType, modalSubType) { // to maintain stack for proper nav |
| 668 | + const modalBG = modal.parentNode |
| 669 | + new MutationObserver(([mutation], obs) => { |
| 670 | + mutation.removedNodes.forEach(removedNode => { if (removedNode == modalBG) { |
| 671 | + if (modals.stack[0].includes(modalSubType || modalType)) { // new modal not launched so nav back |
| 672 | + modals.stack.shift() // remove this modal type from stack 1st |
| 673 | + const prevModalType = modals.stack[0] |
| 674 | + if (prevModalType) { // open it |
| 675 | + modals.stack.shift() // remove type from stack since re-added on open |
| 676 | + modals.open(prevModalType) |
| 677 | + } |
| 678 | + } |
| 679 | + obs.disconnect() |
| 680 | + }}) |
| 681 | + }).observe(modalBG.parentNode, { childList: true, subtree: true }) |
| 682 | + }, |
| 683 | + |
| 684 | + open(modalType, modalSubType) { |
| 685 | + const modal = modalSubType ? this[modalType][modalSubType]() : this[modalType]() // show modal |
| 686 | + if (!modal) return // since no div returned |
| 687 | + this.stack.unshift(modalSubType ? `${modalType}_${modalSubType}` : modalType) // add to stack |
| 688 | + this.init(modal) // add classes + rising particles bg |
| 689 | + this.observeRemoval(modal, modalType, modalSubType) // to maintain stack for proper nav |
| 690 | + }, |
| 691 | + |
| 692 | + safeWinOpen(url) { open(url, '_blank', 'noopener') }, // to prevent backdoor vulnerabilities |
| 693 | + |
| 694 | + stylize() { |
| 695 | + if (!this.styles) { |
| 696 | + this.styles = dom.create.style(null, { id: `${this.class}-styles` }) |
| 697 | + document.head.append(this.styles) |
| 698 | + } |
| 699 | + this.styles.innerText = ( |
| 700 | + `.no-user-select { |
| 701 | + user-select: none ; -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none }` |
| 702 | + + `.${this.class} {` // modals |
| 703 | + + 'font-family: -apple-system, system-ui, BlinkMacSystemFont, Segoe UI, Roboto,' |
| 704 | + + 'Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif ;' |
| 705 | + + 'padding: 20px 25px 24px 25px !important ; font-size: 20px ;' |
| 706 | + + `color: ${ env.ui.scheme == 'dark' ? 'white' : 'black' } !important ;` |
| 707 | + + `background-image: linear-gradient(180deg, ${ |
| 708 | + env.ui.scheme == 'dark' ? '#99a8a6 -200px, black 200px' : '#b6ebff -296px, white 171px' }) }` |
| 709 | + + `.${this.class} [class*=modal-close-btn] {` |
| 710 | + + 'position: absolute !important ; float: right ; top: 14px !important ; right: 16px !important ;' |
| 711 | + + 'cursor: pointer ; width: 33px ; height: 33px ; border-radius: 20px }' |
| 712 | + + `.${this.class} [class*=modal-close-btn] svg { height: 10px }` |
| 713 | + + `.${this.class} [class*=modal-close-btn] path {` |
| 714 | + + `${ env.ui.scheme == 'dark' ? 'stroke: white ; fill: white' : 'stroke: #9f9f9f ; fill: #9f9f9f' }}` |
| 715 | + + ( env.ui.scheme == 'dark' ? // invert dark mode hover paths |
| 716 | + `.${this.class} [class*=modal-close-btn]:hover path { stroke: black ; fill: black }` : '' ) |
| 717 | + + `.${this.class} [class*=modal-close-btn]:hover { background-color: #f2f2f2 }` // hover underlay |
| 718 | + + `.${this.class} [class*=modal-close-btn] svg { margin: 11.5px }` // center SVG for hover underlay |
| 719 | + + `.${this.class} a { color: #${ env.ui.scheme == 'dark' ? '00cfff' : '1e9ebb' } !important }` |
| 720 | + + `.${this.class} h2 { font-weight: bold }` |
| 721 | + + `.${this.class} button {` |
| 722 | + + '--btn-transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out ;' |
| 723 | + + 'font-size: 14px ; text-transform: uppercase ;' // shrink/uppercase labels |
| 724 | + + 'border-radius: 0 !important ;' // square borders |
| 725 | + + 'transition: var(--btn-transition) ;' // smoothen hover fx |
| 726 | + + '-webkit-transition: var(--btn-transition) ; -moz-transition: var(--btn-transition) ;' |
| 727 | + + '-o-transition: var(--btn-transition) ; -ms-transition: var(--btn-transition) ;' |
| 728 | + + 'cursor: pointer !important ;' // add finger cursor |
| 729 | + + `border: 1px solid ${ env.ui.scheme == 'dark' ? 'white' : 'black' } !important ;` |
| 730 | + + 'padding: 8px !important ; min-width: 102px }' // resize |
| 731 | + + `.${this.class} button:hover {` // add zoom, re-scheme |
| 732 | + + 'transform: scale(1.055) ; color: black !important ;' |
| 733 | + + `background-color: #${ env.ui.scheme == 'dark' ? '00cfff' : '9cdaff' } !important }` |
| 734 | + + ( !env.browser.isMobile ? `.${this.class} .modal-buttons { margin-left: -13px !important }` : '' ) |
| 735 | + + `.about-em { color: ${ env.ui.scheme == 'dark' ? 'white' : 'green' } !important }` |
| 736 | + ) |
| 737 | + }, |
| 738 | + |
737 | 739 | update: { |
738 | 740 | width: 377, |
739 | 741 |
|
|
767 | 769 | '', '', modals.update.width |
768 | 770 | ) |
769 | 771 | } |
770 | | - }, |
771 | | - |
772 | | - safeWinOpen(url) { open(url, '_blank', 'noopener') } // to prevent backdoor vulnerabilities |
| 772 | + } |
773 | 773 | } |
774 | 774 |
|
775 | 775 | // Define UI functions |
776 | 776 |
|
| 777 | + function getScheme() { |
| 778 | + return document.documentElement.className |
| 779 | + || (window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ? 'dark' : 'light') |
| 780 | + } |
| 781 | + |
777 | 782 | function syncConfigToUI(options) { |
778 | 783 | if (options?.updatedKey == 'arDisabled') toggleAutoRefresh() |
779 | 784 | if (/arDisabled|toggleHidden/.test(options?.updatedKey)) toggles.sidebar.update.state() |
780 | 785 | menu.refresh() // prefixes/suffixes |
781 | 786 | } |
782 | 787 |
|
783 | | - function getScheme() { |
784 | | - return document.documentElement.className |
785 | | - || (window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ? 'dark' : 'light') |
786 | | - } |
787 | | - |
788 | 788 | const toggles = { |
789 | 789 |
|
790 | 790 | sidebar: { |
|
0 commit comments