Create plain object from URLSearchParams
Since ES6 there is a cleaner solution with Object.fromEntries:
const url = 'https://tempuri.org/?token=secret&amp;test=true';
const params = new URL(url).searchParams;
Object.fromEntries(params);

It will output an object like this:
{ token: 'secret', test: 'true' }

See browser compatibility of Object.fromEntries on MDN. Basically all browsers and Node.js 12+ except Samsung Internet, Opera Android, and Internet Explorer. Time to say goodbye to the old browsers :)