NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 2025-04-02
// @description try to take over the world!
// @author linshuai
// @match https://sandstalk.ymdd.tech/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=ymdd.tech
// @grant none
// @license MIT
// ==/UserScript==
function getHashParam(url, key) {
const hashPart = new URL(url).hash; // 获取 # 之后的部分
const params = new URLSearchParams(hashPart.split("?")[1]); // 解析 ? 后面的参数
return params.get(key);
}
(function() {
'use strict';
// 正则匹配目标 URL
const urlPattern = /^https:\/\/sandstalk\.ymdd\.tech\/\?code=[\w-]+&state=wxwork_home#\/resource\/courseDetails\?id=\d+&fileType=\d+&channel=\d+$/;
if (urlPattern.test(window.location.href)) {
const url = window.location.href;
const banner = document.createElement('div');
banner.id = 'top-banner';
banner.innerHTML = `
<button id="copy-token-btn">复制Token</button>
<button id="copy-id-btn">复制ID</button>
<button id="close-btn">关闭</button>
`;
// 添加到文档的body中
document.body.appendChild(banner);
// 复制ID按钮的点击事件
document.getElementById('copy-id-btn').addEventListener('click', function() {
const id = getHashParam(window.location.href, 'id'); // 模拟要复制的ID
copyToClipboard(id);
alert('ID 已复制: ' + id);
});
// 复制Token按钮的点击事件
document.getElementById('copy-token-btn').addEventListener('click', function() {
const token = JSON.parse(localStorage.getItem('SCW__TOKEN__')); // 模拟要复制的Token
console.log(token.token)
copyToClipboard(token.token);
alert('Token 已复制: ' + token.token);
});
// 关闭按钮的点击事件
document.getElementById('close-btn').addEventListener('click', function() {
banner.style.display = 'none';
});
// 复制内容到剪贴板的函数
function copyToClipboard(text) {
const textarea = document.createElement('textarea');
textarea.value = text;
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
}
// 添加样式
const style = document.createElement('style');
style.textContent = `
#top-banner {
position: fixed;
top: 0;
left: 0;
width: 100%;
background-color: rgba(0, 0, 0, 0.8);
color: white;
text-align: center;
padding: 10px;
z-index: 9999;
}
button {
margin: 5px;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
#close-btn {
background-color: red;
}
#close-btn:hover {
background-color: darkred;
}
`;
// 将样式添加到页面
document.head.appendChild(style);
}
})();