letsmain / ChatGPT访问助手大师版无需魔法Magic/梯子/科学上网工具Tools/Plus+修改版功能增强,免费可随时体验使用,不限时间和地点,Pro高级版赠送精品ChatGPT帐号一枚/个人独享可改密码

// ==UserScript==
// @name         ChatGPT访问助手大师版无需魔法Magic/梯子/科学上网工具Tools/Plus+修改版功能增强,免费可随时体验使用,不限时间和地点,Pro高级版赠送精品ChatGPT帐号一枚/个人独享可改密码
// @namespace    ChatGPT Access Helper
// @version      1.2.7
// @description  ChatGPT访问助手大师解决无法打开ChatGPT或者OpenAI的问题,ip被OpenAI屏蔽或者电信运营商屏蔽无法注册或无法访问Access denied,提供Google谷歌、Bing必应/New Bing新必应、百度、Yandex、360搜索、DuckDuckGo、Startpage、Fsou、DeepL翻译,侧栏联动显示Chat搜索&ChatGPT回答+自定义搜索+代码区高亮+逐字显示,即刻体验OpenAI,无需翻墙,无需注册,无需下载,无需等待!无须繁琐注册流程,无须key,直接与AI对话!轻松导出ChatGPT聊天记录,以便进一步自行保存、分析及分享,解锁ChatGPT Plus功能:主动关闭数据监管;会话导入导出;高负载限制解锁!
// @author       ChatGPT Access Helper
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAArlBMVEUcnH3///+Dybj7/v0gnoDf8e0jn4InoYOr28+Nzr7z+vjc8Ou949pJsJfr9/TC5dwzpov4/Pvv+Pbo9fIro4bR6+V8xrRArJI4qI3j8++JzLtDrZTL6OGy3tOo2c1cuKJRs5w9qpC64dh3xLFiu6X1+/nm9PGv3NKByLdywq5sv6ua08XF5t6W0sPW7ujH59+24NWc1MdnvahUtZ3Z7+qi1sqS0MFNspovpYhYtqDLFPfwAAAD1UlEQVRYw+1W2XqyUAw0gqAgCigqgrjgiktdq33/F/sncLDyg7XtdeeiH6FmkkwSzin94Q9fwdg2dc2yK81a9zfu5rpFKdyD+WP/jzMBlm03LAKc6w/9pw14VYLI8LrHS4WTmJ5W0dTofbd8+M8uaenjtUYkSaDRdodvpaJ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tjYZTg09bcqurU9c4Xlz2/+l9tVePy9Bs2yLAz4/Paz10SuHiePwFemH17TzX/X25W/rDH77AP8OHSPwBjE3hAAAAAElFTkSuQmCC
// @resource     brand https://s2.loli.net/2023/03/22/WIFETy26gc5tRUp.png
// @require      http://cdn.staticfile.org/jquery/1.12.4/jquery.min.js
// @supportURL   http://letsmain.com/chatgpt-access-master?utm_source=openuserjs
// @match        *://*.ai.com/*
// @match        *://chat.openai.com/chat
// @match        *://*.openai.com/*
// @match        *://*.chatgpt.com/*
// @match        *://brad.google.com/*
// @match        *://yiyan.baidu.com/*
// @include      *://*.google.com/*
// @include      *://*.google.com.hk/*
// @include      *://*.ecnu.cf/*
// @include      *://*.aust.cf/*
// @include      *://*.bing.com/*
// @include      *://*.yandex.com/*
// @include      *://*.yandex.ru/*
// @include      *://*.duckduckgo.com/*
// @include      *://*.baidu.com/*
// @include      *://*.sogou.com/*
// @include      *://*.so.com/*
// @include      *://*.sm.cn/*
// @include      *://*.startpage.com/*
// @include      *://*.fsoufsou.com/*
// @include      *://*.deepl.com/*
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_download
// @grant        GM_addStyle
// @grant        GM_openInTab
// @grant        unsafeWindow
// @run-at       document-idle
// @run-at       document-start
// @grant        GM_setClipboard
// @grant        GM_getResourceURL
// @grant        GM_getResourceURL
// @grant        GM_getResourceText
// @grant        GM_xmlhttpRequest
// @compatible	 Chrome
// @compatible	 Edge
// @compatible	 Firefox
// @compatible	 Safari
// @compatible	 Opera
// @license      GPL-3.0-only
// ==/UserScript==

(function() {
    'use strict';
    var $ = window.jQuery;
    if (!$) {
        var script = document.createElement('script');
        script.src = 'https://code.jquery.com/jquery-3.6.0.min.js';
        document.head.appendChild(script);
        $ = window.jQuery;
    }
    var currentUrl = window.location.href;
    var currentHost = window.location.host;
    var resourceAnalysis = {};
    resourceAnalysis.addHtml = function() {
        var brandImgUrl = GM_getResourceURL('brand');
        var floatBoxHtml = '<div style="position:fixed;z-index:1092975;cursor:pointer;top:72px;left:0px;">' +
            '<div id="chatgpt-resources-wrap" style="width:136px;height:28px;line-height:28px;text-align:center;font-size:12px;color:#fff;background-color:#54CBF2;border:1px solid #54CBF2;border-left:none;border-top-right-radius:5px;border-bottom-right-radius:5px;">' +
            '<img src="' + brandImgUrl + '" style="width:20px;height:20px;position:relative;top:5px;" />&nbsp;ChatGPT访问助手' +
            '</div>' +
            '<div id="chatgpt-url-wrap" style="font-size:12px;padding:6px 4px;">' +
            '<a href="http://letsmain.com/chatgpt-access-master?utm_source=greasyfork" target="_blank" style="color:#3b8cff;text-decoration:none">http://letsmain.com/chatgpt-access-master</a>' +
            '</div>' +
            '</div>';
        $('body').append(floatBoxHtml);
        var defaultVipUrl = 'http://letsmain.com/chatgpt-access-master?utm_source=greasyfork&invitation-code=#';
        $('body').on('click', '#chatgpt-resources-wrap', function() {
            defaultVipUrl = defaultVipUrl.replace(/#/g, encodeURIComponent(currentUrl));
            window.open(defaultVipUrl, '_blank');
        });
    };
    resourceAnalysis.init = function() {
        resourceAnalysis.addHtml();
    };
    resourceAnalysis.init();

    const settings = {
        hookEventNames: "contextmenu|select|selectstart|copy|cut|dragstart",
        unhookEventNames: "mousedown|mouseup|keydown|keyup",
        doms: true,
        hookAddEventListener: true,
        hookPreventDefault: true,
        addCss: true,
        iframeSrc: "about:blank",
    };

    const dontHook = e => !!e.closest('form');

    const init = () => {
        const hookEventNames = settings.hookEventNames.split("|");
        const unhookEventNames = settings.unhookEventNames.split("|");
        const eventNames = [...hookEventNames, ...unhookEventNames];

        const clearLoop = () => {
            const targets = [document, document.body, ...document.getElementsByTagName('div')];
            const iframe = document.querySelector(`iframe[src="${settings.iframeSrc}"]`);
            if (iframe && iframe.clientWidth > 99 && iframe.clientHeight > 11) {
                targets.push(iframe.contentWindow.document, iframe.contentWindow.document.body);
            }

            for (const target of targets) {
                if (!target) continue;

                for (const type of eventNames) {
                    const prop = 'on' + type;
                    target[prop] = null;
                }
            }
        };

        if (settings.doms) {
            setInterval(clearLoop, 9e3);
            setTimeout(clearLoop, 1e3);
            window.addEventListener('load', clearLoop, true);
        }

        if (settings.hookAddEventListener) {
            const originalAddEventListener = EventTarget.prototype.addEventListener;
            const newAddEventListener = function (type, listener, options) {
                const useCapture = typeof options === "boolean" ? options : options && options.capture;
                if (!hookEventNames.includes(type)) {
                    originalAddEventListener.call(this, type, listener, useCapture);
                } else {
                    originalAddEventListener.call(this, type, e => {
                        if (dontHook(e) || !hookEventNames.includes(e.type)) {
                        e.preventDefault();
                    } else {
                        listener(e);
                    }
                }, useCapture);
            }
        };
        EventTarget.prototype.addEventListener = newAddEventListener;
        document.addEventListener = newAddEventListener;
    }

        if (settings.hookPreventDefault) {
            const originalPreventDefault = Event.prototype.preventDefault;
            Event.prototype.preventDefault = function () {
                if (dontHook(this) || !eventNames.includes(this.type)) {
                    originalPreventDefault.call(this);
                }
            };
        }

        if (settings.addCss) {
            GM_addStyle(
                `html, * {
                    -webkit-user-select: text !important;
                    -moz-user-select: text !important;
                    user-select: text !important;
                }
            ::-moz-selection {
                color: #FFF!important;
                background: #3399FF!important;
            }
            ::selection {
                color: #FFF!important;
                background: #3399FF!important;
            }`
        );
        }
    };
    init();
})();