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.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

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