YouTube

YouTube Daha Kolay Kullan

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

// ==UserScript==
// @name         YouTube
// @namespace    http://tampermonkey.net
// @version      6
// @description  YouTube Daha Kolay Kullan
// @author       Atilla
// @match        https://www.youtube.com/*
// @icon         https://www.gstatic.com/youtube/img/branding/favicon/favicon_192x192_v2.png
// @grant        GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @noframes
// @require https://cdnjs.cloudflare.com/ajax/libs/arrive/2.5.2/arrive.min.js
// @require https://cdn.jsdelivr.net/npm/[email protected]/notyf.min.js
// @license      MIT
// ==/UserScript==
(async () => {
  if (window.trustedTypes && !window.trustedTypes.defaultPolicy) {
    window.trustedTypes.createPolicy("default", {
      createHTML: (string) => string,
    });
  }

  window.addEventListener("keydown", async (ev) => {
    if (
      ev.ctrlKey &&
      ev.key.toLowerCase() === "f" &&
      location.href.includes("live_chat")
    ) {
      ev.preventDefault();
      let targetName = "";
      try {
        targetName = ytInitialData.contents.liveChatRenderer.viewerName;
      } catch (e) {
        console.error("❌ Kullanıcı adı ytInitialData içinden alınamadı!");
        return;
      }
      if (!targetName) {
        console.error("❌ Kullanıcı adı boş döndü.");
        return;
      }
      console.log(`🔍 Aranan isim: "${targetName}"`);
      const chatItems = document.querySelectorAll(
        "yt-live-chat-text-message-renderer",
      );
      let processedCount = 0;
      for (const item of chatItems) {
        const authorNameEl = item.querySelector("#author-name");
        if (authorNameEl && authorNameEl.textContent.trim() === targetName) {
          const menuButton = item.querySelector("#menu button");
          if (menuButton) {
            menuButton.click();
            await new Promise((resolve) => setTimeout(resolve, 150));
            const menuItems = document.querySelectorAll(
              "ytd-menu-navigation-item-renderer, ytd-menu-service-item-renderer",
            );
            for (const menuItem of menuItems) {
              const stringEl = menuItem.querySelector("yt-formatted-string");
              if (stringEl && stringEl.textContent.trim() === "Kaldır") {
                menuItem.click();
                processedCount++;
                await new Promise((resolve) => setTimeout(resolve, 150));
                break;
              }
            }
          }
        }
      }
      console.log(
        `✅ İşlem tamamlandı! Toplam ${processedCount} adet element için "Kaldır" tıklandı.`,
      );
      if (processedCount > 0) {
        new Notyf({
          duration: 15000,
          position: { x: "right", y: "top" },
          dismissible: true,
        }).success(
          `✅ İşlem tamamlandı! Toplam ${processedCount} adet element için "Kaldır" tıklandı.`,
        );
      } else {
        new Notyf({
          duration: 3000,
          position: { x: "left", y: "top" },
          dismissible: true,
        }).error("Kaldırılacak element bulunamadı");
      }
    }
  });

  let notyfCSS = document.createElement("link");
  notyfCSS.href = "https://cdn.jsdelivr.net/npm/[email protected]/notyf.min.css";
  notyfCSS.rel = "stylesheet";
  document.head.prepend(notyfCSS);

  // Depolama
  let DATA_addTimestampToUrl = GM_getValue("addTimestampToUrl", true);
  //==Depolama==

  GM_registerMenuCommand("Ayarlar: Video Süresini URL'Ye Kaydet", () => {
    let newData = !GM_getValue("addTimestampToUrl", true);
    GM_setValue("addTimestampToUrl", newData);
    console.log(
      "%c 'addTimestampToUrl' Veri Başarıyla Kaydedildi",
      "color: green;",
    );
    new Notyf({
      duration: 3000,
      dismissible: true,
      position: { x: "right", y: "top" },
    }).success(
      `${GM_getValue("addTimestampToUrl", true)} 'addTimestampToUrl' Veri Başarıyla Kaydedildi`,
    );
  });

  // Video Süresini URL'ye Kaydet
  if (DATA_addTimestampToUrl === true) {
    const addTimestampToUrl = () => {
      window.addEventListener("keydown", (e) => {
        if (
          (e.ctrlKey || e.metaKey) &&
          e.key.toLowerCase() === "s" &&
          location.href.includes("watch?v")
        ) {
          e.preventDefault();

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

          const seconds = Math.floor(video.currentTime);
          const url = new URL(window.location.href);

          url.searchParams.set("t", seconds);
          window.history.pushState(null, "", url.toString());
        }
      });
    };

    addTimestampToUrl();
  }

  // Video ön izlemesini kaldır
  document.querySelectorAll("#video-preview").forEach((value) => {
    if (!location.href.includes("shorts") || !location.href.includes("watch")) {
      value.remove();
      console.log(value);
    }
  });

  document.arrive("#video-preview", (newElem) => {
    if (!location.href.includes("shorts") || !location.href.includes("watch")) {
      newElem.remove();
      console.log(newElem);
    }
  });

  document.querySelectorAll("*").forEach((value) => {
    if (value.tagName.startsWith("ANIMATED-THUMBNAIL")) {
      value.remove();
      console.log(value);
    }
  });
  document.arrive("*", (newElem) => {
    if (newElem.tagName.startsWith("ANIMATED-THUMBNAIL")) {
      newElem.remove();
      console.log(newElem);
    }
  });
  //==Video ön izlemesini kaldır==
})();