本帖最后由 gulang453 于 2023-12-11 19:31 编辑
// ==UserScript==
// @name steam search
// @namespace http://tampermonkey.net/
// @version 0.2
// @description 查找游戏离线账号
// @AuThor You
// @match *://store.steampowered.com/app/*
// @grant GM_xmlhttpRequest
// ==/UserScript==
(function() {
'use strict';
var 父级 = document.getElementsByClassName("store_nav")[0];
var 副本 = document.createElement('div');
副本.innerHTML = '<span>找号</span>';
副本.setAttribute("class", "tab ");
父级.appendChild(副本);
var AppName = document.getElementById('appHubAppName')
.textContent;
var Appid = /app\/(\d+)/.exec(window.location.href)[1];
副本.onclick = () => {
console.log(AppName);
console.log(Appid);
console.log("http://146.56.112.227/bf/search.php?query=" + AppName);
GM_xmlhttpRequest({
method: "GET",
url: "http://146.56.112.227/bf/search.php?query=" + encodeURIComponent(AppName),
headers: {
"User-Agent": "Mozilla/5.0",
"Accept": "application/json"
},
onload: function(response) {
var jsonData = JSON.parse(response.responseText);
if (Array.isArray(jsonData)) {
var extractedData = jsonData.map(item => ({
gameName: item.gameName,
userName: item.userName,
password: item.password,
ssfn: item.ssfn
}));
console.log(extractedData);
openNewPage(JSON.stringify(extractedData), Appid); // 传递Appid
} else {
console.log(jsonData);
openNewPage(JSON.stringify(jsonData), Appid); // 传递Appid
}
}
});
}
function openNewPage(data, Appid) { // 添加Appid参数
var newWindow = window.open("", "_blank");
newWindow.document.write("<html><head><title>Steam搜索结果</title>");
newWindow.document.write("<style>");
newWindow.document.write("body { font-family: Arial, sans-serif; background-image: url('background.jpg'); background-size: cover; }");
newWindow.document.write("h1 { text-align: center; color: #fff; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); }");
newWindow.document.write("table { width: 100%; border-collapse: collapse; }");
newWindow.document.write("th, td { padding: 8px; text-align: left; border-bottom: 1px solid #ddd; color: #fff; background-color: rgba(0, 0, 0, 0.5); }");
newWindow.document.write("tr:nth-child(even) { background-color: rgba(255, 255, 255, 0.1); }");
newWindow.document.write("@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }");
newWindow.document.write("tr { animation: fadeIn 0.5s ease-in-out; }");
newWindow.document.write("</style>");
newWindow.document.write("</head><body>");
newWindow.document.write("<h1>Steam搜索结果</h1>");
newWindow.document.write("<table>");
newWindow.document.write("<tr><th>游戏名称</th><th>用户名</th><th>密码</th><th>SSFN</th><th>App ID</th></tr>");
var extractedData = JSON.parse(data);
extractedData = Object.values(extractedData);
console.log(extractedData.length);
for (var i = 0; i < extractedData.length; i++) {
var item = extractedData[i];
// 打印参数值
newWindow.document.write("<tr>");
newWindow.document.write("<td>" + item.gameName + "</td>");
newWindow.document.write("<td>" + item.userName + "</td>");
newWindow.document.write("<td>" + item.password + "</td>");
newWindow.document.write("<td>" + item.ssfn + "</td>");
newWindow.document.write("<td>" + Appid + "</td>");
newWindow.document.write("</tr>");
}
newWindow.document.write("</table></body></html>");
newWindow.document.close();
}
})();
运行环境:脚本猫
更新时间:2023/12/11
[/md] |