Steam工坊操作调整

9/16/2022, 2:39:41 PM

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Steam工坊操作调整
// @namespace   1e873e3b-62d4-49da-9ccf-74be3b7df85c
// @match       *://*steamcommunity.com/app/*/workshop/
// @match       *://*steamcommunity.com/sharedfiles/filedetails/?id=*
// @grant       none
// @version     1.3
// @author      朋也
// @license     AGPL
// @description 9/16/2022, 2:39:41 PM
// ==/UserScript==

(function(){
  let current_player_workshop_link = document.querySelector(".current_player_workshop_link a");
  if (current_player_workshop_link) {
    let astr = current_player_workshop_link.getAttribute("data-dropdown-html");
    
    document.querySelector(".current_player_workshop_link").innerHTML = astr;
    current_player_workshop_link.style.display = "none";
    
    let head = document.querySelector("head");
    let styledom = document.createElement("style");
    styledom.innerHTML = ".current_player_workshop_link a{display:block;margin-top:5px;}";
    head.appendChild(styledom);
  }
  
  let sectionTabs_states = document.querySelector(".sectionTabs>.stats");
  if (sectionTabs_states) {
    let state_href = sectionTabs_states.getAttribute("href");
    console.log(state_href);
    
    fetch(state_href)
      .then(resp => resp.text())
      .then(data => {
        let divdom = document.createElement("div");
        divdom.innerHTML = data;
        let trs = divdom.querySelectorAll("table:first-child tr");
        let totalscore = trs[trs.length-3].querySelector("td:last-child").innerHTML;
        let upscoredom = trs[trs.length-2].querySelector("td:last-child");
        let downscoredom = trs[trs.length-1].querySelector("td:last-child");
        upscoredom.querySelector("span").remove();
        downscoredom.querySelector("span").remove();
        let upscore = upscoredom.innerText.trim();
        let downscore = downscoredom.innerText.trim();
        let subscribecount = document.querySelectorAll(".stats_table tr")[1].querySelector("td:first-child").innerText.trim().replaceAll(",", "");
        
        let numRatingsdom = document.querySelector(".numRatings");
        if (numRatingsdom) {
          numRatingsdom.innerText += ` (${upscore}/${downscore}/${totalscore}/${subscribecount})`;
        } else {
          let ratingSectiondom = document.querySelector(".ratingSection");
          if (ratingSectiondom) {
            ratingSectiondom.innerHTML += ` (${upscore}/${downscore}/${totalscore}/${subscribecount})`;
          }
        }
        
        
      })
  }
})();