CrazyGames+

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu betiği yüklemek için bir betik yöneticisi eklentisi yüklemeniz gerekecektir.

(Zaten bir betik yöneticim var, hadi yükleyelim!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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);
    });
  }
})();