Greasy Fork

Greasy Fork is available in English.

智谱清言会话清除

Add a button to clear localStorage and refresh the page on chatglm.cn

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         智谱清言会话清除
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Add a button to clear localStorage and refresh the page on chatglm.cn
// @author       gu5ang
// @match        https://chatglm.cn/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    // 创建按钮
    const button = document.createElement('button');
    button.textContent = 'Clear Storage';
    button.style.position = 'fixed';
    button.style.top = '10px';
    button.style.right = '10px';
    button.style.zIndex = '9999';
    button.style.backgroundColor = '#4CAF50'; // 设置背景颜色
    button.style.border = 'none'; // 移除边框
    button.style.color = 'white'; // 设置字体颜色
    button.style.padding = '15px 32px'; // 设置内边距
    button.style.textAlign = 'center'; // 文本居中
    button.style.textDecoration = 'none'; // 移除文本装饰
    button.style.display = 'inline-block'; // 设置为行内块元素
    button.style.fontSize = '16px'; // 设置字体大小
    button.style.margin = '4px 2px'; // 设置外边距
    button.style.cursor = 'pointer'; // 设置鼠标样式为指针
    button.style.borderRadius = '8px'; // 设置圆角

    // 添加悬停效果
    button.onmouseover = function () {
        this.style.backgroundColor = '#45a049';
    };
    button.onmouseout = function () {
        this.style.backgroundColor = '#4CAF50';
    };

    // 清除localStorage并刷新页面的函数
    button.onclick = function () {
        localStorage.clear();
        window.location.reload();
    };

    // 将按钮添加到页面
    document.body.appendChild(button);
})();