regexes = ["allow", "accept", "agree", "akceptuj", /przejdź(?! do główn).*/];
avoid = ["dostosuj", "don't"];

buttons = Array.from(document.querySelectorAll("*")).filter(
  (e) =>
    e.textContent.length < 50 &&
    regexes.some((regex) => e.textContent.toLowerCase().match(regex) !== null)
);

operations = [
  (buttons) =>
    buttons.filter((button) => {
      const rect = button.getBoundingClientRect();
      return (
        rect.top < window.innerHeight &&
        rect.left < window.innerWidth &&
        !(rect.width == 0 && rect.height == 0)
      );
    }),
  (buttons) =>
    buttons.filter((e) => !e.textContent.toLowerCase().includes("only")),
  (buttons) => buttons.filter((e) => e.tagName.toLowerCase() === "button"),
  (buttons) =>
    buttons.filter((e) => !e.textContent.toLowerCase().includes("do not")),
  (buttons) => buttons.filter((e) => e.tagName.toLowerCase() === "a"),
  (buttons) =>
    buttons.filter((e) =>
      avoid.every((word) => !e.textContent.toLowerCase().includes(word))
    ),
  (buttons) =>
    buttons.filter(
      (e) => e.tagName.toLowerCase() === "input" && e.type === "submit"
    ),
];

for (const operation of operations) {
  if (buttons.length === 1) {
    break;
  }
  const result = operation(buttons);
  if (result.length) {
    buttons = result;
  }
}

buttons.forEach((button) => button.click());
buttons.forEach((button) => {
  button.querySelectorAll("input").forEach((child) => child.click());
});

buttons;
