Open kriki200 opened 5 years ago
Could you give me the link for the store page of Alice: Madness Returns?
As far as I know there isb't any since its been removed. Here's a hub link: https://steamcommunity.com/app/19680/.
Ok, I just needed the appid, thanks
Good suggestion! Currently, there actually exists 2 options for this (one by me):
Both use entire diffent approaches to solving this problem. Both solutions have their up- and downsides, but overall I think @rafael-gssa's solution is more efficient, as it reduces the requests that are needed. Mind that my userscript checks for region locked store pages too.
I actually found another excellent userscript by @Ryzhehvost. He seems to be using roughly the same solution as @rafael-gssa, but he tries to cover up the added hashes by replacing history, among other things.
There's actually another alternative that I think is much better, using the webRequest API.
We can listen to a onHeadersReceived
event coming from URLs that match either *://*.store.steampowered.com/app/*
or *://*.store.steampowered.com/sub/*
, and then check if the status code is 302. In that case, we then redirect the request.
Here's a sample extension that does this:
manifest.json
{
"manifest_version": 2,
"name": "Steam Redirector",
"version": "1.0.0",
"background": {
"scripts": ["background.js"]
},
"permissions": [
"*://*.store.steampowered.com/app/*",
"*://*.store.steampowered.com/sub/*",
"webRequest",
"webRequestBlocking"
]
}
background.js
function onHeadersReceived(details) {
const response = {};
if (details.statusCode === 302) {
const matches = details.url.match(/(app|sub)\/(\d+)/);
if (matches) {
const type = matches[1];
const id = matches[2];
response.redirectUrl = `https://steamcommunity.com/${type}/${id}`;
}
}
return response;
}
const filter = {
urls: ['*://*.store.steampowered.com/app/*', '*://*.store.steampowered.com/sub/*'],
types: ['main_frame']
};
const extraInfoSpec = ['blocking'];
chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, filter, extraInfoSpec);
You can see it in action by extracting this .zip file and loading it as an unpacked extension on Chrome:
The webRequest
and webRequestBlocking
permissions could be optional (https://developer.chrome.com/apps/permissions) so that the user grants them only if they want to use this feature.
If this method is acceptable, I can try making a PR.
@rafaelgssa are you planning to make a PR?
Sure, I'll see if I can work on it this week.
Also, like my userscript, pages with error "this is not available in your region" I think should also be redirected.
Made a PR. But I think redirecting games that are not available in the region belong in a separate issue, because that has to be handled in the content script side, it's not possible to detect that through webRequest
. I can try making a PR for that as well, though.
I even have doubts if not available in region apps should be redirected at all. Maybe it's better to just add link to steamdb to that page, so that user could understand, why app is not available, and go to steamdb/community hub if needed.
Made a PR. But I think redirecting games that are not available in the region belong in a separate issue, because that has to be handled in the content script side, it's not possible to detect that through
webRequest
. I can try making a PR for that as well, though.
Sure, it uses a different method, but it still belongs to the redirect feature, as it needs the same user options.
Hmm, I wish I had this feature today. I guess I have to resort to an userscript for now.
IT would be nice to get auto redirected to the comunity hub, if the store page has been removed, for example: Alice: Madness Returns.