ScriptedEngineer / steamcommunity.com to Steam APP redirect

// ==UserScript==
// @name         steamcommunity.com to Steam APP redirect
// @namespace    https://openuserjs.org/users/ScriptedEngineer
// @version      0.1
// @description  redirect from steamcommunity.com to windows steam application
// @author       ScriptedEngineer
// @match        *://steamcommunity.com/*
// @grant        window.close
// @updateURL    https://openuserjs.org/meta/ScriptedEngineer/steamcommunity.com_to_Steam_APP_redirect.meta.js
// @downloadURL   https://openuserjs.org/install/ScriptedEngineer/steamcommunity.com_to_Steam_APP_redirect.user.js
// @copyright    2020, ScriptedEngineer (https://openuserjs.org/users/ScriptedEngineer)
// @license      GPL-3.0-or-later
// ==/UserScript==

var linkfields = window.location.pathname.split('/');
var query = parseQuery(window.location.search);
switch(linkfields[1]){
    case "id":
        window.location = "steam://openurl/"+window.location;
        window.close();
        break;
    case "profiles":
        window.location = "steam://url/SteamIDPage/"+linkfields[2];
        window.close();
        break;
    case "workshop":
    case "sharedfiles":
        switch(linkfields[2])
        {
            case "filedetails":
                window.location = "steam://url/CommunityFilePage/"+query.id;
                window.close();
                break;
        }
        break;
    default:
        window.location = "steam://openurl/"+window.location;
        break;
}


function parseQuery(queryString) {
    var query = {};
    var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
    for (var i = 0; i < pairs.length; i++) {
        var pair = pairs[i].split('=');
        query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
    }
    return query;
}