Tuesday, 1 September 2026

Script


(async () => {
  const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));

  const getLabel = (el) =>
    (
      el.getAttribute("aria-label") ||
      el.getAttribute("data-value") ||
      el.innerText ||
      el.textContent ||
      ""
    ).trim();

  const setInputValue = (input, value) => {
    const proto =
      input.tagName === "TEXTAREA"
        ? HTMLTextAreaElement.prototype
        : HTMLInputElement.prototype;

    const setter = Object.getOwnPropertyDescriptor(proto, "value")?.set;

    if (setter) {
      setter.call(input, value);
    } else {
      input.value = value;
    }

    input.dispatchEvent(new Event("input", { bubbles: true }));
    input.dispatchEvent(new Event("change", { bubbles: true }));
    input.dispatchEvent(new Event("blur", { bubbles: true }));
  };

  const questions = [
    ...document.querySelectorAll('div[role="listitem"]')
  ];

  // Mengisi pertanyaan Angkatan dengan 35 apabila berbentuk kolom teks
  for (const question of questions) {
    const questionText = (question.innerText || "").toLowerCase();

    if (questionText.includes("angkatan")) {
      const input = question.querySelector(
        'input[type="text"], input[type="number"], textarea'
      );

      if (input) {
        setInputValue(input, "35");
      }
    }
  }

  // Memilih RSUD ULIN Banjarmasin
  const locationOption = [
    ...document.querySelectorAll(
      'div[role="radio"], div[role="checkbox"]'
    )
  ].find((option) =>
    getLabel(option).toLowerCase().includes("rsud ulin")
  );

  if (locationOption) {
    locationOption.click();
  }

  // Memilih Angkatan 35 apabila berbentuk pilihan
  const angkatanOption = [
    ...document.querySelectorAll(
      'div[role="radio"], div[role="checkbox"]'
    )
  ].find((option) => {
    const label = getLabel(option).toLowerCase();
    return label === "35" || label.includes("angkatan 35");
  });

  if (angkatanOption) {
    angkatanOption.click();
  }

  // Memilih semua jawaban "Baik"
  // (dicocokkan persis agar tidak ikut memilih "Sangat Baik")
  const baikOptions = [
    ...document.querySelectorAll(
      'div[role="radio"], div[role="checkbox"]'
    )
  ].filter((option) => getLabel(option).toLowerCase() === "baik");

  baikOptions.forEach((option) => option.click());

  // Mengisi kolom jawaban bebas dengan "Baik",
  // kecuali Nama, NIM, dan Angkatan
  for (const question of questions) {
    const questionText = (question.innerText || "").toLowerCase();

    const harusDilewati =
      questionText.includes("nama mahasiswa") ||
      questionText.includes("nim") ||
      questionText.includes("angkatan");

    if (harusDilewati) continue;

    const inputs = question.querySelectorAll(
      'input[type="text"], textarea'
    );

    inputs.forEach((input) => {
      if (!input.value.trim()) {
        setInputValue(input, "Baik");
      }
    });
  }

  await delay(500);

  console.log(
    `Selesai: ${baikOptions.length} pilihan "Baik" dipilih. ` +
    `Lokasi RSUD Ulin dan Angkatan 35 juga telah dicoba diisi. ` +
    `Silakan periksa jawaban sebelum menekan Kirim.`
  );
})(); 
Share:

0 comments:

Post a Comment

Search This Blog

Muhammad Bukhari. Powered by Blogger.

Labels

Labels

Blogger templates