Skip to content

Commit

Permalink
Stripped unneeded quotes from CSS selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed Dec 21, 2024
1 parent 09f7b76 commit cb1f51c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
34 changes: 17 additions & 17 deletions chatgpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ const chatgpt = {
+ '.chatgpt-modal .checkbox-group label {'
+ 'font-size: .7rem ; margin: -.04rem 0 0px .3rem ;'
+ `color: ${ scheme == 'dark' ? '#e1e1e1' : '#1e1e1e' }}`
+ '.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'
+ '.chatgpt-modal input[type=checkbox] { transform: scale(0.7) ;'
+ `border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' }}`
+ '.chatgpt-modal input[type="checkbox"]:checked {'
+ '.chatgpt-modal input[type=checkbox]:checked {'
+ `border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' } ;`
+ 'background-color: black ; position: inherit }'
+ '.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'
+ '.chatgpt-modal input[type=checkbox]:focus { outline: none ; box-shadow: none }'
);
}

Expand Down Expand Up @@ -455,7 +455,7 @@ const chatgpt = {
async isIdle(timeout = null) {
const obsConfig = { childList: true, subtree: true },
selectors = { msgDiv: 'div[data-message-author-role]',
replyDiv: 'div[data-message-author-role="assistant"]' };
replyDiv: 'div[data-message-author-role=assistant]' };

// Create promises
const timeoutPromise = timeout ? new Promise(resolve => setTimeout(() => resolve(false), timeout)) : null;
Expand Down Expand Up @@ -620,7 +620,7 @@ const chatgpt = {
filename = `${ parsedHtml.querySelector('title').textContent || 'ChatGPT conversation' }.html`;

// Convert relative CSS paths to absolute ones
const cssLinks = parsedHtml.querySelectorAll('link[rel="stylesheet"]');
const cssLinks = parsedHtml.querySelectorAll('link[rel=stylesheet]');
cssLinks.forEach(link => {
const href = link.getAttribute('href');
if (href?.startsWith('/')) link.setAttribute('href', 'https://chat.openai.com' + href);
Expand Down Expand Up @@ -932,7 +932,7 @@ const chatgpt = {
getLastResponse() { return chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'); },

getNewChatButton() {
return document.querySelector('button[data-testid*="new-chat-button"], button:has([d^="M15.6729"])'); },
return document.querySelector('button[data-testid*=new-chat-button], button:has([d^="M15.6729"])'); },

getNewChatLink() { return document.querySelector('nav a[href="/"]'); },
getRegenerateButton() { return document.querySelector('button:has([d^="M3.06957"])'); },
Expand All @@ -949,8 +949,8 @@ const chatgpt = {
getResponseFromAPI(chatToGet, responseToGet) { return chatgpt.response.getFromAPI(chatToGet, responseToGet); },
getResponseFromDOM(pos) { return chatgpt.response.getFromDOM(pos); },
getScrollToBottomButton() { return document.querySelector('button:has([d^="M12 21C11.7348"])'); },
getSendButton() { return document.querySelector('[data-testid="send-button"]'); },
getStopButton() { return document.querySelector('button[data-testid="stop-button"]'); },
getSendButton() { return document.querySelector('[data-testid=send-button]'); },
getStopButton() { return document.querySelector('button[data-testid=stop-button]'); },

getUserLanguage() {
return navigator.languages[0] || navigator.language || navigator.browserLanguage ||
Expand Down Expand Up @@ -1211,7 +1211,7 @@ const chatgpt = {
}

const addElementsToMenu = () => {
const optionButtons = document.querySelectorAll('a[role="menuitem"]');
const optionButtons = document.querySelectorAll('a[role=menuitem]');
let cssClasses;

for (const navLink of optionButtons)
Expand All @@ -1230,7 +1230,7 @@ const chatgpt = {
};

this.elements.push(newElement);
const menuBtn = document.querySelector('nav button[id*="headless"]');
const menuBtn = document.querySelector('nav button[id*=headless]');
if (!this.addedEvent) { // to prevent adding more than one event
menuBtn?.addEventListener('click', () => { setTimeout(addElementsToMenu, 25); });
this.addedEvent = true; }
Expand All @@ -1239,12 +1239,12 @@ const chatgpt = {
},

close() {
try { document.querySelector('nav [id*="menu-button"][aria-expanded="true"]').click(); }
try { document.querySelector('nav [id*=menu-button][aria-expanded=true]').click(); }
catch (err) { console.error(err.message); }
},

open() {
try { document.querySelector('nav [id*="menu-button"][aria-expanded="false"]').click(); }
try { document.querySelector('nav [id*=menu-button][aria-expanded=false]').click(); }
catch (err) { console.error(err.message); }
}
},
Expand Down Expand Up @@ -1518,7 +1518,7 @@ const chatgpt = {
},

getFromDOM(pos) {
const responseDivs = document.querySelectorAll('div[data-message-author-role="assistant"]'),
const responseDivs = document.querySelectorAll('div[data-message-author-role=assistant]'),
strPos = pos.toString().toLowerCase();
let response = '';
if (!responseDivs.length) return console.error('No conversation found!');
Expand Down Expand Up @@ -1825,15 +1825,15 @@ const chatgpt = {
isOff() { return !this.isOn(); },
isOn() {
const sidebar = (() => {
return chatgpt.sidebar.exists() ? document.querySelector('[class*="sidebar"]') : null; })();
return chatgpt.sidebar.exists() ? document.querySelector('[class*=sidebar]') : null; })();
if (!sidebar) { console.error('Sidebar element not found!'); return false; }
else return chatgpt.browser.isMobile() ?
document.documentElement.style.overflow == 'hidden'
: sidebar.style.visibility != 'hidden' && sidebar.style.width != '0px';
},

toggle() {
const sidebarToggle = document.querySelector('button[data-testid*="sidebar-button"]');
const sidebarToggle = document.querySelector('button[data-testid*=sidebar-button]');
if (!sidebarToggle) console.error('Sidebar toggle not found!');
sidebarToggle.click();
},
Expand Down Expand Up @@ -1943,8 +1943,8 @@ const cjsBtnActions = ['click', 'get'], cjsTargetTypes = [ 'button', 'link', 'di
for (const btnAction of cjsBtnActions) {
chatgpt[btnAction + 'Button'] = function handleButton(buttonIdentifier) {
const button = /^[.#]/.test(buttonIdentifier) ? document.querySelector(buttonIdentifier)
: /send/i.test(buttonIdentifier) ? document.querySelector('form button[class*="bottom"]')
: /scroll/i.test(buttonIdentifier) ? document.querySelector('button[class*="cursor"]')
: /send/i.test(buttonIdentifier) ? document.querySelector('form button[class*=bottom]')
: /scroll/i.test(buttonIdentifier) ? document.querySelector('button[class*=cursor]')
: (function() { // get via text content
for (const button of document.querySelectorAll('button')) { // try buttons
if (button.textContent.toLowerCase().includes(buttonIdentifier.toLowerCase())) {
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/js/min/copy-code-button.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cb1f51c

Please sign in to comment.