Skip to content

Instantly share code, notes, and snippets.

@MalikAQayum
Last active February 3, 2022 20:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MalikAQayum/5c1e6401d79f9697f7bf9617c762e87f to your computer and use it in GitHub Desktop.
Save MalikAQayum/5c1e6401d79f9697f7bf9617c762e87f to your computer and use it in GitHub Desktop.
gets the latest playtest from https://steamcommunity.com/groups/pcgameitplaytest/rss/ and request access to it.
// ==UserScript==
// @name PCGameit Playtests
// @namespace https://pcgameit.com
// @version 0.3
// @description gets the latest playtest from https://steamcommunity.com/groups/pcgameitplaytest/rss/ and request access to it.
// @author MalikQayum
// @connect store.steampowered.com
// @connect steamcommunity.com
// @match https://store.steampowered.com/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant unsafeWindow
// ==/UserScript==
var notifyMe = 1; //set to 1 if you want to be notified that you made a request for a playtest and 0 off.
if( typeof GM_getValue("AppsRequested") === 'undefined' ){
GM_setValue("AppsRequested", "[]");
}
unsafeWindow.ResetAppsRequested = function () {
GM_setValue("AppsRequested", "[]"); //ResetAppsRequested(); in console if you want to reset the AppsRequested
}
GetPlaytestAppid();
function GetPlaytestAppid()
{
GM_xmlhttpRequest({
method: 'GET',
url: 'https://steamcommunity.com/groups/pcgameitplaytest/rss/',
headers: {
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3',
'Accept': 'application/atom+xml,application/xml,text/xml'
},
onload: function(response) {
var dom = response.responseXML;
var description_2 = dom.getElementsByTagName('description')[1].textContent;
var appid = description_2.split("/")[4];
console.log("parent appid: " + appid);
CheckAppid(appid);
}
});
}
function CheckAppid(appid)
{
console.log("here => " + JSON.parse(GM_getValue("AppsRequested")).length);
if($.inArray(appid, JSON.parse(GM_getValue("AppsRequested"))) !== -1)
{
console.log("we have requested this before: " + JSON.parse(GM_getValue("AppsRequested")));
}
else
{
console.log("we have not requested this before: " + JSON.parse(GM_getValue("AppsRequested")));
ajaxrequestplaytestaccess(appid);
}
}
function ajaxrequestplaytestaccess(appid)
{
var AppsRequestedArr = JSON.parse(GM_getValue("AppsRequested"));
GM_xmlhttpRequest ({
method: "POST",
url: 'https://store.steampowered.com/ajaxrequestplaytestaccess/'+appid,
data: "sessionid=" + g_sessionID,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
onload: function(response)
{
response = JSON.parse(response.responseText);
if(response.granted == 1)
{
console.log(appid +" => Instant Access.");
AppsRequestedArr.push(appid);
GM_setValue("AppsRequested", JSON.stringify(AppsRequestedArr));
if(notifyMe == 1){ alert(appid +" => Instant Access."); }
}
else if(response.granted === null)
{
console.log(appid +" => Requested Access.");
AppsRequestedArr.push(appid);
GM_setValue("AppsRequested", JSON.stringify(AppsRequestedArr));
if(notifyMe == 1){ alert(appid +" => Requested Access."); }
}
else
{
alert("something else => " + response);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment