油猴脚本:自动获取CK并上传后台
这是一个用于自动获取展示并上传到codeup的用户脚本。当在特定网址上匹配时,该脚本会自动获取浏览器的cookie值,然后将其作为数据通过API上传到指定的服务器。同时,它还会在页面上显示一个提示框,告知用户CK更新成功,并将CK值复制到剪贴板上。
功能特点
- 自动获取浏览器的cookie值
- 通过API将cookie值上传至指定服务器
- 在页面上显示提示框,通知用户CK更新成功
使用说明
- 安装浏览器插件(如Tampermonkey)
- 复制以上代码并粘贴到插件中
- 在代码中修改上传API地址和秘钥
- 在匹配的网址上访问,脚本将自动执行
欢迎根据个人需求和API接口调整代码。请注意,上传API的请求方式仅作为示例展示。
如有疑问或建议,请留言反馈。谢谢!
// ==UserScript==
// @name 自动获取CK并上传后台
// @namespace 响应网址
// @version 1.0
// @description 自动获取展示,5秒后关闭,同步上传后台
// @match 响应网址
// @grant GM_setClipboard
// @grant GM_xmlhttpRequest
// @connect *
// ==/UserScript==
(function() {
'use strict';
window.addEventListener('load', function() {
function myFunction() {
let cookieValue = document.cookie;
var data = JSON.stringify({
"Context": {
"argv": { 'CK': cookieValue }
}
});
console.log(data);
//以下API(阿里云云效)请求方式仅做展示,具体根据自己API接口调整
GM_xmlhttpRequest({
method: "POST",
url: "上传api",
anonymous: true,
headers: {
"Content-Type": "application/json",
"AirScript-Token": "秘钥"
},
data: data,
onload: function(response) {
console.log(response.responseText);
}
})
}
myFunction();
function showAlertBox() {
let alertBox = document.createElement('div');
var message = document.cookie;
GM_setClipboard(message, 'text');
alertBox.textContent = "更新CK成功:\n" + message;
alertBox.style.position = 'fixed';
alertBox.style.top = '90%';
alertBox.style.left = '50%';
alertBox.style.transform = 'translate(-50%, -50%)';
alertBox.style.background = 'white';
alertBox.style.padding = '10px';
alertBox.style.zIndex = '9999';
alertBox.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.3)';
alertBox.style.fontSize = '12px';
document.body.appendChild(alertBox);
setTimeout(function() {
alertBox.remove();
}, 5000);
}
showAlertBox();
});
})();