ChromeDetector

Chrome tarayıcıyı tespit etme ve versiyonunu alma

אין להתקין סקריפט זה ישירות. זוהי ספריה עבור סקריפטים אחרים // @require https://update.greasyfork.org/scripts/582434/1849851/ChromeDetector.js

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

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

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

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         ChromeDetector
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Chrome tarayıcıyı tespit etme ve versiyonunu alma
// @author       Atilla
// @license MIT
// ==/UserScript==

/**
 * ============================================================================
 * 🚀 ULTRA SECURE CHROME DETECTOR (POWERED BY BOWSER)
 * ============================================================================
 * 
 * En Kolay Kullanım Örnekleri:
 * 
 * 1. Tarayıcı Gerçek Google Chrome mu? (True/False):
 *    if (ChromeDetector.isChrome()) { console.log("Evet, kesinlikle Chrome!"); }
 * 
 * 2. Chrome Ana Versiyonunu Alma:
 *    const version = ChromeDetector.getMajorVersion(); // Örn: 124 veya null
 * 
 * 3. Detaylı Rapor Alma:
 *    const info = ChromeDetector.getInfo(); // { isChrome: true, majorVersion: 124 }
 * ============================================================================
 */

(function (global) {
  'use strict';

  // Bowser kütüphanesini sayfaya dinamik olarak enjekte eden yardımcı fonksiyon
  function injectBowser() {
    if (global.bowser) return;
    const script = document.createElement('script');
    script.src = 'https://cdnjs.cloudflare.com/ajax/libs/bowser/2.12.1/bundled.js';
    script.async = false; // Kodun sıralı çalışması için senkronize yükleme simülasyonu
    document.head.appendChild(script);
  }

  // Sayfa yüklenirken Bowser'ı arka planda hazırla
  if (typeof document !== 'undefined') {
    injectBowser();
  }

  class ChromeDetector {
    /**
     * Bowser parser nesnesini döndürür.
     * @private
     */
    static _getParser() {
      if (!global.bowser) {
        // Eğer Bowser henüz yüklenmediyse anlık olarak userAgent analizi için fallback yapar
        console.warn("ChromeDetector: Bowser henüz tamamen yüklenmedi, bekleniyor...");
        return null;
      }
      return global.bowser.getParser(global.navigator.userAgent);
    }

    /**
     * Kullanıcının gerçek Google Chrome kullanıp kullanmadığını doğrular.
     * Edge, Opera, Brave, Vivaldi vb. tüm yan sanayi Chromium tarayıcıları eler.
     * @returns {boolean}
     */
    static isChrome() {
      const parser = this._getParser();
      if (!parser) {
        // Bowser yüklenene kadar temel JavaScript kontrolü (Geçici Fallback)
        return navigator.vendor === 'Google Inc.' && !navigator.brave && !navigator.userAgent.includes('Edg');
      }

      // Bowser motor adının Blink (Chrome motoru) ve tarayıcı adının tam olarak Chrome olduğunu doğrular
      const browserName = parser.getBrowserName(); // "Chrome"
      const engineName = parser.getEngineName();   // "Blink"

      return browserName === 'Chrome' && engineName === 'Blink';
    }

    /**
     * Chrome'un Major (Ana) sürüm numarasını sayı (number) olarak döndürür.
     * Tarayıcı Chrome değilse null döner.
     * @returns {number|null} Örn: 124 veya null
     */
    static getMajorVersion() {
      if (!this.isChrome()) return null;

      const parser = this._getParser();
      if (!parser) {
        const match = global.navigator.userAgent.match(/(?:Chrome|CriOS)\/([0-9]+)/);
        return match ? parseInt(match[1], 10) : null;
      }

      const versionStr = parser.getBrowserVersion(); // Örn: "124.0.6367.61"
      if (!versionStr) return null;

      return parseInt(versionStr.split('.')[0], 10);
    }

    /**
     * Tüm bilgileri tek bir pratik nesne (object) içinde döndürür.
     * @returns {Object} { isChrome: boolean, majorVersion: number|null }
     */
    static getInfo() {
      return {
        isChrome: this.isChrome(),
        majorVersion: this.getMajorVersion()
      };
    }
  }

  // Global window nesnesine bağlama (Evrensel kütüphane desteği)
  if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
    module.exports = ChromeDetector;
  } else {
    global.ChromeDetector = ChromeDetector;
  }

})(typeof window !== 'undefined' ? window : this);