Sort Vercel Domains

Sort the search results from Vercel Domains (vercel.com/domains)

اعتبارا من 07-04-2023. شاهد أحدث إصدار.

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 or Violentmonkey 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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// @ts-check
// ==UserScript==
// @name         Sort Vercel Domains
// @namespace    https://greasyfork.org/en/users/673321-christianmemije
// @version      0.4
// @description  Sort the search results from Vercel Domains (vercel.com/domains)
// @author       Memije.io
// @match https://vercel.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';
  // @ts-check
  {
    const observer = new MutationObserver((mutations, observer) => {
      const allDomainElems = document.querySelectorAll(
        '[data-testid="domains/search-item"] .INTERNAL_AVAILABLE',
      );

      const domains = Array.from(allDomainElems).map((elem) => {
        const nameEl = elem.querySelector('.query-part');
        const endingEl = elem.querySelector('.tld-part');
        const name = nameEl ? nameEl.textContent : '';
        const ending = endingEl ? endingEl.textContent : '';

        return `${name}${ending}`;
      });
      const sorted = [...domains]
        .sort((a, b) => a.localeCompare(b))
        .sort((a, b) => (a || '').length - (b || '').length);
      if (sorted.length > 0) {
        console.clear();
        console.log(JSON.stringify(sorted));
      }
    });

    // define what element should be observed by the observer
    // and what types of mutations trigger the callback
    observer.observe(document, {
      subtree: true,
      attributes: true,
      //...
    });
  }
})();