kodzik

mail@pastecode.io avatar
unknown
javascript
a year ago
21 kB
96
Indexable
Never
document.addEventListener("keypress", (e) => {
  if (e.keyCode != 92) return;

  const queryPrefix = document
    .querySelector("body > yurt-root-app")
    .shadowRoot.querySelector("redux-provider > yurt-root-app-connected")
    .shadowRoot.querySelector(
      "tcs-view > app-drawer-layout > app-header-layout > yurt-core-router"
    )
    .shadowRoot.querySelector("yurt-review-root")
    .shadowRoot.querySelector("tcs-view > yurt-root-plugin-manager")
    .shadowRoot.querySelector("div > yurt-video-root");

  try {
    const status = queryPrefix.shadowRoot
      .querySelector(
        "yurt-review-layout > tcs-view:nth-child(2) > yurt-video-metadata-panel"
      )
      .shadowRoot.querySelector("div.video > yurt-video-metadata-video")
      .shadowRoot.querySelector(
        "tcs-labeled-list > tcs-labeled-list-item:nth-child(1) > yurt-core-video-status-badge"
      )
      .shadowRoot.querySelector("span");
    status.style.fontSize = "2.5em";
    if (status.textContent === "Not Available") {
      status.style.backgroundColor = "red";
    }
  } catch (e) {}

  if (
    queryPrefix.shadowRoot
      .querySelector(
        "yurt-review-layout > tcs-view:nth-child(2) > yurt-video-metadata-panel"
      )
      .shadowRoot.querySelector("div.video > yurt-video-metadata-video")
      .shadowRoot.querySelector("#decision-panel-custom")
  ) {
    return;
  }
  if (
    queryPrefix.shadowRoot
      .querySelector(
        "yurt-review-layout > tcs-view:nth-child(1) > yurt-video-header"
      )
      .shadowRoot.querySelector(
        "yurt-core-plugin-header > div > yurt-core-header-title-caption"
      )
      .shadowRoot.querySelector("div")
      .textContent.includes("Metrics")
  ) {
    metricsMacro();
    return;
  }

  const targetElement = queryPrefix.shadowRoot
    .querySelector(
      "yurt-review-layout > tcs-view:nth-child(2) > yurt-video-metadata-panel"
    )
    .shadowRoot.querySelector("div.video > yurt-video-metadata-video")
    .shadowRoot.querySelector("tcs-labeled-list");

  const buttonsContainer = document.createElement("div");
  buttonsContainer.setAttribute("id", "decision-panel-custom");
  buttonsContainer.style.display = "flex";
  buttonsContainer.style.gap = "10px";
  buttonsContainer.style.flexWrap = "wrap";
  const decisions = [
    {
      text: "9008",
      action: async () => await approve()
    },
    {
      text: "1022",
      action: async () => await harmfulDangerous()
    },
    {
      text: "1032",
      action: async () => await reject()
    },
    { text: "1029", action: async () => await strikeYM() },
    { text: "1004", action: async () => await provocative() },
    { text: "1026", action: async () => await abuse() },
    { text: "1019", action: async () => await minorFight() },
    { text: "1030", action: async () => await petty() }
  ];

  decisions.forEach((decision, index) => {
    const button = document.createElement("button");
    button.textContent = decision.text;
    button.style.backgroundColor = "black";
    button.style.color = "white";
    button.style.borderRadius = "5px";
    button.style.padding = "3px 10px";
    button.style.border = "2px solid white";
    button.style.width = "40%";
    button.style.cursor = "pointer";
    button.style.boxSizing = "border-box";
    button.style.flex = "1 1 30px";
    button.style.fontSize = "1.2rem";
    button.style.fontWeight = "bold";
    button.addEventListener("click", decision.action);
    buttonsContainer.appendChild(button);
  });

  targetElement.appendChild(buttonsContainer);

  const performClick = async (element) => {
    if (!element) return;
    try {
      await element.click();
    } catch (e) {}
  };

  const performStartingActions = async () => {
    const myReview = queryPrefix.shadowRoot
      ?.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      ?.shadowRoot.querySelector("yurt-core-decision-annotation-tabs")
      ?.shadowRoot.querySelector("#mdc-tab-36");

    const addReview = queryPrefix.shadowRoot
      ?.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      ?.shadowRoot.querySelector(
        "yurt-core-decision-annotation-tabs > div.container > yurt-core-decision-add-review"
      )
      ?.shadowRoot.querySelector("tcs-button");

    const realMinorBtn = queryPrefix.shadowRoot
      ?.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      ?.shadowRoot.querySelector("yurt-core-questionnaire")
      ?.shadowRoot.querySelector(
        "div.questionnaire-content.questionnaire-content-with-helpcenter > yurt-core-label-questionnaire-question-type-mapper.current-question-set"
      )
      ?.shadowRoot.querySelector(
        "yurt-core-label-questionnaire-timeline > yurt-core-label-questionnaire-single-choice"
      )
      ?.shadowRoot.querySelector("#real_minor");

    await performClick(myReview);
    await performClick(addReview);
    await performClick(realMinorBtn);
  };

  const performEndingActions = async () => {
    const shadowRootPrefix = queryPrefix.shadowRoot?.querySelector(
      "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
    );

    const questionnaireButton = shadowRootPrefix.shadowRoot
      ?.querySelector("yurt-core-questionnaire")
      ?.shadowRoot.querySelector(
        "div.questionnaire-navigation > div > slot > tcs-button"
      );

    const acceptPolicyButton = shadowRootPrefix.shadowRoot
      ?.querySelector(
        "yurt-core-decision-annotation-edit > yurt-video-decision-policy-edit"
      )
      ?.shadowRoot.querySelector("#decision-panel-policy-edit")
      ?.shadowRoot.querySelector("#decision-panel-policy-selector")
      ?.shadowRoot.querySelector(
        "tcs-view:nth-child(2) > div > yurt-core-policy-selector-item"
      );

    const saveButton = shadowRootPrefix.shadowRoot
      ?.querySelector("yurt-core-decision-annotation-edit")
      ?.shadowRoot.querySelector("div.action-buttons > tcs-button.save-button");

    const submitButton = shadowRootPrefix.shadowRoot
      ?.querySelector("yurt-core-decision-submit-panel")
      ?.shadowRoot.querySelector("div > tcs-dropdown-button")
      ?.shadowRoot.querySelector("div > tcs-view > tcs-button");

    await performClick(questionnaireButton);
    await performClick(acceptPolicyButton);
    await performClick(saveButton);
    await performClick(submitButton);
  };

  const approve = async () => {
    const shadowRootPrefix = queryPrefix.shadowRoot
      ?.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      ?.shadowRoot.querySelector("yurt-core-questionnaire")
      ?.shadowRoot.querySelector(
        "div.questionnaire-content.questionnaire-content-with-helpcenter > yurt-core-label-questionnaire-question-type-mapper.current-question-set"
      )
      ?.shadowRoot.querySelector(
        "yurt-core-label-questionnaire-timeline > yurt-core-label-questionnaire-single-choice"
      );

    const noneOfTheAbove = shadowRootPrefix?.shadowRoot?.querySelector(
      "#none_of_the_above"
    );
    await performStartingActions();
    await performClick(noneOfTheAbove);
    await performEndingActions();
  };
  const harmfulDangerous = async () => {
    const shadowRootPrefix = queryPrefix.shadowRoot
      ?.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      ?.shadowRoot.querySelector("yurt-core-questionnaire")
      ?.shadowRoot.querySelector(
        "div.questionnaire-content.questionnaire-content-with-helpcenter > yurt-core-label-questionnaire-question-type-mapper.current-question-set"
      )
      ?.shadowRoot.querySelector(
        "yurt-core-label-questionnaire-timeline > yurt-core-label-questionnaire-single-choice"
      );

    const minorHD = shadowRootPrefix?.shadowRoot
      .querySelector("#minors_hd_acts")
      ?.shadowRoot.querySelector("tcs-text-transform")
      ?.shadowRoot.querySelector("span");

    const dangerousSubstance = shadowRootPrefix?.shadowRoot?.querySelector(
      "#dangerous_substance_consumption_tobacco_alcohol_or_drugs"
    );

    const no = shadowRootPrefix?.shadowRoot?.querySelector("#no");

    await performClick(no);
    await performStartingActions();
    await performClick(minorHD);
    await performClick(dangerousSubstance);
    await performEndingActions();
  };

  const reject = async () => {
    const shadowRootPrefix = queryPrefix.shadowRoot
      ?.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      ?.shadowRoot.querySelector("yurt-core-questionnaire")
      ?.shadowRoot.querySelector(
        "div.questionnaire-content.questionnaire-content-with-helpcenter > yurt-core-label-questionnaire-question-type-mapper.current-question-set"
      )
      ?.shadowRoot.querySelector(
        "yurt-core-label-questionnaire-timeline > yurt-core-label-questionnaire-single-choice"
      );

    const minorNu = shadowRootPrefix?.shadowRoot.querySelector(
      "#non_csai_minor_nudity"
    );
    const no = shadowRootPrefix?.shadowRoot.querySelector("#no");
    const nuGe = shadowRootPrefix?.shadowRoot.querySelector("#nude_genitalia");
    const toddler = shadowRootPrefix?.shadowRoot.querySelector(
      "#infant_toddler"
    );
    // const noAgain = shadowRootPrefix.shadowRoot.querySelector("#no");
    await performStartingActions();

    await performClick(minorNu);
    await performClick(no);
    await performClick(nuGe);
    await performClick(toddler);

    await performEndingActions();
  };

  const strikeYM = async () => {
    const shadowRootPrefix = queryPrefix.shadowRoot
      ?.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      ?.shadowRoot.querySelector("yurt-core-questionnaire")
      ?.shadowRoot.querySelector(
        "div.questionnaire-content.questionnaire-content-with-helpcenter > yurt-core-label-questionnaire-question-type-mapper.current-question-set"
      )
      ?.shadowRoot.querySelector(
        "yurt-core-label-questionnaire-timeline > yurt-core-label-questionnaire-single-choice"
      );

    const minorNu = shadowRootPrefix?.shadowRoot.querySelector(
      "#non_csai_minor_nudity"
    );
    const no = shadowRootPrefix?.shadowRoot.querySelector("#no");
    const nuGe = shadowRootPrefix?.shadowRoot.querySelector("#nude_genitalia");
    const YM = shadowRootPrefix?.shadowRoot.querySelector("#younger_minor");
    // const noAgain = shadowRootPrefix.shadowRoot.querySelector("#no");
    await performStartingActions();

    await performClick(minorNu);
    await performClick(no);
    await performClick(nuGe);
    await performClick(YM);

    await performEndingActions();
  };
  const provocative = async () => {
    const shadowRootPrefix = queryPrefix.shadowRoot
      ?.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      ?.shadowRoot.querySelector("yurt-core-questionnaire")
      ?.shadowRoot.querySelector(
        "div.questionnaire-content.questionnaire-content-with-helpcenter > yurt-core-label-questionnaire-question-type-mapper.current-question-set"
      )
      ?.shadowRoot.querySelector(
        "yurt-core-label-questionnaire-timeline > yurt-core-label-questionnaire-single-choice"
      );

    const provocativeBehaviour = shadowRootPrefix?.shadowRoot.querySelector(
      "#minors_provocative_behaviour_asmr"
    );
    // const no = shadowRootPrefix?.shadowRoot.querySelector("#no");
    // const nuGe = shadowRootPrefix?.shadowRoot.querySelector("#nude_genitalia");
    const YM = shadowRootPrefix?.shadowRoot.querySelector("#younger_minor");
    const inappropriate = shadowRootPrefix?.shadowRoot.querySelector(
      "#sexually_inappropriate_behaviour"
    );
    // const noAgain = shadowRootPrefix.shadowRoot.querySelector("#no");
    await performStartingActions();

    await performClick(provocativeBehaviour);
    await performClick(YM);
    await performClick(inappropriate);
    await performEndingActions();
  };
  const abuse = async () => {
    const shadowRootPrefix = queryPrefix.shadowRoot
      ?.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      ?.shadowRoot.querySelector("yurt-core-questionnaire")
      ?.shadowRoot.querySelector(
        "div.questionnaire-content.questionnaire-content-with-helpcenter > yurt-core-label-questionnaire-question-type-mapper.current-question-set"
      )
      ?.shadowRoot.querySelector(
        "yurt-core-label-questionnaire-timeline > yurt-core-label-questionnaire-single-choice"
      );

    const childAbuse = shadowRootPrefix?.shadowRoot.querySelector(
      "#non_sexual_child_abuse"
    );
    const no = shadowRootPrefix?.shadowRoot.querySelector("#no");
    const physical = shadowRootPrefix?.shadowRoot.querySelector(
      "#physical_child_abuse"
    );

    await performStartingActions();
    await performClick(childAbuse);
    await performClick(physical);
    await performClick(no);
    await performEndingActions();
  };
  const minorFight = async () => {
    const shadowRootPrefix = queryPrefix.shadowRoot
      ?.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      ?.shadowRoot.querySelector("yurt-core-questionnaire")
      ?.shadowRoot.querySelector(
        "div.questionnaire-content.questionnaire-content-with-helpcenter > yurt-core-label-questionnaire-question-type-mapper.current-question-set"
      )
      ?.shadowRoot.querySelector(
        "yurt-core-label-questionnaire-timeline > yurt-core-label-questionnaire-single-choice"
      );

    const minorFights = shadowRootPrefix?.shadowRoot.querySelector(
      "#minor_fights"
    );
    const multipleHits = shadowRootPrefix?.shadowRoot.querySelector(
      "#multiple_hits_minor_fighting"
    );
    const no = shadowRootPrefix?.shadowRoot.querySelector("#no");

    await performStartingActions();
    await performClick(minorFights);
    await performClick(multipleHits);
    await performClick(no);
    await performEndingActions();
  };
  const petty = async () => {
    const shadowRootPrefix = queryPrefix.shadowRoot
      ?.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      ?.shadowRoot.querySelector("yurt-core-questionnaire")
      ?.shadowRoot.querySelector(
        "div.questionnaire-content.questionnaire-content-with-helpcenter > yurt-core-label-questionnaire-question-type-mapper.current-question-set"
      )
      ?.shadowRoot.querySelector(
        "yurt-core-label-questionnaire-timeline > yurt-core-label-questionnaire-single-choice"
      );

    const minorSe = shadowRootPrefix?.shadowRoot.querySelector(
      "#minor_sexualisation"
    );
    const pettyComedic = shadowRootPrefix?.shadowRoot.querySelector(
      "#petty_comedic_sexualisation"
    );
    const no = shadowRootPrefix?.shadowRoot.querySelector("#no");

    await performStartingActions();
    await performClick(minorSe);
    await performClick(pettyComedic);
    await performClick(no);
    await performEndingActions();
  };
});

const metricsMacro = () => {
  const queryPrefix = document
    .querySelector("body > yurt-root-app")
    .shadowRoot.querySelector("redux-provider > yurt-root-app-connected")
    .shadowRoot.querySelector(
      "tcs-view > app-drawer-layout > app-header-layout > yurt-core-router"
    )
    .shadowRoot.querySelector("yurt-review-root")
    .shadowRoot.querySelector("tcs-view > yurt-root-plugin-manager")
    .shadowRoot.querySelector("div > yurt-video-root");
  try {
    queryPrefix.shadowRoot
      .querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      .shadowRoot.querySelector("yurt-core-decision-annotation-tabs")
      .shadowRoot.querySelector("#mdc-tab-15")
      .click();
  } catch (e) {}
  try {
    queryPrefix.shadowRoot
      .querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      .shadowRoot.querySelector(
        "yurt-core-decision-annotation-tabs > div.container > yurt-core-decision-add-review"
      )
      .shadowRoot.querySelector("tcs-button")
      .click();
  } catch (e) {}
  try {
    queryPrefix.shadowRoot
      .querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      .shadowRoot.querySelector(
        "yurt-core-decision-annotation-edit > yurt-video-decision-policy-edit"
      )
      .shadowRoot.querySelector("#decision-panel-policy-edit")
      .shadowRoot.querySelector("div > yurt-core-questionnaire")
      .shadowRoot.querySelector(
        "div.questionnaire-content.questionnaire-content-with-helpcenter > yurt-core-label-questionnaire-question-type-mapper"
      )
      .shadowRoot.querySelector(
        "yurt-core-label-questionnaire-timeline > yurt-core-label-questionnaire-single-choice"
      )
      .shadowRoot.querySelector("#other")
      .click();
  } catch (e) {}
  try {
    queryPrefix.shadowRoot
      .querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      .shadowRoot.querySelector(
        "yurt-core-decision-annotation-edit > yurt-video-decision-policy-edit"
      )
      .shadowRoot.querySelector("#decision-panel-policy-edit")
      .shadowRoot.querySelector("div > yurt-core-questionnaire")
      .shadowRoot.querySelector(
        "div.questionnaire-navigation > div > slot > tcs-button"
      )
      .click();
  } catch (e) {}
  try {
    document
      .querySelector("body > yurt-root-app")
      .shadowRoot.querySelector("redux-provider > yurt-root-app-connected")
      .shadowRoot.querySelector(
        "tcs-view > app-drawer-layout > app-header-layout > yurt-core-router"
      )
      .shadowRoot.querySelector("yurt-review-root")
      .shadowRoot.querySelector("tcs-view > yurt-root-plugin-manager")
      .shadowRoot.querySelector("div > yurt-video-root")
      .shadowRoot.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      .shadowRoot.querySelector("yurt-core-decision-annotation-edit")
      .shadowRoot.querySelector("div.action-buttons > tcs-button.save-button")
      .shadowRoot.querySelector("mwc-button")
      .shadowRoot.querySelector("#button")
      .click();
  } catch (e) {}
  try {
    document
      .querySelector("body > yurt-root-app")
      .shadowRoot.querySelector("redux-provider > yurt-root-app-connected")
      .shadowRoot.querySelector(
        "tcs-view > app-drawer-layout > app-header-layout > yurt-core-router"
      )
      .shadowRoot.querySelector("yurt-review-root")
      .shadowRoot.querySelector("tcs-view > yurt-root-plugin-manager")
      .shadowRoot.querySelector("div > yurt-video-root")
      .shadowRoot.querySelector(
        "yurt-review-layout > tcs-view:nth-child(4) > yurt-video-decision-panel-v2"
      )
      .shadowRoot.querySelector("yurt-core-decision-submit-panel")
      .shadowRoot.querySelector("div > tcs-dropdown-button")
      .shadowRoot.querySelector("div > tcs-view > tcs-button")
      .shadowRoot.querySelector("mwc-button")
      .shadowRoot.querySelector("#button")
      .click();
  } catch (e) {}
};

document.addEventListener("keydown", function (event) {
  if (!event.shiftKey) return;
  const videoElement = document
    .querySelector("body > yurt-root-app")
    .shadowRoot.querySelector("redux-provider > yurt-root-app-connected")
    .shadowRoot.querySelector(
      "tcs-view > app-drawer-layout > app-header-layout > yurt-core-router"
    )
    .shadowRoot.querySelector("yurt-review-root")
    .shadowRoot.querySelector("tcs-view > yurt-root-plugin-manager")
    .shadowRoot.querySelector("div > yurt-video-root")
    .shadowRoot.querySelector(
      "yurt-review-layout > tcs-view:nth-child(3) > div > tcs-view > tcs-view > div.video-section > div > yurt-video-player"
    )
    .shadowRoot.querySelector("yurt-core-player-v2")
    .shadowRoot.querySelector("div > div > ytp-player")
    .shadowRoot.querySelector(
      "#movie_player > div.html5-video-container > video"
    );

  if (event.key === ">" && event.shiftKey) {
    var periodKey = new KeyboardEvent("keydown", {
      key: ".",
      code: "Period",
      keyCode: 190,
      which: 190,
      shiftKey: true,
      bubbles: true
    });
    videoElement.dispatchEvent(periodKey);
  }
  if (event.key === "<" && event.shiftKey) {
    console.log("yeah");
    console.log(document.activeElement);
    var periodKey = new KeyboardEvent("keydown", {
      key: ",",
      code: "Period",
      keyCode: 188,
      which: 188,
      shiftKey: true,
      bubbles: true
    });
    videoElement.dispatchEvent(periodKey);
  }
});