|
1 | 1 | // ==UserScript== |
2 | 2 | // @name ChatGPT Zero |
3 | 3 | // @namespace https://github.com/NextDev65/ |
4 | | -// @version 0.58 |
| 4 | +// @version 0.59 |
5 | 5 | // @description Enhancements for ChatGPT |
6 | 6 | // @author NextDev65 |
7 | 7 | // @downloadURL https://raw.githubusercontent.com/NextDev65/ChatGPT-0/main/ChatGPT-Zero.js |
|
506 | 506 | const checkInterval = setInterval(() => { |
507 | 507 | const nativeModelSwitchers = document.querySelectorAll('[data-testid="model-switcher-dropdown-button"]'); |
508 | 508 | let switcher = document.getElementById('chatgpt-model-switcher'); |
509 | | - |
| 509 | + const getPlusClassName = ['absolute start-1/2 flex flex-col items-center gap-2 ltr:-translate-x-1/2 rtl:translate-x-1/2', |
| 510 | + 'pointer-events-none absolute start-0 flex flex-col items-center gap-2 lg:start-1/2 ltr:-translate-x-1/2 rtl:translate-x-1/2']; |
510 | 511 | // Create switcher |
511 | 512 | if (!switcher) { |
512 | | - const getPlusClassName = 'absolute start-1/2 flex flex-col items-center gap-2 ltr:-translate-x-1/2 rtl:translate-x-1/2'; |
513 | | - |
514 | 513 | const savedModel = localStorage.getItem(PREFERRED_MODEL_KEY) || DEFAULT_MODEL; |
515 | 514 | switcher = createModelSwitcher(savedModel); |
516 | | - switcher.className = getPlusClassName; |
517 | | - |
518 | | - // move "Get Plus" button |
519 | | - let getPlus = document.getElementsByClassName(getPlusClassName)[0]; |
520 | | - //document.getElementById('page-header').childNodes[1].appendChild(getPlus); // 2nd child of page header |
521 | | - nativeModelSwitchers[0].parentNode.appendChild(getPlus); // first nativeModelSwitcher |
522 | | - getPlus.className = ''; |
523 | 515 | } |
524 | 516 | // Insert switcher next to the first visible native button |
525 | 517 | if (!switcher.parentNode) { |
526 | 518 | for (let nativeModelSwitcher of nativeModelSwitchers) { |
527 | 519 | if (nativeModelSwitcher.checkVisibility && nativeModelSwitcher.checkVisibility()) { |
528 | 520 | nativeModelSwitcher.parentNode.after(switcher); |
| 521 | + |
| 522 | + // move "Get Plus" button |
| 523 | + let getPlus = null; |
| 524 | + for (let className of getPlusClassName) { |
| 525 | + let elements = document.getElementsByClassName(className); |
| 526 | + if (elements.length > 0) { |
| 527 | + // give getPlus styling to switcher |
| 528 | + switcher.className = getPlusClassName; |
| 529 | + getPlus = elements[0]; |
| 530 | + break; |
| 531 | + } |
| 532 | + } |
| 533 | + nativeModelSwitcher.parentNode.appendChild(getPlus); |
| 534 | + getPlus.className = ''; |
529 | 535 | break; |
530 | 536 | } |
531 | 537 | } |
|
0 commit comments