var blacklist = ["constructor", "__proto__"];

function resolvePath(obj, parts) {
  let target = obj;

  for (let part of parts) {
    if (blacklist.includes(part)) {
      throw new Error("Blacklisted path part");
    }
    if (target[part] === undefined) {
      throw new Error(`Invalid path ${part}`);
    }
    target = target[part];
  }
  return target;
}

function copy(copyTo, copyFrom) {
  const parts = copyTo.split(".");
  const lastPart = parts.pop();

  const target = resolvePath(document.body, parts);
  const value = resolvePath(document.body, copyFrom.split("."));
  target[lastPart] = value;
}

const searchParams = new URLSearchParams(window.location.search);

for (const [name, value] of searchParams.entries()) {
  copy(name, value);
}
