const url = 'https://test/com?x=a&y=b#old&p=8397543#dsf43';
function getUrlVars(url) {
var vars = {};
var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
console.log(getUrlVars(url)['x']) // a
https://anonystick.com/blog-developer/get-param-from-url-js-tips-javascript-2021051250569666
https://stackoverflow.com/questions/979975/how-to-get-the-value-from-the-get-parameters