|
本帖最后由 451341 于 2021-8-9 08:58 编辑
已更新为通用版本
因为背景表情太多,SEE和SIH的分解功能又慢又卡,所以自己折腾了一个
食用方法:在steam相关的页面,F12控制台,复制粘贴代码,回车
效果如下:
[/quote]
代码:
隐藏内容,点击显示 [quote]
- (async () => {
- function sleep(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
- var count = 5000;
- var language = `schinese`;
- var totalAsset = 0;
- var currentAsset = 0;
- var startasset = 0;
- var list = [];
- var inventoryUrl = `https://steamcommunity.com/inventory/${g_steamID}/753/6?l=${language}&count=${count}&start_assetid=`;
- var ajaxUrl = `https://steamcommunity.com/profiles/${g_steamID}/ajaxgrindintogoo/`;
- var nRequest = 1;
- var items = {};
- var values = {};
- while(true){
- console.log(`正在加载 No.${nRequest} ${count} 个物品, 当前: ${currentAsset}/${totalAsset}`);
- const response = await fetch(startasset == 0? inventoryUrl : inventoryUrl + startasset);
- if(!response.ok){
- continue;
- }
- const data = await response.json();
- if(data.success != 1){
- continue;
- }
- totalAsset = data.total_inventory_count;
- currentAsset += data.assets.length;
- nRequest++;
- let dMap = data.descriptions.reduce((t,c) => {
- c.tags = c.tags.reduce((t2,c2) => { t2[c2.category] = c2; return t2;}, {});
- if (c.owner_actions && c.owner_actions.length > 0 ) {
- c.owner_actions.forEach((act) => {
- if (act.link.indexOf("GetGooValue") != -1) {
- c.gv = act.link;
- }
- })
- }
- t[c.classid] = c;
- return t;
- },{});
- for(let asset of data.assets){
- var desc = dMap[asset.classid];
- if (desc.tags.Event && desc.gv) {
- asset.name = desc.name;
- if (!items[desc.type]) {
- items[desc.type] = [];
- var rM = desc.gv.match( /GetGooValue\( '%contextid%', '%assetid%', *'?([0-9]+)'? *, *'?([0-9]+)'? *, *'?([0-9]+)'?/ );
- var res = await (await fetch(`https://steamcommunity.com/auction/ajaxgetgoovalueforitemtype?appid=${rM[1]}&item_type=${rM[2]}&border_color=${rM[3]}`)).json();
- if(res && res.goo_value) {
- values[desc.type] = res.goo_value;
- }
- }
- asset.type =desc.type;
- items[desc.type].push(asset);
- }
- }
- if(data.more_items){
- startasset = data.last_assetid;
- await sleep(1000);
- continue;
- }
- console.log(`成功加载 ${totalAsset} 个物品`);
- break;
- }
- if(Object.keys(items).length == 0){
- console.log("没有大促物品")
- return;
- }
- console.log('点击上方对话框,确定:分解 取消:忽略');
- for( let k in items) {
- if (!values[k]) {
- continue;
- }
- if (prompt(`是否分解 ${items[k].length} 个 ${k}, 价值: ${values[k]}`) != null) {
- list = list.concat(items[k]);
- }
- }
- var numAjax = 1;
- var totalAjax = list.length;
- if (totalAjax == 0) {
- console.log("未选择物品");
- return
- }
- console.log(`开始分解 ${totalAjax} 个物品 `)
- for(let asset of list){
- const body = new FormData;
- body.append("sessionid",g_sessionID);
- body.append("appid",asset.appid);
- body.append("goo_value_expected",values[asset.type]);
- body.append("assetid",asset.assetid);
- body.append("contextid",6);
- console.log(`[NO. ${numAjax} / ${totalAjax}]`, asset.name);
- try{
- const data = await (await fetch(ajaxUrl, { method:"POST", body: body})).json();
- if(data.success && data.success == 1){
- console.log(data.strHTML.replace("<div>","").replace("</div>",""));
- } else if(data.success && data.message){
- console.log(data.message);
- } else {
- console.log(`Failed`);
- }
- }
- catch(err){
- console.log(err.message);
- }
- finally{
- numAjax++;
- }
- await sleep(400);
- }
- console.log("分解完毕");
- })();
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
×
1、转载或引用本网站内容,必须注明本文网址:https://keylol.com/t456845-1-1。如发文者注明禁止转载,则请勿转载
2、对于不当转载或引用本网站内容而引起的民事纷争、行政处理或其他损失,本网站不承担责任
3、对不遵守本声明或其他违法、恶意使用本网站内容者,本网站保留追究其法律责任的权利
4、所有帖子仅代表作者本人意见,不代表本社区立场
|