YouTube

YouTube Daha Kolay Kullan

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Advertisement:

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

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