Greasy Fork

Greasy Fork is available in English.

claudeTokenLogin

使用 token 登录 claude

当前为 2024-04-16 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name claudeTokenLogin
// @namespace https://fk.oeatv.com/
// @version 1.1
// @description 使用 token 登录 claude
// @author fk.oeatv.com
// @match https://claude.ai/*
// @grant none
// @license GNU GPLv3
// ==/UserScript==

(function() {
'use strict';
var tokenInput = document.createElement('input');
tokenInput.type = 'text';
tokenInput.placeholder = '请输入sessionKey';
tokenInput.style.marginRight = '10px';

var saveButton = document.createElement('button');
saveButton.innerText = '保存并应用';

var getTokenButton = document.createElement('button');
getTokenButton.innerText = '获取sessionKey';
getTokenButton.style.marginLeft = '10px';

var container = document.createElement('div');
container.style.position = 'fixed';
container.style.top = '10px';
container.style.right = '10px';
container.style.zIndex = '9999';
container.style.backgroundColor = 'white';
container.style.padding = '10px';
container.style.borderRadius = '5px';
container.style.boxShadow = '0 2px 5px rgba(0, 0, 0, 0.3)';

container.appendChild(tokenInput);
container.appendChild(saveButton);
container.appendChild(getTokenButton);

document.body.appendChild(container);

saveButton.addEventListener('click', function() {
    var token = tokenInput.value;
    var domain = 'claude.ai';
    var expirationDate = new Date();
    expirationDate.setDate(expirationDate.getDate() + 7);
    var cookieValue = 'sessionKey=' + token + '; expires=' + expirationDate.toUTCString() + '; path=/; domain=' + domain;
    document.cookie = cookieValue;
    location.reload();
});

getTokenButton.addEventListener('click', function() {
    var token = document.cookie.replace(/(?:(?:^|.*;\s*)sessionKey\s*\=\s*([^;]*).*$)|^.*$/, "$1");
    tokenInput.value = token;
    tokenInput.select();
    document.execCommand('copy');
    alert('sessionKey已复制到剪贴板');
});
})();