CrazyGames+

CrazyGames Sitesi Eğer Türkçe Değilse Otomatik Türkçeye Geçer ve Bazı Gereksiz Görülen Ögeleri Gizler

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         CrazyGames+
// @namespace    http://tampermonkey.net/
// @version      7
// @description  CrazyGames Sitesi Eğer Türkçe Değilse Otomatik Türkçeye Geçer ve Bazı Gereksiz Görülen Ögeleri Gizler
// @author       Atilla
// @match        https://www.crazygames.com/*
// @icon         https://www.crazygames.com/images/logo/logo-ziggy.svg
// @grant        GM_addStyle
// @grant        GM.xmlHttpRequest
// @grant        window.onurlchange
// @require      https://cdnjs.cloudflare.com/ajax/libs/js-cookie/3.0.6/js.cookie.min.js
// @require      https://update.greasyfork.org/scripts/586910/1875145/simple-notify.js
// @license      MIT
// ==/UserScript==

(async () => {
  "use strict";

  // Sabit Seçiciler ve Sınıflar
  const THEME_CSS = `
    [class^='GamePageDesktop_rightSidebar__'] { overflow-y: scroll !important; height: var(--yukseklik) !important; }
    [class^=GamePageDesktop_rightMpuContainer__],
    [class^=GamePageDesktop_leaderboardContainer__],
    [class^=GameInfo_rightColumn__],
    [class*=ThumbVideo],
    [class*=hovered] { display: none !important; }
  `;

  // 1. CSS Kurallarını Tek Seferde Ekle ve Dinamik Yüksekliği Hesapla
  GM_addStyle(THEME_CSS);

  const updateHeight = () => {
    document.documentElement.style.setProperty(
      "--yukseklik",
      `${window.innerHeight * 0.7}px`,
    );
  };
  updateHeight();
  window.addEventListener("resize", updateHeight);

  // Simple-Notify CSS Ekleme
  let css = document.createElement("link");
  css.rel = "stylesheet";
  css.href =
    "https://cdn.jsdelivr.net/npm/simple-notify/dist/simple-notify.css";
  document.head.appendChild(css);

  // 2. Dil Kontrol ve Bildirim Fonksiyonu
  const checkAndSetLanguage = async () => {
    if (window.Cookies.get("czy_locale") === "tr-TR") return;

    window.Cookies.set("czy_locale", "tr-TR", { secure: true, path: "/" });

    new Notify({
      status: "warning",
      title: "Türkçeye Çevrildi",
      text: "Sayfa 3 Saniye İçinde Yenilenecek",
      effect: "slide",
      speed: 300,
      showIcon: false,
      showCloseButton: true,
      autoclose: false,
      type: "filled",
      position: "right top",
    });

    await new Promise((resolve) => setTimeout(resolve, 3000));
    location.reload();
  };

  // 3. Güvenilir Tipler (Trusted Types) Güvenlik Politikası
  if (window.trustedTypes?.createPolicy) {
    window.trustedTypes.createPolicy("default", {
      createHTML: (string) => string,
    });
  }

  // 4. Oyun Beğeni Verilerini Çekme Fonksiyonu
  const fetchAndDisplayRatings = () => {
    if (!location.href.includes("/game/")) return;

    const selector = document.querySelector("h1");
    if (!selector) return;

    const sonuc = location.href.split("/game/")[1]?.split(/[?#]/)[0];
    if (!sonuc) return;

    GM.xmlHttpRequest({
      method: "GET",
      url: `https://api.crazygames.com/v4/en_US/game/${sonuc}/rating`,
      onload: function (response) {
        try {
          const data = JSON.parse(response.responseText);
          let oldText = selector.textContent;

          if (oldText.includes(" / ") && oldText.includes(" | ")) {
            oldText = oldText.split(" | ").slice(1).join(" | ");
          }

          const up = data.upVotes ? data.upVotes.toLocaleString("tr-TR") : "0";
          const down = data.downVotes
            ? data.downVotes.toLocaleString("tr-TR")
            : "0";

          selector.textContent = `${up} / ${down} | ${oldText}`;
        } catch (e) {
          console.error("JSON ayrıştırılamadı:", e);
        }
      },
      onerror: function (error) {
        console.error("İstek sırasında hata oluştu:", error);
      },
    });
  };

  // 5. İlk Çalıştırma ve URL Değişim Takibi
  await checkAndSetLanguage();
  fetchAndDisplayRatings();

  if (window.onurlchange === null) {
    window.addEventListener("urlchange", async () => {
      await checkAndSetLanguage();
      setTimeout(fetchAndDisplayRatings, 500);
    });
  }
})();