// ==UserScript==
// @name Autoclear ChatGPT History
// @name:af Verwyder ChatGPT Geskiedenis 🕶️
// @name:am በተሻለ ChatGPT ጉዳዮ ማግኘት 🕶️
// @name:ar مسح تاريخ ChatGPT 🕶️
// @name:az ChatGPT Tarixini Təmizləyin 🕶️
// @name:be Ачысціць гісторыю ChatGPT 🕶️
// @name:bem Lekeni ChatGPT History 🕶️
// @name:bg Изчистете ChatGPT История 🕶️
// @name:bn চ্যাটজিপিটি ইতিহাস মুছে ফেলুন 🕶️
// @name:bo ChatGPT སྐད་དོན་ཚར་བཟོ། 🕶️
// @name:bs Obriši ChatGPT historiju 🕶️
// @name:ca Esborra l'historial de ChatGPT 🕶️
// @name:ceb Autoclear ChatGPT Kasaysayan 🕶️
// @name:ckb بسڕەوەی مێژووی ChatGPT 🕶️
// @name:cs Vymazat ChatGPT Historii 🕶️
// @name:cy Clirio Hanes ChatGPT 🕶️
// @name:da Ryd ChatGPT Historik 🕶️
// @name:de ChatGPT-Verlauf löschen 🕶️
// @name:dv ChatGPT ހިސްތުކުރުން ފުހެވޭނީ 🕶️
// @name:dz ChatGPT སྐད་ཆ་འབད་བཅུ་ 🕶️
// @name:el Διαγραφή Ιστορικού ChatGPT 🕶️
// @name:eo Forviŝi ChatGPT Historion 🕶️
// @name:es Borrar Historial de ChatGPT 🕶️
// @name:et Kustuta ChatGPT Ajalugu 🕶️
// @name:eu Ezabatu ChatGPT Historia 🕶️
// @name:fa پاک کردن تاریخچه ChatGPT 🕶️
// @name:fi Poista ChatGPT:n historia 🕶️
// @name:fo Strika ChatGPT Søgu 🕶️
// @name:fr Effacer l'historique de ChatGPT 🕶️
// @name:fr-CA Effacer l'historique de ChatGPT 🕶️
// @name:gd Lùghdaich Eachdraidh ChatGPT 🕶️
// @name:gl Limpar Historial de ChatGPT 🕶️
// @name:gu આપો ChatGPT ઇતિહાસ 🕶️
// @name:haw Kāpaki Kākoʻo i ka Moʻolelo o ChatGPT 🕶️
// @name:he מחק את היסטוריית ChatGPT 🕶️
// @name:hi ChatGPT इतिहास को हटाएं 🕶️
// @name:hr Izbriši ChatGPT Povijest 🕶️
// @name:ht Efase ChatGPT Istwa 🕶️
// @name:hu ChatGPT Előzmények Törlése 🕶️
// @name:hy Ջնջել ChatGPT-ի Պատմությունը 🕶️
// @name:id Hapus Riwayat ChatGPT 🕶️
// @name:is Eyða ChatGPT Saga 🕶️
// @name:it Cancella Cronologia ChatGPT 🕶️
// @name:ja ChatGPT の履歴を削除する 🕶️
// @name:jv Hapus Riwayat ChatGPT 🕶️
// @name:ka ChatGPT-ის ისტორიის გასუფთავება 🕶️
// @name:kab Sken ChatGPT Tamɣarit 🕶️
// @name:kk ChatGPT Тарихын Жою 🕶️
// @name:km លុបប្រវត្តិសាស្រ្ត ChatGPT 🕶️
// @name:kn ChatGPT ಇತಿಹಾಸವನ್ನು ಅಳಿಸಿ 🕶️
// @name:ko ChatGPT 기록 지우기 🕶️
// @name:ku Çavkaniya ChatGPTê Paqij bike 🕶️
// @name:ky ChatGPT Тарыхын Жок Кыл 🕶️
// @name:la Eximitte Historiam ChatGPT 🕶️
// @name:lb Läschen ChatGPT Geschicht 🕶️
// @name:lo ລຶບບັນດາຕິນມັກສະບັບ ChatGPT 🕶️
// @name:lt Išvalyti ChatGPT Istoriją 🕶️
// @name:lv Notīrīt ChatGPT Vēsturi 🕶️
// @name:mg Mamafa ny ChatGPT Historique 🕶️
// @name:mi Muku ChatGPT Hītori 🕶️
// @name:mk Избриши го Историјата на ChatGPT 🕶️
// @name:ml ചാറ്റ്ജിപിടി ചരിത്രം മായ്ക്കുക 🕶️
// @name:mn ChatGPT Түүхийг устгах 🕶️
// @name:ms Padam Sejarah ChatGPT 🕶️
// @name:mt Ħassar It-Twaħħil ChatGPT 🕶️
// @name:my ဆက်လက် ChatGPT သမိုင်းကို ဖျက်ပစ်နေပါသည် 🕶️
// @name:ne Autoclear ChatGPT इतिहास 🕶️
// @name:nl Wis ChatGPT Geschiedenis 🕶️
// @name:no Autoclear ChatGPT Historie 🕶️
// @name:ny Tikalonso ChatGPT Chisulo 🕶️
// @name:pa ਚੈਟਜੀਪੀਟੀ ਇਤਿਹਾਸ ਮਿਟਾਓ 🕶️
// @name:pap Bula Historia di ChatGPT 🕶️
// @name:pl Wyczyść Historię ChatGPT 🕶️
// @name:ps د ChatGPT د تاریخ پاکول 🕶️
// @name:pt Limpar Histórico do ChatGPT 🕶️
// @name:pt-BR Limpar Histórico do ChatGPT 🕶️
// @name:rn Kwihesha ChatGPT Byinshi 🕶️
// @name:ro Ștergeți Istoricul ChatGPT 🕶️
// @name:ru Очистить Историю ChatGPT 🕶️
// @name:rw Fata ChatGPT Itangazo 🕶️
// @name:sg Mbama ChatGPT Makumbe 🕶️
// @name:si නැවත සංවේදී ChatGPT ඉතිරිකිරීම 🕶️
// @name:sk Vymažte ChatGPT Históriu 🕶️
// @name:sl Počisti Zgodovino ChatGPT 🕶️
// @name:sm Masi ChatGPT Faʻaipoipoga 🕶️
// @name:sn Tirisa ChatGPT Chiremba 🕶️
// @name:so Ka Saar Tareenka ChatGPT 🕶️
// @name:sr Обриши историју ChatGPT-а 🕶️
// @name:sv Rensa ChatGPT Historik 🕶️
// @name:sw Futa Historia ya ChatGPT 🕶️
// @name:ta தானாகவே அழிக்க சேட்ஜிபிடி வரலாற்றை 🕶️
// @name:te ChatGPT చరిత్రను తొలగించు 🕶️
// @name:tg Тозаиши корҳои ChatGPT 🕶️
// @name:th ล้างประวัติศาสตร์ ChatGPT 🕶️
// @name:ti ምርግጋጽ ChatGPT ኣጸዓይ ፈጥር 🕶️
// @name:tk ChatGPT Tarixini Aýyr 🕶️
// @name:tn Futa ChatGPT Tlhahlobo 🕶️
// @name:to Fakatonu ChatGPT History 🕶️
// @name:tpi Kolim ChatGPT Stori 🕶️
// @name:tr ChatGPT Geçmişi Temizle 🕶️
// @name:uk Очистити Історію ChatGPT 🕶️
// @name:ur ChatGPT کی تاریخ صاف کریں 🕶️
// @name:uz ChatGPT Tarixini Tozalash 🕶️
// @name:vi Xóa Lịch Sử ChatGPT 🕶️
// @name:xh Qhipha ChatGPT Isaziso 🕶️
// @name:yi ויסמעקן טשאַטגפּט געשיכטע 🕶️
// @name:zh 自动清除 ChatGPT 历史记录 🕶️
// @name:zh-CN 自动清除 ChatGPT 历史记录 🕶️
// @name:zh-HK 自动清除 ChatGPT 历史记录 🕶️
// @name:zh-SG 自动清除 ChatGPT 历史记录 🕶️
// @name:zh-TW 自动清除 ChatGPT 历史记录 🕶️
// @name:zu Sula ChatGPT Isifundo 🕶️
// @description Auto-clears chat history when visiting chatgpt.com
// @description:af Skoonmaak Chat Geskiedenis wanneer jy chatgpt.com besoek
// @description:am የ chatgpt.com ጸሃይ ታክሲን በማግኘት ታከለው
// @description:ar يقوم تلقائيًا بمسح سجل المحادثات عند زيارة chatgpt.com
// @description:az chatgpt.com-a gedəndə avtomatik olaraq söhbət tarixini təmizləyir
// @description:be Аўтаматычна ачышчае гісторыю чата пры наведванні chatgpt.com
// @description:bem Chibwezache Mphindi Zochitika Pamene Kumatemba chatgpt.com
// @description:bg Автоматично изчиства чат историята при посещение на chatgpt.com
// @description:bn যখন chatgpt.com পরিদর্শন করা হলে অটোমেটিকভাবে চ্যাট ইতিহাস মুছে ফেলে
// @description:bo དཔེར་ན་ chatgpt.com འགྲེལ་བཤད་འདི་ལུ་ སྤྱོད་ཡོད་མི་འདི་བལྟ་མི་བཟོ།
// @description:bs Automatski briše istoriju chata prilikom posjete chatgpt.com
// @description:ca S'elimina automàticament l'historial de xats en visitar chatgpt.com
// @description:ceb Automatic gidut-ana sa kasaysayan sa chat sa pagbisita sa chatgpt.com
// @description:ckb دهستکاریکردنی مێژووی گفتوگۆکان خۆکارانه بۆ سەردانی chatgpt.com
// @description:cs Automaticky vymaže historii chatu při návštěvě chatgpt.com
// @description:cy Mae'n glirio hanes sgwrs yn awtomatig wrth ymweld â chatgpt.com
// @description:da Renser automatisk chatloggen ved besøg på chatgpt.com
// @description:de Löscht den Chatverlauf automatisch beim Besuch von chatgpt.com
// @description:dv chatgpt.com އެކައުންމަދުގެ ޗެކުމު ހުރިހައްދަވާނެ ޗައިންކުރޭ
// @description:dz འཛུགས་མིག་འདི་ལུ་ chatgpt.com འགྲེལ་བཤད་རོགས་བསྐྱེད་ཡོད།
// @description:el Αυτόματη διαγραφή ιστορικού συνομιλίας κατά την επίσκεψη στο chatgpt.com
// @description:eo Memorigo de la babilado aŭtomate malaperas dum vizito ĉe chatgpt.com
// @description:es Borra automáticamente el historial de chat al visitar chatgpt.com
// @description:et Kustutab automaatselt vestluse ajaloo, kui külastate saiti chatgpt.com
// @description:eu Berezgaitasunez ezabatzen du txataren historia chatgpt.com bisitatzen denean
// @description:fa پاک کردن خودکار تاریخچه چت در هنگام بازدید از chatgpt.com
// @description:fi Poistaa keskusteluhistorian automaattisesti käydessä chatgpt.comissa
// @description:fo Auto-rensar spjall søguna tá tú vitjar chatgpt.com
// @description:fr Efface automatiquement l'historique des discussions lors de la visite de chatgpt.com
// @description:fr-CA Efface automatiquement l'historique des discussions lors de la visite de chatgpt.com
// @description:gd Thoir aire bheagachaidh air eachdraidh na còmhraidh nuair a tha thu a' tadhal air chatgpt.com
// @description:gl Limpa automáticamente o historial do chat ao visitar chatgpt.com
// @description:gu chatgpt.com મુકે છે નાતીજે જ્ઞાનવર્ધક ચેટ નો ઇતિહાસ
// @description:haw Mālama haku ʻinoʻino pāhana hoʻohānau mai ana i chatgpt.com
// @description:he מנקה באופן אוטומטי את היסטוריית הצ'אט בעת ביקור ב-chatgpt.com
// @description:hi chatgpt.com पर आवर्तित होने पर चैट इतिहास को स्वचालित रूप से साफ करता है
// @description:hr Automatski briše povijest razgovora prilikom posjeta chatgpt.com
// @description:ht Auto-efase istwa chat la lè vizite chatgpt.com
// @description:hu Automatikusan törli a csevegés előzményeit a chatgpt.com látogatásakor
// @description:hy Պատմությունը ինքնաշխատանքային մաքրում է chatgpt.com այցելելուն դեպի
// @description:id Menghapus otomatis riwayat obrolan saat mengunjungi chatgpt.com
// @description:is Hreinsar sjálfvirkt spjallshönnun þegar heimsókn er gerð á chatgpt.com
// @description:it Cancella automaticamente la cronologia della chat durante la visita a chatgpt.com
// @description:ja chatgpt.com を访れる际に自动的にチャット履歴を消去します
// @description:jv Otomatis ngapus riwayat obrolan nalika ngunjungi chatgpt.com
// @description:ka თავისითად წაშლის ჩათის ისტორიას chatgpt.com-ზე მომსახურების დროს
// @description:kab Ireɣsan Ayren Tisstrir ChatGPT I yur-s achatgpt.com
// @description:kk chatgpt.com-ды көруге бастап автоматты түрде чат тарихын жою
// @description:km លុបសេវាកម្មប្រវត្តិការណ៍ជជែកពីព័ត៌មានមនុស្សកន្លងទៅកាន់ chatgpt.com
// @description:kn chatgpt.com ಸಂದರ್ಶಿಸಿದಾಗ ಸ್ವಯಂಚಾಲಿತವಾಗಿ ಚಾಟ್ ಇತಿಹಾಸವನ್ನು ಅಳಿಸುತ್ತದೆ
// @description:ko chatgpt.com 방문 시 채팅 기록을 자동으로 지웁니다
// @description:ku Çêkirina historyaya chatê di hembêzkirina chatgpt.com de
// @description:ky chatgpt.com барысында түр кат жазмаларын автоматтык түрде жок этиш
// @description:la Automate chat historia clearum cum chatgpt.com adibvisam
// @description:lb Läscht automatesch d'Chat-Geschicht wéini een chatgpt.com besicht
// @description:lo ລຶບປະວັດການສົນທະນາໃນຖ້າເຂົ້າຊົມ chatgpt.com
// @description:lt Automatiškai išvalo pokalbių istoriją apsilankius chatgpt.com
// @description:lv Automātiski notīra čata vēsturi, apmeklējot chatgpt.com
// @description:mg Mamafa tsy ampy lalao ny tetikasa vaovao rehefa mitovy amin'ny chatgpt.com
// @description:mi Auto-kōmata e whakakore i te hītori whakawhiti kōrero i te toro ki te chatgpt.com
// @description:mk Автоматски брише историја на разговорот при посета на chatgpt.com
// @description:ml chatgpt.com സന്ദർശിക്കുമ്പോൾ ചാറ്റ് ചരിത്രം ഓട്ടോ-പിന്തുണച്ച് അഴിച്ചുവയ്ക്കുന്നു
// @description:mn chatgpt.com-оос орж ирэх үед чатын түүхийг автоматаар цэвэрлэнэ
// @description:ms Membersihkan sejarah perbualan secara automatik apabila melawat chatgpt.com
// @description:mt Jħassar awtomatikament il-kronoloġija tal-chat meta żżur chatgpt.com
// @description:my chatgpt.com ကိုသွားဖို့အတွက် စကားဝှက်မှတ်တမ်းကို အလိုလိုရွေးချယ်ရန် အလွယ်တကူပြန်ဖွင့်ထားသည်
// @description:ne chatgpt.com मा आएकोमा च्याट इतिहास स्वचालित रूपमा हटाउँछ
// @description:nl Wis automatisch de chatgeschiedenis bij een bezoek aan chatgpt.com
// @description:no Sletter automatisk samtalehistorikk ved besøk på chatgpt.com
// @description:ny Kwatsa makina m'chipatala cha chat pamene kuwona chatgpt.com
// @description:pa chatgpt.com ਦੇ ਦੌਰਾਨ ਚੈਟ ਇਤਿਹਾਸ ਆਟੋਮੈਟਿਕ ਕਲੀਅਰ ਹੋ ਜਾਂਦਾ ਹੈ
// @description:pap Limpieza automático di historial di chat na bishita chatgpt.com
// @description:pl Automatycznie czyści historię czatu podczas odwiedzania chatgpt.com
// @description:ps خودکار تاریخچه چت پاک کول په chatgpt.com کښې
// @description:pt Limpa automaticamente o histórico de bate-papo ao visitar chatgpt.com
// @description:pt-BR Limpa automaticamente o histórico de bate-papo ao visitar chatgpt.com
// @description:rn Guteza inkuru y'ikarita y'imibare igihe utanga chatgpt.com
// @description:ro Șterge automat istoricul chat-ului la vizitarea chatgpt.com
// @description:ru Автоматически очищает историю чата при посещении chatgpt.com
// @description:rw Inyunganira amakuru ya chat inyuma yuko umaze guhamagara chatgpt.com
// @description:sg Auto-kura kolibatalu ya misamba wakari karika kutɔbɔ chatgpt.com
// @description:si chatgpt.com වෙත පැය සඳහා ස්වයංක්රීයතාවයින් චැට් ඉතිරිකිරීම මකා දැමුම
// @description:sk Automaticky vymazáva históriu chatu pri návšteve chatgpt.com
// @description:sl Samodejno izbriše zgodovino klepeta ob obisku spletnega mesta chatgpt.com
// @description:sm Automa i le malologa o le sootaga i luma i le chatgpt.com
// @description:sn Inongorora chat history chinayo ipapo uchi chiri kunochinja chatgpt.com
// @description:so Wax ka qaad chatka markii la booqdo chatgpt.com
// @description:sr Аутоматски брише историју чата при посети chatgpt.com
// @description:sv Rensar automatiskt chattens historik vid besök på chatgpt.com
// @description:sw Inaondoa historia ya mazungumzo moja kwa moja wakati wa kutembelea chatgpt.com
// @description:ta chatgpt.com அடுத்தடுத்தப்படும் நேரத்தில் உரையாடல் வரலாறை தானியங்கே நீக்குகிறது
// @description:te chatgpt.com సందర్శించినప్పుడు స్వయంచాలకంగా చాట్ చరిత్రను తొలగిస్తుంది
// @description:tg Тарихи чатро худкор ҷоба кунед, ки chatgpt.com равед
// @description:th ล้างประวัติการสนทนาโดยอัตโนมัติเมื่อเข้าชม chatgpt.com
// @description:ti ኮምፕዩተር እየጠበቀ ጊዜ chatgpt.com የተሰኘውን ችግርን አስፈልጋል
// @description:tk chatgpt.com-a ugradykda çat görnüşini awtomatiki biçimde boşaltýar
// @description:tn Emucisha chat chinyakanyaka nga uwonawo chatgpt.com
// @description:to 'Oku fa'a kovi 'e he ngaahi sipoti fakamatala 'i he falelotu ki he chatgpt.com
// @description:tpi Autometik klia chat histeri long bisitim long chatgpt.com
// @description:tr chatgpt.com'u ziyaret ettiğinizde sohbet geçmişini otomatik olarak temizler
// @description:uk Автоматично очищає історію чату при відвідуванні chatgpt.com
// @description:ur chatgpt.com کے دورے پر چیٹ تاریخ خودکار طور پر صاف کرتا ہے
// @description:uz chatgpt.com saytini tashrif buyurganda chat tarixini avtomatik ravishda o'chiradi
// @description:vi Xóa lịch sử trò chuyện tự động khi ghé thăm chatgpt.com
// @description:xh Ingqalasela ihisitela le-chat uma uzithola chatgpt.com
// @description:yi רומט די פֿונען דער שאַט היסטאָריע ביי בעזוך בקוקן chatgpt.com
// @description:zh 访问 chatgpt.com 时自动清除聊天记录
// @description:zh-CN 访问 chatgpt.com 时自动清除聊天记录
// @description:zh-HK 访问 chatgpt.com 时自动清除聊天记录
// @description:zh-SG 访问 chatgpt.com 时自动清除聊天记录
// @description:zh-TW 访问 chatgpt.com 时自动清除聊天记录
// @description:zu Ziba itshala lokucabanga okuzoshintshwa ngokuzenzakalelayo uma ukubuka chatgpt.com
// @author Adam Lui
// @namespace https://github.com/adamlui
// @version 2024.10.20.2
// @license MIT
// @icon https://media.autoclearchatgpt.com/images/icons/openai/black/icon48.png?a8868ef
// @icon64 https://media.autoclearchatgpt.com/images/icons/openai/black/icon64.png?a8868ef
// @compatible chrome
// @compatible edge
// @compatible firefox
// @compatible opera
// @compatible brave
// @compatible vivaldi
// @compatible librewolf
// @compatible ghost
// @compatible qq
// @match *://chatgpt.com/*
// @match *://chat.openai.com/*
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.5/dist/chatgpt.min.js#sha256-rfC4kk8q0byrafp7X0Qf9vaa3JNvkHRwNnUt6uL2hUE=
// @connect cdn.jsdelivr.net
// @connect update.greasyfork.org
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_xmlhttpRequest
// @grant GM.xmlHttpRequest
// @noframes
// @homepageURL https://www.autoclearchatgpt.com
// @supportURL https://support.autoclearchatgpt.com
// @contributionURL https://github.com/sponsors/adamlui
// ==/UserScript==
// Documentation: https://docs.autoclearchatgpt.com
// NOTE: This script relies on the powerful chatgpt.js library @ https://chatgpt.js.org © 2023–2024 KudoAI & contributors under the MIT license.
(async () => {
// Init ENV vars
const env = {
browser: { isMobile: chatgpt.browser.isMobile(), isFF: chatgpt.browser.isFirefox() },
scriptManager: (() => { try { return GM_info.scriptHandler } catch (err) { return 'unknown' }})()
}
const xhr = env.scriptManager == 'OrangeMonkey' ? GM_xmlhttpRequest : GM.xmlHttpRequest
// Init APP info
const app = { configKeyPrefix: 'autoclearChatGPThistory', latestAssetCommitHash: 'a223559' },
assetHostURL = `https://cdn.jsdelivr.net/gh/adamlui/autoclear-chatgpt-history@${app.latestAssetCommitHash}`
Object.assign(app, await new Promise(resolve => xhr({
method: 'GET', url: `${assetHostURL}/app.json`,
onload: resp => resolve(JSON.parse(resp.responseText))
})))
app.urls.update = app.urls.greasyFork.replace('https://', 'https://update.')
.replace(/(\d+)-?([a-zA-Z-]*)$/, (_, id, name) => `${id}/${ name || 'script' }.meta.js`)
// Init CONFIG
const config = { userLanguage: chatgpt.getUserLanguage() }
const settings = {
load(...keys) {
if (Array.isArray(keys[0])) keys = keys[0] // use 1st array arg, else all comma-separated ones
keys.forEach(key => config[key] = GM_getValue(app.configKeyPrefix + '_' + key, false))
},
save(key, value) { GM_setValue(app.configKeyPrefix + '_' + key, value) ; config[key] = value }
} ; settings.load('autoclear', 'buttonHidden', 'notifDisabled', 'toggleHidden')
// Init app MESSAGES
app.msgs = {
appName: app.name,
appAuthor: app.author.name,
appDesc: 'Auto-clears chat history when visiting chatgpt.com',
menuLabel_autoClear: 'Autoclear Chats',
menuLabel_toggleVis: 'Toggle Visibility',
menuLabel_modeNotifs: 'Mode Notifications',
menuLabel_about: 'About',
menuLabel_donate: 'Please send a donation',
about_version: 'Version',
about_poweredBy: 'Powered by',
about_sourceCode: 'Source code',
mode_autoClear: 'Auto-Clear',
alert_choosePlatform: 'Choose a platform',
alert_updateAvail: 'Update available',
alert_newerVer: 'An update to',
alert_isAvail: 'is available',
alert_upToDate: 'Up-to-date',
alert_isUpToDate: 'is up-to-date',
alert_showYourSupport: 'Show your support',
alert_isOSS: 'is open-source software built & maintained for free through 100% volunteer efforts',
alert_despiteAffliction: 'Despite being severely afflicted by',
alert_longCOVID: 'long COVID',
alert_since2020: 'since 2020',
alert_byDonatingResults: 'by donating, you help me to continue improving, fixing bugs, adding new features, and making the software even better',
alert_yourContrib: 'Your contribution',
alert_noMatterSize: 'no matter the size',
alert_directlySupports: 'directly supports my unpaid efforts to ensure this project remains free and open for all to use',
alert_tyForSupport: 'Thank you for your support',
alert_author: 'author',
btnLabel_moreApps: 'More ChatGPT Apps',
btnLabel_rateUs: 'Rate Us',
btnLabel_getSupport: 'Get Support',
btnLabel_updateCheck: 'Check for Updates',
btnLabel_update: 'Update',
btnLabel_dismiss: 'Dismiss',
link_viewChanges: 'View changes',
state_enabled: 'enabled',
state_disabled: 'disabled',
state_on: 'on',
state_off: 'off'
}
if (!config.userLanguage.startsWith('en')) { // localize msgs for non-English users
const localizedMsgs = await new Promise(resolve => {
const msgHostDir = assetHostURL + '/greasemonkey/_locales/',
msgLocaleDir = ( config.userLanguage ? config.userLanguage.replace('-', '_') : 'en' ) + '/'
let msgHref = msgHostDir + msgLocaleDir + 'messages.json', msgXHRtries = 0
function fetchMsgs() { xhr({ method: 'GET', url: msgHref, onload: handleMsgs })}
function handleMsgs(resp) {
try { // to return localized messages.json
const msgs = JSON.parse(resp.responseText), flatMsgs = {}
for (const key in msgs) // remove need to ref nested keys
if (typeof msgs[key] == 'object' && 'message' in msgs[key])
flatMsgs[key] = msgs[key].message
resolve(flatMsgs)
} catch (err) { // if bad response
msgXHRtries++ ; if (msgXHRtries == 3) return resolve({}) // try up to 3X (original/region-stripped/EN) only
msgHref = config.userLanguage.includes('-') && msgXHRtries == 1 ? // if regional lang on 1st try...
msgHref.replace(/([^_]+_[^_]+)_[^/]*(\/.*)/, '$1$2') // ...strip region before retrying
: ( msgHostDir + 'en/messages.json' ) // else use default English messages
fetchMsgs()
}
}
fetchMsgs()
})
Object.assign(app.msgs, localizedMsgs)
}
// Define MENU functions
const menu = {
ids: [], state: {
symbols: ['❌', '✔️'], separator: env.scriptManager == 'Tampermonkey' ? ' — ' : ': ',
words: [app.msgs.state_off.toUpperCase(), app.msgs.state_on.toUpperCase()]
},
register() {
// Add Autoclear Chats toggle
const acLabel = menu.state.symbols[+config.autoclear] + ' '
+ ( app.msgs.menuLabel_autoClear )
+ menu.state.separator + menu.state.words[+config.autoclear]
menu.ids.push(GM_registerMenuCommand(acLabel, () => {
document.getElementById('autoclear-toggle-label').click()
}))
// Add Toggle Visibility toggle
const tvLabel = menu.state.symbols[+!config.toggleHidden] + ' '
+ ( app.msgs.menuLabel_toggleVis )
+ menu.state.separator + menu.state.words[+!config.toggleHidden]
menu.ids.push(GM_registerMenuCommand(tvLabel, () => {
settings.save('toggleHidden', !config.toggleHidden)
navToggleDiv.style.display = config.toggleHidden ? 'none' : 'flex' // toggle visibility
notify(`${app.msgs.menuLabel_toggleVis}: ${menu.state.words[+!config.toggleHidden]}`)
menu.refresh()
}))
// Add Mode Notiications toggle
const mnLabel = menu.state.symbols[+!config.notifDisabled] + ' '
+ ( app.msgs.menuLabel_modeNotifs )
+ menu.state.separator + menu.state.words[+!config.notifDisabled]
menu.ids.push(GM_registerMenuCommand(mnLabel, () => {
settings.save('notifDisabled', !config.notifDisabled)
notify(`${app.msgs.menuLabel_modeNotifs}: ${menu.state.words[+!config.notifDisabled]}`)
menu.refresh()
}))
// Add About entry
const aboutLabel = `💡 ${app.msgs.menuLabel_about} ${app.msgs.appName}`
menu.ids.push(GM_registerMenuCommand(aboutLabel, modals.about.show))
// Add Donate entry
const donateLabel = `💖 ${app.msgs.menuLabel_donate}`
menu.ids.push(GM_registerMenuCommand(donateLabel, modals.donate.show))
},
refresh() {
if (env.scriptManager == 'OrangeMonkey') return
for (const id of menu.ids) { GM_unregisterMenuCommand(id) } menu.register()
}
}
function updateCheck() {
// Fetch latest meta
const currentVer = GM_info.script.version
xhr({
method: 'GET', url: app.urls.update + '?t=' + Date.now(),
headers: { 'Cache-Control': 'no-cache' },
onload: response => { const updateAlertWidth = 377
// Compare versions
const latestVer = /@version +(.*)/.exec(response.responseText)[1]
for (let i = 0 ; i < 4 ; i++) { // loop thru subver's
const currentSubVer = parseInt(currentVer.split('.')[i], 10) || 0,
latestSubVer = parseInt(latestVer.split('.')[i], 10) || 0
if (currentSubVer > latestSubVer) break // out of comparison since not outdated
else if (latestSubVer > currentSubVer) { // if outdated
// Alert to update
const updateModalID = siteAlert(`🚀 ${app.msgs.alert_updateAvail}!`, // title
`${app.msgs.alert_newerVer} ${app.msgs.appName} `
+ `(v${latestVer}) ${app.msgs.alert_isAvail}! `
+ '<a target="_blank" rel="noopener" style="font-size: 0.7rem" '
+ 'href="' + app.urls.gitHub + '/commits/main/greasemonkey/'
+ app.urls.update.replace(/.*\/(.*)meta\.js/, '$1user.js') + '"'
+ `> ${app.msgs.link_viewChanges}</a>`,
function update() { // button
modals.safeWinOpen(app.urls.update.replace('meta.js', 'user.js') + '?t=' + Date.now())
}, '', updateAlertWidth
)
// Localize button labels if needed
if (!config.userLanguage.startsWith('en')) {
const updateAlert = document.querySelector(`[id="${updateModalID}"]`),
updateBtns = updateAlert.querySelectorAll('button')
updateBtns[1].textContent = app.msgs.btnLabel_update
updateBtns[0].textContent = app.msgs.btnLabel_dismiss
}
return
}}
// Alert to no update, return to About modal
siteAlert(`${app.msgs.alert_upToDate}!`, // title
`${app.msgs.appName} (v${currentVer}) ${app.msgs.alert_isUpToDate}!`, // msg
'', '', updateAlertWidth
)
modals.about.show()
}})}
// Define FEEDBACK functions
function notify(msg, pos = '', notifDuration = '', shadow = '') {
if (config.notifDisabled && !msg.includes(app.msgs.menuLabel_modeNotifs)) return
// Strip state word to append colored one later
const foundState = menu.state.words.find(word => msg.includes(word))
if (foundState) msg = msg.replace(foundState, '')
// Show notification
chatgpt.notify(`${app.symbol} ${msg}`, pos, notifDuration, shadow || chatgpt.isDarkMode() ? '' : 'shadow')
const notif = document.querySelector('.chatgpt-notif:last-child')
// Append styled state word
if (foundState) {
const styledState = document.createElement('span')
styledState.style.cssText = `color: ${
foundState == menu.state.words[0] ? '#ef4848 ; text-shadow: rgba(255, 169, 225, 0.44) 2px 1px 5px'
: '#5cef48 ; text-shadow: rgba(255, 250, 169, 0.38) 2px 1px 5px' }`
styledState.append(foundState) ; notif.append(styledState)
}
}
function siteAlert(title = '', msg = '', btns = '', checkbox = '', width = '') {
return chatgpt.alert(title, msg, btns, checkbox, width )}
// Define MODAL functions
const modals = {
stack: [],
about: {
show() {
modals.stack.unshift('about') ; modals.stack = [...new Set(modals.stack)] // track for nav
// Init data/styles
const chatgptJSver = (/chatgpt-([\d.]+)\.min/.exec(GM_info.script.header) || [null, ''])[1],
headingStyle = 'font-size: 1.15rem',
pStyle = 'position: relative ; left: 3px',
pBrStyle = 'position: relative ; left: 4px ',
aStyle = 'color: ' + ( chatgpt.isDarkMode() ? '#c67afb' : '#8325c4' ) // purple
// Show alert
const aboutModalID = siteAlert(
app.msgs.appName, // title
`<span style="${headingStyle}"><b>🏷️ <i>${app.msgs.about_version}</i></b>: </span>`
+ `<span style="${pStyle}">${GM_info.script.version}</span>\n`
+ `<span style="${headingStyle}"><b>⚡ <i>${app.msgs.about_poweredBy}</i></b>: </span>`
+ `<span style="${pStyle}"><a style="${aStyle}" href="${app.urls.chatgptJS}" target="_blank" rel="noopener">`
+ 'chatgpt.js</a>' + ( chatgptJSver ? ( ' v' + chatgptJSver ) : '' ) + '</span>\n'
+ `<span style="${headingStyle}"><b>📜 <i>${app.msgs.about_sourceCode}</i></b>:</span>\n`
+ `<span style="${pBrStyle}"><a href="${app.urls.gitHub}" target="_blank" rel="nopener">`
+ app.urls.gitHub + '</a></span>',
[ // buttons
function checkForUpdates() { updateCheck() },
function getSupport() { modals.safeWinOpen(app.urls.support) },
function rateUs() { modals.safeWinOpen(app.urls.review.greasyFork) },
function moreChatGPTapps() { modals.safeWinOpen(app.urls.relatedApps) }
], '', 478 // set width
)
// Re-format buttons to include emoji + localized label + hide Dismiss button
for (const button of document.getElementById(aboutModalID).querySelectorAll('button')) {
if (/updates/i.test(button.textContent)) button.textContent = (
'🚀 ' + ( app.msgs.btnLabel_updateCheck ))
else if (/support/i.test(button.textContent)) button.textContent = (
'🧠 ' + ( app.msgs.btnLabel_getSupport ))
else if (/rate/i.test(button.textContent)) button.textContent = (
'⭐ ' + ( app.msgs.btnLabel_rateUs ))
else if (/apps/i.test(button.textContent)) button.textContent = (
'🤖 ' + ( app.msgs.btnLabel_moreApps ))
else button.style.display = 'none' // hide Dismiss button
}
}
},
donate: {
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(
`💖 ${app.msgs.alert_showYourSupport}`, // title
`<p>${app.msgs.appName} ${app.msgs.alert_isOSS}.</p>`
+ `<p>${app.msgs.alert_despiteAffliction} `
+ `<a target="_blank" rel="noopener" href="${modals.donate.longCOVIDwikiLink}">${app.msgs.alert_longCOVID}</a> `
+ `${app.msgs.alert_since2020}, ${app.msgs.alert_byDonatingResults}.</p>`
+ `<p>${app.msgs.alert_yourContrib}, <b>${app.msgs.alert_noMatterSize}</b>, ${app.msgs.alert_directlySupports}.</p>`
+ `<p>${app.msgs.alert_tyForSupport}!</p>`
+ `<img src="https://cdn.jsdelivr.net/gh/adamlui/adamlui/images/siggie/${ chatgpt.isDarkMode() ? 'white' : 'black' }.png"`
+ ' style="height: 54px ; margin: 5px 0 -2px 5px"></img>'
+ `<p>—<b><a target="_blank" rel="noopener" href="${app.author.url}">${app.msgs.appAuthor}</a></b>, ${app.msgs.alert_author}</p>`,
[ // 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 rateUs() { modals.safeWinOpen(app.urls.review.greasyFork) }
], '', 478 // set width
)
// Format text
const donateModal = document.getElementById(donateModalID)
donateModal.querySelectorAll('p').forEach(p => // v-pad text, shrink line height
p.style.cssText = 'padding: 8px 0 ; line-height: 20px')
// Format buttons
const btns = donateModal.querySelectorAll('button')
btns.forEach((btn, idx) => {
if (idx == 0) btn.style.display = 'none' // hide Dismiss button
else {
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
}
})
}
},
safeWinOpen(url) { open(url, '_blank', 'noopener') } // to prevent backdoor vulnerabilities
}
// Define UI functions
const navToggle = {
insert() {
// Insert toggle
const toggleParent = document.querySelector('nav')
if (!toggleParent.contains(navToggleDiv))
toggleParent.insertBefore(navToggleDiv, toggleParent.children[1])
// Tweak styles
const knobSpan = document.getElementById('autoclear-toggle-knob-span'),
navicon = document.getElementById('autoclear-toggle-navicon')
navToggleDiv.style.flexGrow = 'unset' // overcome OpenAI .grow
navToggleDiv.style.paddingLeft = '8px'
if (knobSpan) knobSpan.style.boxShadow = (
'rgba(0, 0, 0, .3) 0 1px 2px 0' + ( chatgpt.isDarkMode() ? ', rgba(0, 0, 0, .15) 0 3px 6px 2px' : '' ))
if (navicon) navicon.src = `${ // update navicon color in case scheme changed
app.urls.mediaHost}/images/icons/incognito/`
+ `${ chatgpt.isDarkMode() ? 'white' : 'black' }/icon32.png?${app.latestAssetCommitHash}`
},
update() {
if (config.toggleHidden) navToggleDiv.style.display = 'none'
else {
// Create/size/position navicon
const navicon = document.getElementById('autoclear-toggle-navicon') || document.createElement('img')
navicon.id = 'autoclear-toggle-navicon'
navicon.style.width = navicon.style.height = '1.25rem'
navicon.style.marginLeft = '2px' ; navicon.style.marginRight = '4px'
// Create/ID/disable/hide/update checkbox
const toggleInput = document.getElementById('autoclear-toggle-input') || document.createElement('input')
toggleInput.id = 'autoclear-toggle-input' ; toggleInput.type = 'checkbox' ; toggleInput.disabled = true
toggleInput.style.display = 'none' ; toggleInput.checked = config.autoclear
// Create/ID/stylize switch
const switchSpan = document.getElementById('autoclear-switch-span') || document.createElement('span')
switchSpan.id = 'autoclear-switch-span'
const switchStyles = {
position: 'relative', left: `${ env.browser.isMobile ? 211 : !ui.firstLink ? 160 : 154 }px`,
backgroundColor: toggleInput.checked ? '#ccc' : '#AD68FF', // init opposite final color
bottom: `${ !ui.firstLink ? -0.15 : env.browser.isFF ? 0.05 : 0 }em`,
width: '30px', height: '15px', '-webkit-transition': '.4s', transition: '0.4s', borderRadius: '28px'
}
Object.assign(switchSpan.style, switchStyles)
// Create/ID/stylize knob, append to switch
const knobSpan = document.getElementById('autoclear-toggle-knob-span') || document.createElement('span')
knobSpan.id = 'autoclear-toggle-knob-span'
const knobStyles = {
position: 'absolute', left: '3px', bottom: '1.25px',
width: '12px', height: '12px', content: '""', borderRadius: '28px',
transform: toggleInput.checked ? // init opposite final pos
'translateX(0)' : 'translateX(13px) translateY(0)',
backgroundColor: 'white', '-webkit-transition': '0.4s', transition: '0.4s'
}
Object.assign(knobSpan.style, knobStyles) ; switchSpan.append(knobSpan)
// Create/ID/stylize/fill label
const toggleLabel = document.getElementById('autoclear-toggle-label') || document.createElement('label')
toggleLabel.id = 'autoclear-toggle-label'
if (!ui.firstLink) { // add font size/weight since no ui.firstLink to borrow from
toggleLabel.style.fontSize = '0.875rem' ; toggleLabel.style.fontWeight = 600 }
toggleLabel.style.marginLeft = `-${ !ui.firstLink ? 23 : 41 }px` // left-shift to navicon
toggleLabel.style.cursor = 'pointer' // add finger cursor on hover
toggleLabel.style.width = `${ env.browser.isMobile ? 201 : 148 }px` // to truncate overflown text
toggleLabel.style.overflow = 'hidden' // to truncate overflown text
toggleLabel.style.textOverflow = 'ellipsis' // to truncate overflown text
toggleLabel.innerText = ( app.msgs.mode_autoClear ) + ' '
+ ( toggleInput.checked ? ( app.msgs.state_enabled || 'enabled' )
: ( app.msgs.state_disabled ))
// Append elements
for (const elem of [navicon, toggleInput, switchSpan, toggleLabel]) navToggleDiv.append(elem)
// Update visual state
navToggleDiv.style.display = 'flex'
setTimeout(() => {
switchSpan.style.backgroundColor = toggleInput.checked ? '#ad68ff' : '#ccc'
switchSpan.style.boxShadow = toggleInput.checked ? '2px 1px 9px #d8a9ff' : 'none'
knobSpan.style.transform = toggleInput.checked ? 'translateX(13px) translateY(0)' : 'translateX(0)'
}, 1) // min delay to trigger transition fx
}
}
}
function hideHistory() { // from DOM since chatgpt.clearChats() works back-end only (front-end updates on refresh)
document.querySelectorAll('nav ol').forEach(ol => {
ol.previousElementSibling.style.display = 'none' // hide temporal heading
ol.querySelectorAll('li').forEach(li => li.style.display = 'none') // hide chat entry
})
if (!hideHistory.observer) { // monitor <nav> to restore temporal headings on new chats
hideHistory.observer = new MutationObserver(mutations => mutations.forEach(mutation => {
if (mutation.type == 'childList') mutation.addedNodes.forEach(addedNode => {
if (addedNode.tagName == 'LI') addedNode.closest('ol').previousElementSibling.style.display = 'inherit'
})}))
hideHistory.observer.observe(document.querySelector('nav'), { childList: true, subtree: true })
}
}
// Run MAIN routine
menu.register() // create browser toolbar menu
// Init UI props
await Promise.race([chatgpt.isLoaded(), new Promise(resolve => setTimeout(resolve, 5000))]) // initial UI loaded
await chatgpt.sidebar.isLoaded()
const ui = { firstLink: chatgpt.getNewChatLink() }
// Add/update TWEAKS style
const tweaksStyleUpdated = 20241002 // datestamp of last edit for this file's `tweaksStyle`
let tweaksStyle = document.getElementById('tweaks-style') // try to select existing style
if (!tweaksStyle || parseInt(tweaksStyle.getAttribute('last-updated'), 10) < tweaksStyleUpdated) { // if missing or outdated
if (!tweaksStyle) { // outright missing, create/id/attr/append it first
tweaksStyle = document.createElement('style') ; tweaksStyle.id = 'tweaks-style'
tweaksStyle.setAttribute('last-updated', tweaksStyleUpdated.toString())
document.head.append(tweaksStyle)
}
tweaksStyle.innerText = (
( chatgpt.isDarkMode() ? '.chatgpt-modal > div { border: 1px solid white }' : '' )
+ '.chatgpt-modal button {'
+ 'font-size: 0.77rem ; text-transform: uppercase ;' // shrink/uppercase labels
+ `border: 2px dashed ${ chatgpt.isDarkMode() ? 'white' : 'black' } !important ; border-radius: 0 !important ;` // thiccen/square/dash borders
+ 'transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out ;' // smoothen hover fx
+ 'cursor: pointer !important ;' // add finger cursor
+ 'padding: 5px !important ; min-width: 102px }' // resize
+ '.chatgpt-modal button:hover {' // add zoom, re-scheme
+ 'transform: scale(1.055) ;'
+ ( chatgpt.isDarkMode() ? 'background-color: #2cff00 !important ; box-shadow: 2px 1px 54px #38ff00 !important ; color: black !important'
: 'background-color: #c7ff006b !important ; box-shadow: 2px 1px 30px #97ff006b !important' ) + '}'
+ '.modal-buttons { margin-left: -13px !important }'
+ '* { scrollbar-width: thin }' // make FF scrollbar skinny to not crop toggle
)
}
// Create NAV TOGGLE div, add styles
const navToggleDiv = document.createElement('div')
navToggleDiv.style.height = '37px'
navToggleDiv.style.margin = '2px 0' // add v-margins
navToggleDiv.style.userSelect = 'none' // prevent highlighting
navToggleDiv.style.cursor = 'pointer' // add finger cursor
navToggle.update() // create children
if (ui.firstLink) { // borrow/assign CLASSES from sidebar div
const firstIcon = ui.firstLink.querySelector('div:first-child'),
firstLabel = ui.firstLink.querySelector('div:nth-child(2)')
navToggleDiv.classList.add(...ui.firstLink.classList, ...(firstLabel?.classList || []))
navToggleDiv.querySelector('img')?.classList.add(...(firstIcon?.classList || []))
}
navToggle.insert()
// Add LISTENER to toggle switch/label/config/menu + auto-clear
navToggleDiv.onclick = () => {
const toggleInput = document.getElementById('autoclear-toggle-input')
toggleInput.checked = !toggleInput.checked ; config.autoclear = toggleInput.checked
navToggle.update() ; menu.refresh()
if (config.autoclear) {
setTimeout(() => { chatgpt.clearChats('api') ; hideHistory() ; chatgpt.startNewChat() }, 250)
notify(`${app.msgs.mode_autoClear}: ${menu.state.words[1]}`)
} else if (!config.autoclear)
notify(`${app.msgs.mode_autoClear}: ${menu.state.words[0]}`)
settings.save('autoclear', config.autoclear)
}
// AUTO-CLEAR on first visit if enabled
if (config.autoclear) setTimeout(() => { chatgpt.clearChats('api') ; hideHistory() ; chatgpt.startNewChat() }, 250)
// Monitor <html> to maintain NAV TOGGLE VISIBILITY on node changes
new MutationObserver(mutations => mutations.forEach(mutation => {
if (mutation.type == 'childList' && mutation.addedNodes.length && !config.toggleHidden)
navToggle.insert()
})).observe(document.documentElement, { childList: true, subtree: true })
// Disable distracting SIDEBAR CLICK-ZOOM effect
if (!document.querySelector('[sidebar-click-zoom-observed]')) {
new MutationObserver(mutations => mutations.forEach(({ target }) => {
if (target.closest('[class*="sidebar"]') // include sidebar divs
&& !target.id.endsWith('-knob-span') // exclude our navToggle
&& target.style.transform != 'none' // click-zoom occurred
) target.style.transform = 'none'
})).observe(document.body, { attributes: true, subtree: true, attributeFilter: [ 'style' ]})
document.documentElement.setAttribute('sidebar-click-zoom-observed', true)
}
})()