// ==UserScript== // @name Show prices on Steam followedgames page // @namespace http://tampermonkey.net/ // @version 0.1.1 // @description 在Steam社区"已关注的游戏"页面显示游戏的价格 // @author lyzlyslyc // @match http*://steamcommunity.com/*/followedgames/ // @icon https://store.steampowered.com/favicon.ico // @grant GM_xmlhttpRequest // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Your code here... let interval = 200; setInterval(requestPrice,interval); function requestPrice(){ //获取关注列表 let apps = document.querySelector(".games_list_rows").children; for(let i=0;i`+ '
'+ `
Request Timeout
`+ '
'+ ''; let span = document.createElement("span"); span.innerHTML = content; span.className = "game_purchase_action_bg"; let a = apps[i].querySelector(".followed_game_actions a"); a.parentElement.prepend(span); apps[i].hasPrice = false; } }) apps[i].hasPrice = "loading"; } } } function generatePrice(price){ let content = ""; let template = ""; if(price.discount_percent==0){ template = ``+ '
'+ `
${price.final_formatted}
`+ '
'+ '
'; } else { template = ``+ `
-${price.discount_percent}%
`+ '
'+ `
${price.initial_formatted}
`+ `
${price.final_formatted}
`+ '
'+ '
' } content+=template; return content; } function isAppVisible(app){ let s = app.offsetTop; // 元素相对于页面顶部的距离 let x = app.offsetHeight; //元素自身高度 let t = document.documentElement.scrollTop; // 页面在垂直方向上滚动的距离 let y = document.documentElement.clientHeight; //窗口可视区域的高度 let isHidden = (s+x) < t || (s > (t+y)); return !isHidden } })();