KeepBingChat

实现火狐浏览器访问New Bing的ChatGPT

当前为 2023-05-07 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name              KeepBingChat
// @description       实现火狐浏览器访问New Bing的ChatGPT
// @version           1.1
// @author            xcanwin
// @namespace         https://github.com/xcanwin/KeepBingChat/
// @supportURL        https://github.com/xcanwin/KeepBingChat/
// @icon              data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" stroke-width="2" fill="none" stroke="currentColor"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path></svg>
// @license           GPL-2.0-only
// @match             https://www.bing.com/*
// @match             https://www.bing.com/chat
// @run-at            document-idle
// @noframes
// ==/UserScript==

(function() {
    'use strict';

    if (!location.href.match(/.*q=(bingchat|Bing\+AI).*/)) {
        return;
    }

    const setIfr = function(u = "") {
        const kbc = document.createElement('iframe');
        kbc.id = 'xcanwin';
        kbc.style = `position: fixed; top: 0; left: 0; width: 100%;height: 100%; border: none;`;
        document.documentElement.appendChild(kbc);
        const headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1788.0"
        };
        fetch(u, {headers: headers}).then((response) => {
            response.text().then((data) => {
                try {
                    kbc.srcdoc = data;
                } catch (e) {
                    console.log(e);
                }
            })
        });
    };

    const u = `https://www.bing.com/se${GM_info.script.namespace.slice(37, 38)}rch?q=Bing+AI&sh${GM_info.script.namespace.slice(16, 17)}wconv=1&cc=us&s${GM_info.script.namespace.slice(28, 29)}tlang=zh-Hans`;
    setIfr(u);

})();