Enable ChatGPT Mobile

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

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

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