// ==UserScript== // @name ChatGPT禁用数据监管 // @namespace http://tampermonkey.net/ // @version 1.0.1 // @description 目前功能:1.关闭数据监管;2.会话导入导出;3.存档管理器。 // @author bigemon // @match https://chat.openai.com/chat // @match https://chat.openai.com/chat/* // @license GPL-3.0 // @run-at document-idle // @downloadURL none // ==/UserScript== window.enableFakeMod = 'false' != localStorage.getItem('enable_fakemod'); var style = document.createElement('style'); style.innerHTML = '.switch{position:relative;display:inline-block;width:60px;height:34px;}.switch input{opacity:0;width:0;height:0;}.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ccc;-webkit-transition:.4s;transition:.4s;}.slider:before{position:absolute;content:"";height:26px;width:26px;left:4px;bottom:4px;background-color:white;-webkit-transition:.4s;transition:.4s;}input:checked + .slider{background-color:#2196F3;}input:focus + .slider{box-shadow:0 0 1px #2196F3;}input:checked + .slider:before{-webkit-transform:translateX(26px);-ms-transform:translateX(26px);transform:translateX(26px);}.slider.round{border-radius:34px;}.slider.round:before{border-radius:50%;}', document.head.appendChild(style), window.exportSaveData = function () { var a = localStorage.getItem('conversation_id_last') || '', b = localStorage.getItem('parent_message_id_last') || '', c = localStorage.getItem('authorization_last'); if ('' == a || '' == b || 'undefined' == a || 'undefined' == b) return void alert('\u8BF7\u81F3\u5C11\u8BF4\u4E24\u53E5\u8BDD\u518D\u4F7F\u7528\u8FD9\u4E2A\u529F\u80FD!'); var e = JSON.stringify( { conversation_id: a, parent_message_id: b, authorization: c }), f = window.btoa(e); return f }, window.importSaveData = function (a) { var b = window.atob(a), c = JSON.parse(b); return void 0 === c.conversation_id || void 0 === c.parent_message_id ? void alert('\u5B58\u6863\u635F\u574F\u6216\u6570\u636E\u6709\u8BEF\u3002') : void (localStorage.setItem('next_conversation_id', c.conversation_id), localStorage.setItem('next_parent_message_id', c.parent_message_id), alert('\u5B58\u6863\u5BFC\u5165\u6210\u529F')) }, window.saveData = function (a, b, c) { var d = new Date, e = d.getDate(), f = d.getMonth() + 1, g = d.getFullYear().toString().slice(-2), h = d.getHours(), j = d.getMinutes(), k = JSON.parse(localStorage.getItem('savedata')) || [], l = { time: g + '-' + f.toString().padStart(2, '0') + '-' + e.toString().padStart(2, '0') + ' ' + h.toString().padStart(2, '0') + ':' + j.toString().padStart(2, '0'), name: b ? b : '\u5B58\u6863' + (k.length + 1), data: c }; 0 > a || a >= k.length ? k.push(l) : k[a] = l, localStorage.setItem('savedata', JSON.stringify(k)), alert('\u4FDD\u5B58\u5B8C\u6BD5') }, window.loadData = function (a) { var b = JSON.parse(localStorage.getItem('savedata')) || []; if (0 > a || a >= b.length) return alert('\u8BFB\u53D6\u5931\u8D25\uFF1A\u5B58\u6863\u7D22\u5F15\u8D85\u51FA\u8303\u56F4'), !1; var c = b[a]; return window.importSaveData(c.data || ''), !0 }, window.deleteData = function (a) { var b = JSON.parse(localStorage.getItem('savedata')) || []; return 0 > a || a >= b.length ? (alert('\u5220\u9664\u5931\u8D25\uFF1A\u5B58\u6863\u7D22\u5F15\u8D85\u51FA\u8303\u56F4'), !1) : (b.splice(a, 1), localStorage.setItem('savedata', JSON.stringify(b)), !0) }, window.clearAllSaveData = function () { for (var e, a = document.querySelectorAll('nav'), b = 0; b < a.length; b++) { e = a[b].querySelectorAll('a.save-data'); for (var c = 0; c < e.length; c++) e[c].remove(); for (var d = a[b].querySelectorAll('div.save-data'), c = 0; c < d.length; c++) d[c].remove() } }, window.switchEnableFakeMod = function () { var a = document.querySelector('input#cswitch'), b = !!a && a.checked; b ? (window.enableFakeMod = !0, localStorage.setItem('enable_fakemod', !0)) : (window.enableFakeMod = !1, localStorage.setItem('enable_fakemod', !1)) }, window.boxInit = function () { for (var a = document.querySelectorAll('nav'), b = 0; b < a.length; b++) { var g = a[b], c = g.querySelectorAll('a'); if (window.clearAllSaveData(), 2 < g.childNodes.length) { for (var h = JSON.parse(localStorage.getItem('savedata')) || [], d = 0; d < h.length; d++) { var k = h[d], e = document.createElement('div'); e.setAttribute('class', 'save-data flex py-3 px-3 items-center gap-3 rounded-md hover:bg-gray-500/10 transition-colors duration-200 text-white cursor-pointer text-sm flex-shrink-0 border border-white/20'), e.innerHTML = '' + k.time + '
' + k.name + '
\u5220\u9664', g.insertBefore(e, g.childNodes[1]) } var f = document.createElement('a'); f.setAttribute('class', 'save-data flex py-3 px-3 items-center gap-3 rounded-md hover:bg-gray-500/10 transition-colors duration-200 text-white cursor-pointer text-sm flex-shrink-0 border border-white/20'), f.innerHTML = '[ + ] \u65B0\u5EFA\u5B58\u6863', f.onclick = function () { var k = window.exportSaveData(); if (k) { var l = prompt('\u8BF7\u7ED9\u5B58\u6863\u8D77\u4E2A\u7B80\u77ED\u7684\u540D\u5B57'); l && (window.saveData(-1, l, k), window.setTimeout(function () { window.boxInit() }, 300)) } }, g.insertBefore(f, g.childNodes[1]); var j = document.createElement('div'); j.setAttribute('class', 'save-data flex py-3 px-3 items-center gap-3 rounded-md hover:bg-gray-500/10 transition-colors duration-200 text-white cursor-pointer text-sm flex-shrink-0 border border-white/20'), j.innerHTML = '\u7981\u7528\u6570\u636E\u76D1\u7BA1', g.insertBefore(j, g.childNodes[1]) } for (var d = 0; d < c.length; d++) 0 <= c[d].innerHTML.indexOf('FAQ') && (c[d].removeAttribute('href'), c[d].innerHTML = '\u5BFC\u51FA', c[d].onclick = function () { var h = document.querySelector('textarea'), j = window.exportSaveData(); j && prompt('\u2193\u5B58\u6863\u5DF2\u5BFC\u51FA\u81F3\u4E0B\u65B9\u2193', j) }), 0 <= c[d].innerHTML.indexOf('OpenAI Discord') && (c[d].removeAttribute('href'), c[d].innerHTML = '\u5BFC\u5165', c[d].onclick = function () { var h = prompt('\u8BF7\u9ECF\u8D34\u5B58\u6863\u5230\u8F93\u5165\u6846'); window.importSaveData(h) }), 0 <= c[d].innerHTML.indexOf('New Chat') && (c[d].removeAttribute('href'), c[d].innerHTML = '\u91CD\u7F6E\u4F1A\u8BDD', c[d].onclick = function () { confirm('\u70B9\u51FB\u786E\u8BA4\u540E\u5C06\u5237\u65B0\u4F1A\u8BDD,\u5E76\u6E05\u9664\u6240\u6709\u52A0\u8F7D\u7684\u5B58\u6863\u72B6\u6001\u3002\u662F\u5426\u7EE7\u7EED?') && (localStorage.removeItem('import_authorization'), localStorage.removeItem('next_parent_message_id'), localStorage.removeItem('next_conversation_id'), localStorage.removeItem('parent_message_id_last'), localStorage.removeItem('conversation_id_last')) }) } }, window.boxInit(), alert('\u8D5B\u535A\u5DE5\u5177\u5A18v1.1.6\u811A\u672C\u5DF2\u542F\u7528\u3002\u672C\u5DE5\u5177\u7531ChatGPT\u5728\u6307\u5BFC\u4E0B\u81EA\u884C\u7814\u53D1~\r\n\r\n\u66F4\u65B0:\r\n1.\u65B0\u589E\u5B58\u6863\u7BA1\u7406\r\n2.\u300C\u5173\u95ED\u76D1\u7BA1\u300D\u5206\u79BB\u4E3A\u5355\u72EC\u5F00\u5173'); var oldf = window.fetch; window.fetch = function () { for (var a = arguments.length, b = Array(a), c = 0; c < a; c++) b[c] = arguments[c]; if (b[0].includes('moderations') && window.enableFakeMod) return new Response('{}', { status: 200, statusText: 'ok' }); if (b[0].includes('conversation')) { var d = new Headers(b[1].headers), h = d.get('authorization'); localStorage.setItem('authorization_last', h); var j = localStorage.getItem('import_authorization'); if (j && (d.set('authorization', j), b[1].headers = d), b[1].body && 'POST' === b[1].method) if (localStorage.getItem('next_conversation_id') && localStorage.getItem('next_parent_message_id')) { var e = localStorage.getItem('next_conversation_id'), f = localStorage.getItem('next_parent_message_id'); localStorage.removeItem('next_conversation_id'), localStorage.removeItem('next_parent_message_id'); var g = JSON.parse(b[1].body); g.conversation_id = e, g.parent_message_id = f, b[1].body = JSON.stringify(g) } else { var k = JSON.parse(b[1].body); localStorage.setItem('conversation_id_last', k.conversation_id || ''), localStorage.setItem('parent_message_id_last', k.parent_message_id || ''), localStorage.setItem('body_last', b[1].body) } } return oldf.apply(void 0, b) }; var resizeTimer = null; window.onresize = function () { resizeTimer && clearTimeout(resizeTimer), resizeTimer = setTimeout(function () { window.boxInit() }, 200) }; for (var button, buttons = document.getElementsByTagName('button'), i = 0; i < buttons.length; i++) button = buttons[i], -1 !== button.innerHTML.indexOf('sidebar') && button.addEventListener('click', function () { window.setTimeout(function () { window.boxInit() }, 300) });