您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Sort the search results from Vercel Domains (vercel.com/domains)
- // @ts-check
- // ==UserScript==
- // @name Sort Vercel Domains
- // @version 0.5
- // @description Sort the search results from Vercel Domains (vercel.com/domains)
- // @match https://vercel.com/*
- // @grant none
- // @license MIT
- // @namespace MEMIJE.IO
- // @author MEMIJE.IO
- // ==/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,
- //...
- });
- }
- })();