Vercel Project Deletion Form Filler

Automatically fills in project deletion form fields on Vercel. This script extracts the project name from the page and fills it into the appropriate input field, along with the verification text. Use with caution as it automates deletion form filling.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Vercel Project Deletion Form Filler
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Automatically fills in project deletion form fields on Vercel. This script extracts the project name from the page and fills it into the appropriate input field, along with the verification text. Use with caution as it automates deletion form filling.
// @author       YourName
// @match        https://vercel.com/*/settings
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to extract project name from HTML
    function getProjectName() {
        const selectors = [
            'b[style*="overflow-wrap: anywhere"]',
            'p strong',
            'label b',
            'p b'
        ];

        for (let selector of selectors) {
            const element = document.querySelector(selector);
            if (element && element.textContent.trim()) {
                return element.textContent.trim();
            }
        }

        return null;
    }

    // Function to fill the form
    function fillForm() {
        const projectName = getProjectName();
        if (!projectName) {
            console.error('Could not find project name');
            return;
        }

        const inputs = Array.from(document.querySelectorAll('input[type="text"]'));

        const projectNameInput = inputs.find(input =>
            input.getAttribute('aria-label')?.toLowerCase().includes('resource name') ||
            input.getAttribute('name')?.toLowerCase().includes('resourcename') ||
            input.getAttribute('placeholder')?.toLowerCase().includes('project name')
        );
        if (projectNameInput) {
            projectNameInput.value = projectName;
            projectNameInput.dispatchEvent(new Event('input', { bubbles: true }));
            projectNameInput.dispatchEvent(new Event('change', { bubbles: true }));
        }

        const verificationInput = inputs.find(input =>
            input.getAttribute('aria-label')?.toLowerCase().includes('verification') ||
            input.getAttribute('name')?.toLowerCase().includes('verification') ||
            input.getAttribute('placeholder')?.toLowerCase().includes('delete my project')
        );
        if (verificationInput) {
            verificationInput.value = 'delete my project';
            verificationInput.dispatchEvent(new Event('input', { bubbles: true }));
            verificationInput.dispatchEvent(new Event('change', { bubbles: true }));
        }
    }

    // Run the function when the page is fully loaded
    window.addEventListener('load', fillForm);

    // Also run it immediately in case the page is already loaded
    fillForm();

    // Add a mutation observer to handle dynamic content loading
    const observer = new MutationObserver((mutations) => {
        for (let mutation of mutations) {
            if (mutation.addedNodes.length) {
                fillForm();
                break;
            }
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();