GreasyFork Script Bulucu

Ziyaret ettiğiniz site için Greasy Fork'taki kullanıcı scriptlerini hızlıca bulur.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Advertisement:

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

Advertisement:

// ==UserScript==
// @name                 GreasyFork Script Bulucu
// @namespace            https://github.com/utags
// @homepageURL          https://github.com/utags/userscripts#readme
// @supportURL           https://github.com/utags/userscripts/issues
// @version              1
// @description          Ziyaret ettiğiniz site için Greasy Fork'taki kullanıcı scriptlerini hızlıca bulur.
// @author               Atilla
// @license              MIT
// @match                *://*/*
// @icon                https://greasyfork.org/vite/assets/blacklogo96-CxYTSM_T.png
// @noframes
// @grant                GM_registerMenuCommand
// @grant                GM_openInTab
// ==/UserScript==
//
(() => {
  "use strict";
  var __defProp = Object.defineProperty;
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  var __hasOwnProp = Object.prototype.hasOwnProperty;
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
  var __defNormalProp = (obj, key, value) =>
    key in obj
      ? __defProp(obj, key, {
          enumerable: true,
          configurable: true,
          writable: true,
          value,
        })
      : (obj[key] = value);
  var __spreadValues = (a, b) => {
    for (var prop in b || (b = {}))
      if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
    if (__getOwnPropSymbols)
      for (var prop of __getOwnPropSymbols(b)) {
        if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
      }
    return a;
  };
  function registerMenu(caption, onClick, options) {
    if (typeof GM_registerMenuCommand === "function") {
      return GM_registerMenuCommand(caption, onClick, options);
    }
    return 0;
  }
  function unregisterMenu(menuId) {
    if (typeof GM_unregisterMenuCommand === "function") {
      GM_unregisterMenuCommand(menuId);
    }
  }
  function openInTab(url, options) {
    if (typeof GM_openInTab === "function") {
      GM_openInTab(url, options);
      return;
    }
    globalThis.open(url, "_blank");
  }
  var valueChangeListenerIdCounter = 0;
  var lastKnownValues = /* @__PURE__ */ new Map();
  var pollingIntervalId = null;
  var pollingEnabled = false;
  var doc = document;
  function c(tag, opts) {
    const el = doc.createElement(tag);
    if (!opts) return el;
    if (opts.className) el.className = opts.className;
    if (opts.classes) for (const cls of opts.classes) el.classList.add(cls);
    if (opts.dataset && el.dataset)
      for (const k of Object.keys(opts.dataset))
        el.dataset[k] = opts.dataset[k];
    if (opts.attrs)
      for (const k of Object.keys(opts.attrs))
        el.setAttribute(k, opts.attrs[k]);
    if (opts.style)
      for (const k of Object.keys(opts.style)) el.style[k] = opts.style[k];
    if ("text" in opts) el.textContent = opts.text || "";
    if (opts.type && "type" in el) el.type = opts.type;
    if ("value" in opts && "value" in el) el.value = opts.value || "";
    if (opts.rows && "rows" in el) el.rows = opts.rows;
    if (opts.placeholder && "placeholder" in el)
      el.placeholder = opts.placeholder;
    if (typeof opts.checked === "boolean" && "checked" in el)
      el.checked = opts.checked;
    if (opts.children) {
      for (const ch of opts.children) {
        if (typeof ch === "string") el.append(doc.createTextNode(ch));
        else el.append(ch);
      }
    }
    return el;
  }
  var win = globalThis;
  function isTopFrame() {
    return win.self === win.top;
  }
  var currentHost;
  function onKeyDown(e) {
    if (e.key === "Escape") {
    }
  }
  function extractDomain(url) {
    try {
      let hostname;
      if (url) {
        try {
          hostname = new URL(url).hostname;
        } catch (e) {
          hostname = url;
        }
      } else {
        hostname = win.location.hostname;
      }
      let domain = hostname.replace(/^www\./, "");
      const parts = domain.split(".");
      if (parts.length > 2) {
        const secondLevelDomains = [
          "co",
          "com",
          "org",
          "net",
          "edu",
          "gov",
          "mil",
        ];
        const thirdLevelDomain = parts[parts.length - 2];
        domain =
          parts.length > 2 && secondLevelDomains.includes(thirdLevelDomain)
            ? parts.slice(-3).join(".")
            : parts.slice(-2).join(".");
      }
      return domain;
    } catch (e) {
      return url || win.location.hostname || "";
    }
  }
  var CONFIG = {
    REPOSITORIES: [
      {
        id: "greasy_fork",
        name: "Greasy Fork",
        domainSearchUrl:
          "https://greasyfork.org/scripts/by-site/{domain}?filter_locale=0",
        domainSearchEnabled: true,
        keywordSearchUrl:
          "https://greasyfork.org/scripts?filter_locale=0&q={keyword}",
        keywordSearchEnabled: true,
        icon: "\u{1F374}",
      },
    ],
    DEBUG: false,
  };
  var I18N = {
    en: {
      menu_domain: "Greasy Fork'de alan adına göre bul",
      menu_keyword: "Greasy Fork'de anahtar kelimeye göre ara",
      // title_settings: "Depo Ayarları",
      // btn_save: "Kaydet",
      // btn_cancel: "İptal",
      // title_domain: "Alan Adı Arama",
      // title_keyword: "Anahtar Kelime Arama",
      // menu_settings: "\u2699\uFE0F Ayarlar",
    },
  };
  var USER_LANG = detectLanguage();
  var LANG_MAP =
    USER_LANG === "en"
      ? I18N.en
      : __spreadValues(__spreadValues({}, I18N.en), I18N[USER_LANG]);
  function t(key) {
    return LANG_MAP[key];
  }
  function detectLanguage() {
    try {
      const browserLang = (
        navigator.language ||
        navigator.userLanguage ||
        "en"
      ).toLowerCase();
      const supportedLangs = Object.keys(I18N);
      if (supportedLangs.includes(browserLang)) {
        return browserLang;
      }
      const langBase = browserLang.split("-")[0];
      const matchingLang = supportedLangs.find((lang) =>
        lang.startsWith(langBase + "-"),
      );
      if (matchingLang) {
        return matchingLang;
      }
      return "en";
    } catch (error) {
      debugLog("Error detecting language:", error);
      return "en";
    }
  }
  function debugLog(message, data = null) {
    if (CONFIG.DEBUG) {
      console.log("[Find Scripts] ".concat(message), data || "");
    }
  }
  function getLocalizedMenuText(repo, isKeywordSearch = false) {
    const key = isKeywordSearch ? "menu_keyword" : "menu_domain";
    const template = t(key);
    return template.replace("{icon}", repo.icon).replace("{name}", repo.name);
  }
  var MENU_IDS = [];
  var SETTINGS_MENU_ID;
  function clearMenus() {
    for (const id of MENU_IDS) {
      unregisterMenu(id);
    }
    MENU_IDS = [];
    if (SETTINGS_MENU_ID) {
      unregisterMenu(SETTINGS_MENU_ID);
      SETTINGS_MENU_ID = void 0;
    }
  }
  function registerAllMenus() {
    const domain = extractDomain();
    registerMenuCommands(domain);
  }
  function registerMenuCommands(domain) {
    for (const repo of CONFIG.REPOSITORIES) {
      const domainEnabled = Boolean(
        CURRENT_SETTINGS["domain_".concat(repo.id)],
      );
      if (repo.domainSearchUrl && domainEnabled) {
        const url = repo.domainSearchUrl.replace("{domain}", domain);
        const menuText = getLocalizedMenuText(repo);
        const id = registerMenu(menuText, () => {
          debugLog("Opening ".concat(repo.name, " for domain:"), domain);
          openInTab(url, { active: true, insert: true });
        });
        MENU_IDS.push(id);
      }
      const keywordEnabled = Boolean(
        CURRENT_SETTINGS["keyword_".concat(repo.id)],
      );
      if (repo.keywordSearchUrl && keywordEnabled) {
        const keywordUrl = repo.keywordSearchUrl.replace("{keyword}", domain);
        const keywordMenuText = getLocalizedMenuText(repo, true);
        const id = registerMenu(keywordMenuText, () => {
          debugLog(
            "Opening ".concat(repo.name, " for keyword search:"),
            domain,
          );
          openInTab(keywordUrl, { active: true, insert: true });
        });
        MENU_IDS.push(id);
      }
    }
  }
  var CURRENT_SETTINGS = {
    domain_greasy_fork: true,
    keyword_greasy_fork: true,
  };
  function buildDefaults() {
    var _a, _b;
    const out = {};
    for (const repo of CONFIG.REPOSITORIES) {
      if (repo.domainSearchUrl)
        out["domain_".concat(repo.id)] =
          (_a = repo.domainSearchEnabled) != null ? _a : false;
      if (repo.keywordSearchUrl)
        out["keyword_".concat(repo.id)] =
          (_b = repo.keywordSearchEnabled) != null ? _b : false;
    }
    return out;
  }
  async function initialize() {
    registerAllMenus();
  }
  void initialize();
})();