您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add tools for many bundle sites.
当前为
// ==UserScript== // @name Bundle Helper // @namespace iFantz7E.BundleHelper // @version 0.03 // @description Add tools for many bundle sites. // @match https://www.hrkgame.com/randomkeyshop/make-bundle/* // @match https://www.bundlestars.com/*/bundle/* // @match https://www.reddit.com/r/*/comments/* // @match https://groupees.com/* // @match https://www.indiegala.com/* // @run-at document-start // @grant GM_addStyle // @grant GM_xmlhttpRequest // @icon http://store.steampowered.com/favicon.ico // @copyright 2016, 7-elephant // ==/UserScript== (function () { function attachOnLoad(callback) { window.addEventListener("load", function (e) { callback(); }); } function attachOnReady(callback) { document.addEventListener("DOMContentLoaded", function (e) { callback(); }); } function insertBeforeElement(newNode, referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode); } function insertAfterElement(newNode, referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } function reload() { window.location = window.location.href; } function getQueryByName(name, url) { if (url == null) url = location.search; name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); var results = regex.exec(url); return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } function main() { var url = document.documentURI; if (url.indexOf("hrkgame.com") > -1) { GM_addStyle( " .bh_button { " + " border-radius: 2px; border: medium none; padding: 10px; display: inline-block; cursor: pointer; " + " text-decoration: none !important; color: #67C1F5 !important; " + " background: rgba(103, 193, 245, 1) none repeat scroll 0% 0%; } " + " .bh_owned { background-color: #5C7836 !important; } " ); // Add load button { var divButton = document.createElement("div"); divButton.classList.add("bh_button"); divButton.id = "bh_loadAll"; divButton.setAttribute("style", "position: fixed; right: 20px; bottom: 80px; z-index:3;"); divButton.innerHTML = "<a href='#' onclick=' \ var idx = setInterval(function() \ { \ var eleLoad = document.querySelector(\".loadmore\"); \ if (eleLoad != null) \ { \ window.scrollTo(0,document.body.scrollHeight); \ } \ else \ { \ clearInterval(idx); \ } \ }, 500); \ this.parentElement.style.display=\"none\"; \ return false;'>Load All</a>"; document.body.appendChild(divButton); } // Add mark button { var divButton = document.createElement("div"); divButton.classList.add("bh_button"); divButton.id = "bh_markOwned"; divButton.setAttribute("style", "position: fixed; right: 20px; bottom: 20px; z-index:3;"); var eleA = document.createElement("a"); eleA.setAttribute("href", "#"); eleA.setAttribute("onclick", "return false;"); eleA.textContent = "Mark Owned"; eleA.addEventListener("click", function() { var apps = []; var eleApps = document.querySelectorAll(".add-to-cart-product[href^='http://store.steampowered.com/app/']"); console.log("Apps: " + eleApps.length); for (var i = 0; i < eleApps.length; i++) { var app = /[0-9]+/.exec(eleApps[i].getAttribute("href")); if (app != null) { apps.push(app[0]); } } apps = apps.filter(function(elem, index, self) { return index == self.indexOf(elem); }); var appAll = apps.join(","); GM_xmlhttpRequest( { method: "GET", headers: { "Cache-Control": "max-age=0" }, url: "http://store.steampowered.com/api/appuserdetails/?appids=" + appAll, onload: function(response) { var dataRes = JSON.parse(response.responseText); //console.log("Response: " + Object.keys(dataRes).length); var countOwned = 0; var eleApps = document.querySelectorAll(".add-to-cart-product[href^='http://store.steampowered.com/app/']"); for (var i = 0; i < eleApps.length; i++) { var app = /[0-9]+/.exec(eleApps[i].getAttribute("href")); if (app != null) { if (typeof dataRes[app] !== "undefined") { if (dataRes[app].success) { if (dataRes[app].data.is_owned) { var eleLabel = eleApps[i].nextElementSibling; eleLabel.classList.add("bh_owned"); countOwned++; } else { console.log("App: not owned - " + app); } } else { console.log("App: not success - " + app); } } } } console.log("Apps: owned - " + countOwned); } // End onload }); }); divButton.appendChild(eleA); document.body.appendChild(divButton); } } else if (url.indexOf("bundlestars.com") > -1) { GM_addStyle( " .bh_button { " + " border-radius: 2px; border: medium none; padding: 10px; display: inline-block; cursor: pointer; " + " text-decoration: none !important; color: #67C1F5 !important; " + " background: rgba(103, 193, 245, 1) none repeat scroll 0% 0%; } " + " .bh_owned { background-color: #5C7836 !important; } " ); // Add mark button { var divButton = document.createElement("div"); divButton.classList.add("bh_button"); divButton.id = "bh_markOwned"; divButton.setAttribute("style", "position: fixed; right: 20px; bottom: 20px; z-index:3;"); var eleA = document.createElement("a"); eleA.setAttribute("href", "#"); eleA.setAttribute("onclick", "return false;"); eleA.textContent = "Mark Owned"; eleA.addEventListener("click", function() { var apps = []; var eleApps = document.querySelectorAll(".bundle-accordian a.btn-bundle-more[href^='http://store.steampowered.com/app/']"); console.log("Apps: " + eleApps.length); for (var i = 0; i < eleApps.length; i++) { var app = /[0-9]+/.exec(eleApps[i].getAttribute("href")); if (app != null) { apps.push(app[0]); } } apps = apps.filter(function(elem, index, self) { return index == self.indexOf(elem); }); var appAll = apps.join(","); GM_xmlhttpRequest( { method: "GET", headers: { "Cache-Control": "max-age=0" }, url: "http://store.steampowered.com/api/appuserdetails/?appids=" + appAll, onload: function(response) { var dataRes = JSON.parse(response.responseText); //console.log("Response: " + Object.keys(dataRes).length); var countOwned = 0; var eleApps = document.querySelectorAll(".bundle-accordian a.btn-bundle-more[href^='http://store.steampowered.com/app/']"); for (var i = 0; i < eleApps.length; i++) { var app = /[0-9]+/.exec(eleApps[i].getAttribute("href")); if (app != null) { if (typeof dataRes[app] !== "undefined") { if (dataRes[app].success) { if (dataRes[app].data.is_owned) { var eleLabel = eleApps[i].parentElement.parentElement .parentElement.parentElement.parentElement .parentElement.parentElement.parentElement .parentElement.firstElementChild; eleLabel.classList.add("bh_owned"); countOwned++; } else { console.log("App: not owned - " + app); } } else { console.log("App: not success - " + app); } } } } console.log("Apps: owned - " + countOwned); } // End onload }); }); divButton.appendChild(eleA); document.body.appendChild(divButton); } } else if (url.indexOf("reddit.com") > -1) { GM_addStyle( " .bh_button { " + " border-radius: 2px; border: medium none; padding: 10px; display: inline-block; cursor: pointer; " + " text-decoration: none !important; color: #67C1F5 !important; " + " background: rgba(103, 193, 245, 1) none repeat scroll 0% 0%; } " + " .bh_owned , .md .bh_owned code { background-color: #DFF0D8 !important; } " ); // Add mark button { var divButton = document.createElement("div"); divButton.classList.add("bh_button"); divButton.id = "bh_markOwned"; divButton.setAttribute("style", "position: fixed; right: 20px; bottom: 20px; z-index:3;"); var eleA = document.createElement("a"); eleA.setAttribute("href", "#"); eleA.setAttribute("onclick", "return false;"); eleA.textContent = "Mark Owned"; eleA.addEventListener("click", function() { var apps = []; var eleApps = document.querySelectorAll("td > a[href^='http://store.steampowered.com/app/']"); console.log("Apps: " + eleApps.length); for (var i = 0; i < eleApps.length; i++) { var app = /[0-9]+/.exec(eleApps[i].getAttribute("href")); if (app != null) { apps.push(app[0]); } } apps = apps.filter(function(elem, index, self) { return index == self.indexOf(elem); }); var appAll = apps.join(","); GM_xmlhttpRequest( { method: "GET", headers: { "Cache-Control": "max-age=0" }, url: "http://store.steampowered.com/api/appuserdetails/?appids=" + appAll, onload: function(response) { var dataRes = JSON.parse(response.responseText); //console.log("Response: " + Object.keys(dataRes).length); var countOwned = 0; var eleApps = document.querySelectorAll("td > a[href^='http://store.steampowered.com/app/']"); for (var i = 0; i < eleApps.length; i++) { var app = /[0-9]+/.exec(eleApps[i].getAttribute("href")); if (app != null) { if (typeof dataRes[app] !== "undefined") { if (dataRes[app].success) { if (dataRes[app].data.is_owned) { var eleLabel = eleApps[i].parentElement.parentElement; eleLabel.classList.add("bh_owned"); countOwned++; } else { console.log("App: not owned - " + app); } } else { console.log("App: not success - " + app); } } } } console.log("Apps: owned - " + countOwned); } // End onload }); }); divButton.appendChild(eleA); document.body.appendChild(divButton); } } else if (url.indexOf("groupees.com") > -1) { GM_addStyle( " .bh_button { " + " border-radius: 2px; border: medium none; padding: 10px; display: inline-block; cursor: pointer; " + " text-decoration: none !important; color: #67C1F5 !important; " + " background: rgba(103, 193, 245, 1) none repeat scroll 0% 0%; } " + " .bh_owned { background-color: #DFF0D8 !important; } " ); // Add mark button { var divButton = document.createElement("div"); divButton.classList.add("bh_button"); divButton.id = "bh_markOwned"; divButton.setAttribute("style", "position: fixed; right: 20px; bottom: 20px; z-index:3;"); var eleA = document.createElement("a"); eleA.setAttribute("href", "#"); eleA.setAttribute("onclick", "return false;"); eleA.textContent = "Mark Owned"; eleA.addEventListener("click", function() { var apps = []; var eleApps = document.querySelectorAll(".bundle > .products .info .description a[href^='http://store.steampowered.com/app/']" + ", .expanded .product-info a[href^='http://store.steampowered.com/app/']"); console.log("Apps: " + eleApps.length); for (var i = 0; i < eleApps.length; i++) { var app = /[0-9]+/.exec(eleApps[i].getAttribute("href")); if (app != null) { apps.push(app[0]); } } apps = apps.filter(function(elem, index, self) { return index == self.indexOf(elem); }); var appAll = apps.join(","); GM_xmlhttpRequest( { method: "GET", headers: { "Cache-Control": "max-age=0" }, url: "http://store.steampowered.com/api/appuserdetails/?appids=" + appAll, onload: function(response) { var dataRes = JSON.parse(response.responseText); var countOwned = 0; var elePrds = document.querySelectorAll(".bundle > .products .product h3" + ", .expanded .details"); var eleApps = document.querySelectorAll(".bundle > .products .info" + ", .expanded .details"); for (var i = 0; i < eleApps.length; i++) { var eleApp = eleApps[i].querySelector(".description a[href^='http://store.steampowered.com/app/']" + ", .product-info a[href^='http://store.steampowered.com/app/']"); if (eleApp != null) { var app = /[0-9]+/.exec(eleApp.getAttribute("href")); if (app != null) { if (typeof dataRes[app] !== "undefined") { if (dataRes[app].success) { if (dataRes[app].data.is_owned) { var eleLabel = elePrds[i]; eleLabel.classList.add("bh_owned"); countOwned++; } else { console.log("App: not owned - " + app); } } else { console.log("App: not success - " + app); } } } } } console.log("Apps: owned - " + countOwned); } // End onload }); }); divButton.appendChild(eleA); document.body.appendChild(divButton); } } else if (url.indexOf("indiegala.com") > -1) { GM_addStyle( " .bh_button { " + " border-radius: 2px; border: medium none; padding: 10px; display: inline-block; cursor: pointer; " + " text-decoration: none !important; color: #67C1F5 !important; " + " background: rgba(103, 193, 245, 1) none repeat scroll 0% 0%; } " + " .bh_owned { background-color: #7CA156 !important; } " + " .bundle-item-trading-cards-cont span { opacity: 0; } " + " .span-title .title_game, .span-title .title_drm, .span-title .title_music { " + " line-height: 43px !important; margin: 10px 0px 10px 15px !important; " + " padding-left: 10px !important; border-radius: 3px !important;} " ); // Add mark button { var divButton = document.createElement("div"); divButton.classList.add("bh_button"); divButton.id = "bh_markOwned"; divButton.setAttribute("style", "position: fixed; right: 20px; bottom: 20px; z-index:3;"); var eleA = document.createElement("a"); eleA.setAttribute("href", "#"); eleA.setAttribute("onclick", "return false;"); eleA.textContent = "Mark Owned"; eleA.addEventListener("click", function() { var apps = []; var eleApps = document.querySelectorAll(".game-opened-switcher .game-steam-url[href*='http://store.steampowered.com/app/']" + ", .in .in .in .game-steam-url[href*='http://store.steampowered.com/app/']"); console.log("Apps: " + eleApps.length); for (var i = 0; i < eleApps.length; i++) { var app = /[0-9]+/.exec(eleApps[i].getAttribute("href")); if (app != null) { apps.push(app[0]); } } apps = apps.filter(function(elem, index, self) { return index == self.indexOf(elem); }); var appAll = apps.join(","); GM_xmlhttpRequest( { method: "GET", headers: { "Cache-Control": "max-age=0" }, url: "http://store.steampowered.com/api/appuserdetails/?appids=" + appAll, onload: function(response) { var dataRes = JSON.parse(response.responseText); var countOwned = 0; var elePrds = document.querySelectorAll(".bundle-item-link, .in .in .in .game-steam-url"); var eleApps = document.querySelectorAll(".game-opened-switcher .game-steam-url, .in .in .in .game-steam-url"); for (var i = 0; i < eleApps.length; i++) { var appUrl = eleApps[i].getAttribute("href"); if (appUrl.indexOf("http://store.steampowered.com/app/") > -1) { var app = /[0-9]+/.exec(appUrl); if (app != null) { if (typeof dataRes[app] !== "undefined") { if (dataRes[app].success) { if (dataRes[app].data.is_owned) { var eleLabel = elePrds[i].parentElement; eleLabel.classList.add("bh_owned"); countOwned++; } else { console.log("App: not owned - " + app); } } else { console.log("App: not success - " + app); } } } } } console.log("Apps: owned - " + countOwned); } // End onload }); }); divButton.appendChild(eleA); document.body.appendChild(divButton); } } } attachOnReady(main); })();