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, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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);
    });
  }
})();