Enable ChatGPT Mobile

在桌面浏览器上启用ChatGPT移动版本

当前为 2023-06-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Enable ChatGPT Mobile
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.0
  5. // @license MIT
  6. // @author CY Fung
  7. // @match https://chat.openai.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com
  9. // @grant unsafeWindow
  10. // @run-at document-start
  11.  
  12. // @description To enable mobile version of ChatGPT in desktop browsers
  13. // @description:ja デスクトップブラウザでChatGPTモバイル版を有効にする
  14. // @description:zh-TW 在桌面瀏覽器上啟用ChatGPT行動版
  15. // @description:zh-CN 在桌面浏览器上启用ChatGPT移动版本
  16.  
  17. // @description:ko 데스크톱 브라우저에서 ChatGPT 모바일 버전 활성화
  18. // @description:ru Включение мобильной версии ChatGPT в браузерах для компьютера
  19. // @description:af Aktiveer ChatGPT Mobile op rekenaarblaaier
  20. // @description:az Masaüstü brauzerlərdə ChatGPT Mobile versiyasını aktivləşdirin
  21. // @description:id Mengaktifkan versi mobile ChatGPT di browser desktop
  22. // @description:ms Mengaktifkan versi mudah alih ChatGPT di pelayar desktop
  23. // @description:bs Aktivirajte mobilnu verziju ChatGPT-a u desktop preglednicima
  24. // @description:ca Activar la versió mòbil de ChatGPT en navegadors d'escriptori
  25. // @description:cs Povolení mobilní verze ChatGPT v desktopových prohlížečích
  26. // @description:da Aktivér mobilversionen af ChatGPT i desktop-browsere
  27. // @description:de Aktivieren Sie die mobile Version von ChatGPT in Desktop-Browsern
  28. // @description:et Luba ChatGPT mobiiliversioon töölauabrauserites
  29. // @description:es Habilitar la versión móvil de ChatGPT en navegadores de escritorio
  30. // @description:eu Gaitu ChatGPT Mobile-ren bertsioa mahaigaineko nabigatzaileetan
  31. // @description:fr Activer la version mobile de ChatGPT dans les navigateurs de bureau
  32. // @description:gl Activar a versión móbil de ChatGPT nos navegadores de escritorio
  33. // @description:hr Omogućite mobilnu verziju ChatGPT-a u preglednicima za stolna računala
  34. // @description:zu Vumela ukuqalisa i-versi ye-ChatGPT Mobile kumakhompyutha we-deskithophu
  35. // @description:is Virkjaðu ChatGPT Mobile-útgáfu í tölvuvafrum
  36. // @description:it Attiva la versione mobile di ChatGPT nei browser per desktop
  37. // @description:sw Wezesha toleo la ChatGPT Mobile kwenye vivinjari vya kompyuta
  38. // @description:lv Iespējot ChatGPT Mobile versiju datora pārlūkprogrammās
  39. // @description:lt Įgalinkite „ChatGPT Mobile“ versiją darbalaukio naršyklėse
  40. // @description:hu Engedélyezze a ChatGPT Mobile verziót asztali böngészőkben
  41. // @description:nl Schakel de mobiele versie van ChatGPT in op desktopbrowsers
  42. // @description:uz Desktop brauzerlarda ChatGPT Mobile versiyasini yoqish
  43. // @description:pl Włącz wersję mobilną ChatGPT w przeglądarkach na komputery
  44. // @description:pt Ative a versão móvel do ChatGPT nos navegadores de desktop
  45. // @description:pt-BR Ative a versão móvel do ChatGPT em navegadores de desktop
  46. // @description:ro Activează versiunea mobilă ChatGPT în browserele de pe desktop
  47. // @description:sq Aktivizo versionin mobile të ChatGPT në shfletuesit e desktopit
  48. // @description:sk Povoliť mobilnú verziu ChatGPT v desktopových prehliadačoch
  49. // @description:sl Omogočite mobilno različico ChatGPT v namiznih brskalnikih
  50. // @description:sr Активирајте мобилну верзију ChatGPT-а у десктоп прегледачима
  51. // @description:fi Ota käyttöön ChatGPT Mobile -versio työpöytäselaimissa
  52. // @description:sv Aktivera mobila versionen av ChatGPT i skrivbordswebbläsare
  53. // @description:vi Kích hoạt phiên bản di động của ChatGPT trên trình duyệt máy tính
  54. // @description:tr Masaüstü tarayıcılarda ChatGPT Mobile sürümünü etkinleştirin
  55. // @description:be Уключыць мабільную версію ChatGPT у настольных браўзерах
  56. // @description:bg Активиране на мобилната версия на ChatGPT в десктоп браузъри
  57. // @description:ky Стол таракчаларында ChatGPT Mobile версиясын иштетүү
  58. // @description:kk Столтік шолғыштарда ChatGPT Mobile нұсқасын қосу
  59. // @description:mk Овозможи мобилна верзија на ChatGPT во десктоп прелистувачи
  60. // @description:mn Дэскутоп браузерд ChatGPT Mobile ихэвчлэн ашиглах
  61. // @description:uk Увімкнути мобільну версію ChatGPT у браузерах для робочого столу
  62. // @description:el Ενεργοποίηση της κινητής έκδοσης του ChatGPT σε προγράμματα περιήγησης επιφάνειας εργασίας
  63. // @description:hy Միացնել ChatGPT բջջային տարբերակը աշխատանքային ժամանցման զննարկիչներում
  64. // @description:ur ڈیسک ٹاپ براؤزرز میں چیٹ جی پی ٹی موبائل کو فعال کریں
  65. // @description:ar تمكين نسخة ChatGPT المحمول في متصفحات سطح المكتب
  66. // @description:fa فعال کردن نسخه تلفن همراه ChatGPT در مرورگرهای دسکتاپ
  67. // @description:ne डेस्कटप ब्राउजरहरूमा ChatGPT मोबाइल सक्षम गर्नुहोस्
  68. // @description:mr डेस्कटॉप ब्राउझरमध्ये ChatGPT मोबाईल सक्षम करा
  69. // @description:hi डेस्कटॉप ब्राउज़रों में ChatGPT मोबाइल सक्षम करें
  70. // @description:as ডেক্সটপ ব্ৰাউজাৰত ChatGPT মোবাইল সক্ৰিয় কৰক
  71. // @description:bn ডেস্কটপ ব্রাউজারে ChatGPT মোবাইল সক্রিয় করুন
  72. // @description:pa ਡੈਸਕਟਾਪ ਬਰਾ browserਜ਼ਰ 'ਤੇ ਚੈਟਜੀਪੀਟੀ ਮੋਬਾਈਲ ਯੋਗ ਕਰੋ
  73. // @description:gu ડેસ્કટોપ બ્રાઉઝરમાં ChatGPT મોબાઇલ સક્રિય કરો
  74. // @description:or ଡେସ୍କଟପ ବ୍ରାଉଜରରେ ChatGPT ମୋବାଇଲ ସକ୍ରିୟ କରନ୍ତୁ
  75. // @description:ta மேல இணைய உலாவிகளில் ChatGPT மொபைல் பதிப்பை இயக்க
  76. // @description:te డెస్క్‌టాప్ బ్రౌజర్‌లో ChatGPT మొబైల్ వెర్షన్‌ను ప్రారంభించండి
  77. // @description:kn ಡೆಸ್ಕ್‌ಟಾಪ್ ಬ್ರೌಸರ್‌ಗಳಲ್ಲಿ ChatGPT ಮೊಬೈಲ್ ಆವೃತ್ತಿಯನ್ನು ಸಕ್ರಿಯಗೊಳಿಸಿ
  78. // @description:ml ഡെസ്ക്ടോപ് ബ്രൌസറുകളിൽ ChatGPT മൊബൈൽ പതിപ്പ് പ്രവർത്തനമാക്കുക
  79. // @description:si ඩෙස්ක්ටොප් බ්‍රවුසර් වල ChatGPT ජංගම අනුවාදය සක්‍රීය කරන්න
  80. // @description:th เปิดใช้งาน ChatGPT บนมือถือในเบราว์เซอร์เดสก์ท็อป
  81. // @description:lo ເປີດໃຊ້ ChatGPT ສະບັບມືຖືໃນໂປຣແກຣມທ່ອງເວັບໃນຄອມພິວເຕີ
  82. // @description:my ဒက်စ်တော့ဘရောင်ဇာများတွင် ChatGPT မိုဘိုင်းဗားရှင်းကို ဖွင့်ရန်
  83. // @description:ka ჩართეთ ChatGPT Mobile სამუშაო ბრაუზერებში
  84. // @description:am በዴስክቶፕ ብራውዘሮች ውስጥ ChatGPT ተቀናቃኝ ስሪትን አብረውው
  85. // @description:km បើក ChatGPT កំណែទូរស័ព្ទលើកម្មវិធីរុករកលើផ្ទៃតុ
  86.  
  87.  
  88. // ==/UserScript==
  89.  
  90. (() => {
  91. "use strict";
  92.  
  93. const REPLACE_DESKTOP_MODELS = false;
  94.  
  95. const mzs = [{
  96. // category: "other",
  97. desktop: "text-davinci-002-render-sha",
  98. mobile: "text-davinci-002-render-sha-mobile",
  99. human_category_name_mobile: "GPT-3.5-M"
  100. }, {
  101. // category: "other",
  102. desktop: "gpt-4",
  103. mobile: "gpt-4-mobile",
  104. human_category_name_mobile: "GPT-4-M"
  105. }];
  106.  
  107. const gptModels = {}
  108. for (const mz of mzs) {
  109. gptModels[mz.mobile] = {
  110. human_category_name: mz.human_category_name_mobile,
  111. default_model: mz.mobile
  112. };
  113. }
  114.  
  115. /** @type {globalThis.Window} */
  116. const win = typeof unsafeWindow === 'object' ? unsafeWindow : typeof window === 'object' ? window : this;
  117.  
  118.  
  119. /**
  120. * @typedef Category
  121. * @type {object}
  122. * @property {string} category
  123. * @property {string} human_category_name
  124. * @property {string} subscription_level
  125. * @property {string} default_model
  126. * @property {string} browsing_model
  127. * @property {string} code_interpreter_model
  128. * @property {string} plugins_model
  129. */
  130.  
  131. /**
  132. * @typedef Model
  133. * @type {object}
  134. * @property {string} slug
  135. * @property {number} max_tokens
  136. * @property {string} title
  137. * @property {string} description
  138. * @property {string[]} tags
  139. * @property {object} capabilities
  140. */
  141.  
  142. /**
  143. * @typedef JsonRes
  144. * @type {object}
  145. * @property {Category[]} categories
  146. * @property {Model[]} models
  147. */
  148.  
  149.  
  150. /**
  151. * @param {Model} model
  152. */
  153. function fixTitle(model) {
  154.  
  155. if (model.slug === "text-davinci-002-render-sha") {
  156. model.title = /\bdefault\b/i.test(model.title) ? "Default (GPT-3.5)" : "GPT-3.5";
  157. } else if (model.slug === "text-davinci-002-render-sha-mobile") {
  158. model.title = /\bdefault\b/i.test(model.title) ? "Default (GPT-3.5) (Mobile)" : "GPT-3.5 (Mobile)";
  159. } else if (model.slug === "gpt-4") {
  160. model.title = /\bdefault\b/i.test(model.title) ? "Default (GPT-4)" : "GPT-4";
  161. } else if (model.slug === "gpt-4-mobile") {
  162. model.title = /\bdefault\b/i.test(model.title) ? "Default (GPT-4) (Mobile)" : "GPT-4 (Mobile)";
  163. }
  164.  
  165. let suffix = `[${model.tags.join(', ')}]`;
  166. if (model.description.indexOf(suffix) < 0) model.description = `${model.description} ${suffix}`;
  167.  
  168. }
  169.  
  170. ((Response) => {
  171.  
  172. Response.prototype.__json7942__ = Response.prototype.json;
  173. Response.prototype.json = function () {
  174.  
  175. /** @type {globalThis.Response} */
  176. const __this__ = this;
  177. /** @type {Promise<any>} */
  178. let jsonPromise = __this__.__json7942__.apply(__this__, arguments);
  179.  
  180. jsonPromise = jsonPromise.then(__jsonRes__ => {
  181.  
  182. if (typeof (__jsonRes__ || 0).browsing === 'boolean' && typeof (__jsonRes__ || 0).code_interpreter === 'boolean' && typeof (__jsonRes__ || 0).plugins === 'boolean') {
  183. __jsonRes__.browsing = true;
  184. __jsonRes__.code_interpreter = true;
  185. __jsonRes__.plugins = true;
  186. }
  187.  
  188.  
  189. if (typeof (__jsonRes__ || 0).message_cap === 'number') {
  190.  
  191. if (__jsonRes__.message_cap < 9999) {
  192. __jsonRes__.message_cap = 9999;
  193. }
  194. }
  195.  
  196. if (typeof ((((__jsonRes__ || 0).accounts || 0).default || 0).features || 0) == 'object') {
  197.  
  198. let features = __jsonRes__.accounts.default.features;
  199.  
  200. let extraFeatures = [
  201. "model_preview",
  202. "browsing_available",
  203. "model_switcher",
  204. "plugins_available",
  205. "beta_features"
  206. ];
  207.  
  208. for (const s of extraFeatures) {
  209. if (features.indexOf(s) < 0) features.push(s);
  210. }
  211.  
  212. }
  213.  
  214. if (((__jsonRes__ || 0).categories || 0).length >= 1 && ((__jsonRes__ || 0).models || 0).length >= 1) {
  215.  
  216.  
  217. try {
  218. /** @type {JsonRes} */
  219. const jsonRes = __jsonRes__;
  220.  
  221. const categories = [...jsonRes.categories];
  222. let add_gpt_4_mobile = false;
  223. let add_gpt_3_mobile = false;
  224.  
  225. /** @type {Map<string, Category>} */
  226. const default_models = new Map();
  227. for (const cat of categories) {
  228. default_models.set(`${cat.default_model}`, cat);
  229. }
  230.  
  231. /** @type {Map<string, Model>} */
  232. const availableModels = new Map();
  233. for (const model of jsonRes.models) {
  234. availableModels.set(`${model.slug}`, model);
  235. fixTitle(model);
  236. }
  237.  
  238. const b = (d, m) => (default_models.has(d) && !default_models.has(m) && availableModels.has(d) && availableModels.has(m));
  239.  
  240. let gpt3 = mzs[0];
  241. let gpt4 = mzs[1];
  242. if (b(gpt3.desktop, gpt3.mobile)) add_gpt_3_mobile = true;
  243. if (b(gpt4.desktop, gpt4.mobile)) add_gpt_4_mobile = true;
  244.  
  245. if (add_gpt_3_mobile) {
  246. REPLACE_DESKTOP_MODELS
  247. ? Object.assign(default_models.get(gpt3.desktop), gptModels[gpt3.mobile])
  248. : categories.push(Object.assign({}, default_models.get(gpt3.desktop), gptModels[gpt3.mobile]));
  249. }
  250. if (add_gpt_4_mobile) {
  251. REPLACE_DESKTOP_MODELS
  252. ? Object.assign(default_models.get(gpt4.desktop), gptModels[gpt4.mobile])
  253. : categories.push(Object.assign({}, default_models.get(gpt4.desktop), gptModels[gpt4.mobile]));
  254. }
  255.  
  256. jsonRes.categories = categories;
  257.  
  258. } catch (e) {
  259. console.warn(e);
  260. }
  261.  
  262. }
  263.  
  264. return __jsonRes__;
  265.  
  266. });
  267. return jsonPromise;
  268.  
  269. };
  270. })(win.Response)
  271.  
  272. })();