Greasy Fork

humble-bundle-extra

User script for humble bundle. Adds steam store links to all games and marks already owned games

目前为 2021-05-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         humble-bundle-extra
// @namespace    https://humblebundle.com
// @version      1.0.0
// @description  User script for humble bundle. Adds steam store links to all games and marks already owned games
// @match        *://www.humblebundle.com/*
// @author       MrMarble
// @grant        GM_xmlhttpRequest
// @connect      api.steampowered.com
// @connect      store.steampowered.com
// @source       https://github.com/MrMarble/humble-bundle-extra
// ==/UserScript==
!function(){"use strict";const e=e=>new Promise(((t,a)=>{GM_xmlhttpRequest({...e,onload:t,onabort:a})})),t=(()=>{const e=document.createElement("div");return function(t){return t&&"string"==typeof t&&(t=(t=t.replace(/<script[^>]*>([\S\s]*?)<\/script>/gim,"")).replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gim,""),e.innerHTML=t,t=e.textContent,e.textContent=""),t}})(),a=e=>t(e).replace(/[\u{2122}\u{00AE}]/gu,"").toLowerCase(),n=(e,t,a)=>{return n=`\n  <div class="charity-details-view humblemodal-wrapper" tabindex="0">\n    <div class="humblemodal-modal humblemodal-modal--open" style="opacity: 1;">\n      <a class="js-close-modal close-modal" href="#" onclick="(function(e){e.preventDefault();e.target.parentElement.parentElement.parentElement.remove()})(event)">\n        <i class="hb ${e}"></i>\n      </a>\n      <div class="charity-info-wrapper">\n        <div class="charity-media">\n          <div class="charity-logo">\n            <i class="hb hb-exclamation-circle" style="font-size:13em;color:#c9262c"></i>\n          </div> \n        </div>\n        <div class="charity-details">\n          <div class="charity-title">\n            <h2>${t}</h2>\n          </div>\n          <div class="charity-description">\n            ${a}\n          </div>\n        </div>\n        </div>\n    </div>\n</div>\n  `,r=document.createElement("template"),n=n.trim(),r.innerHTML=n,r.content.firstChild;var n,r},r="&&hh_extras&&",o="&&hh_extras_owned&&",i=async()=>{const t=await e({url:"https://api.steampowered.com/ISteamApps/GetAppList/v0002/?format=json",method:"GET"}),{applist:n}=JSON.parse(t.responseText),r={};return n?.apps?.forEach((({name:e,appid:t})=>{r[a(e)]=t})),r},l=async()=>{const t=await e({url:"https://store.steampowered.com/dynamicstore/userdata/",method:"GET"}),{rgOwnedApps:a}=JSON.parse(t.responseText);return a};document.querySelector("div.inner-main-wrapper div.bundle-info-container")&&async function(){const e=await(async e=>{let t={};return void 0?(t=await i(),localStorage.setItem(r,JSON.stringify(t))):(t=localStorage.getItem(r))?t=JSON.parse(t):(t=await i(),localStorage.setItem(r,JSON.stringify(t))),t})(),t=await(async e=>{let t=[];return void 0?(t=await l(),localStorage.setItem(o,JSON.stringify(t))):(t=localStorage.getItem(o))?t=JSON.parse(t):(t=await l(),localStorage.setItem(o,JSON.stringify(t))),t})(),s=0!=t.length;s||function(){const e=n("hb-exclamation-circle","You are not logged in to the steam store",'<p>Information about games already in your library will not be available.</p>\n    <p>You can login using this <a href="https://store.steampowered.com/login" target="_blank" rel="noopener">link</a>. Reload the page after login to load the games in your library.</p>');document.querySelector("#site-modal").appendChild(e)}(),document.querySelectorAll(".front-page-art-image-text").forEach((n=>{let r;(r=e[a(n.textContent)])&&(n.innerHTML=`<a href="https://store.steampowered.com/app/${r}" style="text-decoration:underline;font-weight:normal" target="_blank" rel="noopener" title="Visit Steam Store">${n.textContent}</a>`,s&&t.includes(r)&&(n.parentElement.parentElement.querySelector(".dd-caption-lock").remove(),n.firstChild.style.color="#7f9a2f"))}))}()}();