Greasy Fork镜像 is available in English.

Convert Email Address to Duckduckgo Anonymous email format

Converts an email to duckgo anonymous email format, now with minimize functionality

Fra 01.03.2025. Se den seneste versjonen.

// ==UserScript==
// @name         Convert Email Address to Duckduckgo Anonymous email format
// @namespace    http://tampermonkey.net/
// @author       aspen138
// @version      1.1.2
// @description  Converts an email to duckgo anonymous email format, now with minimize functionality
// @match        https://mail.google.com/*
// @match        https://gmail.com/*
// @match        https://outlook.live.com/*
// @match        https://outlook.com/*
// @match        https://mail.yahoo.com/*
// @match        https://yahoo.com/mail/*
// @match        https://mail.qq.com/*
// @match        https://exmail.qq.com/*
// @match        https://proton.me/*
// @match        https://mail.proton.me/*
// @match        https://icloud.com/mail/*
// @match        https://mail.apple.com/*
// @match        https://zoho.com/mail/*
// @match        https://mail.zoho.com/*
// @match        https://mail.aol.com/*
// @match        https://aol.com/mail/*
// @match        https://www.mail.com/*
// @match        https://email.mail.com/*
// @match        https://mail.yandex.com/*
// @match        https://yandex.com/mail/*
// @match        https://mail.163.com/*
// @match        https://www.163.com/mail/*
// @match        https://mail.126.com/*
// @match        https://www.126.com/*
// @match        https://mail.sina.com/*
// @match        https://mail.sina.com.cn/*
// @match        https://gmx.com/*
// @match        https://mail.gmx.com/*
// @match        https://fastmail.com/*
// @match        https://mail.fastmail.com/*
// @icon         data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiB2aWV3Qm94PSIwIDAgMTI4IDEyOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cGF0aCBmaWxsPSIjZGU1ODMzIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik02NCAxMjhjMzUuMzQ2IDAgNjQtMjguNjU0IDY0LTY0IDAtMzUuMzQ2LTI4LjY1NC02NC02NC02NFMwIDI4LjY1NCAwIDY0YzAgMzUuMzQ2IDI4LjY1NCA2NCA2NCA2NHoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPgogIDxwYXRoIGZp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y40NyAzLjQ3IDAgMCAxIDMuNDc1IDMuNDYgMy40NyAzLjQ3IDAgMCAxLTMuNDc0IDMuNDYyem0yLjQ0Ny00LjYwOGEuODk5Ljg5OSAwIDAgMC0xLjc5OSAwYzAgLjQ5NC40MDUuODk1LjkuODk1LjQ5OSAwIC45LS40LjktLjg5NXptLTI1LjQ2NCAzLjU0MmE0LjA0MiA0LjA0MiAwIDAgMS00LjA0OSA0LjAzNyA0LjA0NSA0LjA0NSAwIDAgMS00LjA1LTQuMDM3IDQuMDQ1IDQuMDQ1IDAgMCAxIDQuMDUtNC4wMzcgNC4wNDUgNC4wNDUgMCAwIDEgNC4wNSA0LjAzN3ptLTEuMTkzLTEuMzM4YTEuMDUgMS4wNSAwIDAgMC0yLjA5NyAwIDEuMDQ3IDEuMDQ3IDAgMCAwIDIuMDk3IDB6IiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz4KICA8L2c+CiAgPHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNjQgMTE3Ljc1YzI5LjY4NSAwIDUzLjc1LTI0LjA2NSA1My43NS01My43NVM5My42ODUgMTAuMjUgNjQgMTAuMjUgMTAuMjUgMzQuMzE1IDEwLjI1IDY0IDM0LjMxNSAxMTcuNzUgNjQgMTE3Ljc1em0wIDVjMzIuNDQ3IDAgNTguNzUtMjYuMzAzIDU4Ljc1LTU4Ljc1Uzk2LjQ0NyA1LjI1IDY0IDUuMjUgNS4yNSAzMS41NTMgNS4yNSA2NCAzMS41NTMgMTIyLjc1IDY0IDEyMi43NXoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPgo8L3N2Zz4K
// @iconbackup         https://ssl.gstatic.com/ui/v1/icons/mail/rfr/gmail.ico
// @license      MIT
// @grant        GM_getValue
// @grant        GM_setValue
// ==/UserScript==

(function() {
    'use strict';

    // Retrieve a stored value for demonstration (not essential for minimizing logic)
    const testStoredSendTo = GM_getValue('whatever', '');
    console.log("testStoredSendTo", testStoredSendTo);

    // Create a container for the floating box
    const container = document.createElement('div');
    container.style.position = 'fixed';
    container.style.bottom = '20px';
    container.style.left = '20px';
    container.style.zIndex = '9999';
    container.style.padding = '10px';
    container.style.backgroundColor = '#fff';
    container.style.border = '1px solid #ccc';
    container.style.borderRadius = '5px';
    container.style.boxShadow = '0 0 5px rgba(0,0,0,0.3)';
    container.style.fontFamily = 'Arial, sans-serif';
    container.style.maxWidth = '280px';

    // Title or heading
    const heading = document.createElement('h4');
    heading.textContent = 'Email Converter';
    heading.style.margin = '0 0 10px 0';
    container.appendChild(heading);

    // Close (minimize) button
    const minimizeButton = document.createElement('button');
    minimizeButton.textContent = 'X';
    minimizeButton.style.position = 'absolute';
    minimizeButton.style.top = '5px';
    minimizeButton.style.right = '10px';
    minimizeButton.style.cursor = 'pointer';
    minimizeButton.style.border = 'none';
    minimizeButton.style.background = 'none';
    minimizeButton.style.fontSize = '16px';
    container.appendChild(minimizeButton);

    // This button will appear when the container is minimized
    const restoreButton = document.createElement('button');
    restoreButton.textContent = 'Email Converter';
    restoreButton.style.position = 'fixed';
    restoreButton.style.left = '0';
    restoreButton.style.bottom = '20px';
    restoreButton.style.zIndex = '9999';
    restoreButton.style.padding = '6px 12px';
    restoreButton.style.cursor = 'pointer';
    restoreButton.style.border = '1px solid #ccc';
    restoreButton.style.borderRadius = '5px';
    restoreButton.style.fontFamily = 'Arial, sans-serif';
    restoreButton.style.backgroundColor = '#fff';
    restoreButton.style.boxShadow = '0 0 5px rgba(0,0,0,0.3)';
    // Initially hidden
    // restoreButton.style.display = 'none';
    container.style.display = 'none';
    restoreButton.style.display = 'block';
    document.body.appendChild(restoreButton);

    // When the user clicks the "X", hide the container and show the restore button
    minimizeButton.addEventListener('click', () => {
        container.style.display = 'none';
        restoreButton.style.display = 'block';
    });

    // When the user clicks restore, show the container and hide the restore button
    restoreButton.addEventListener('click', () => {
        container.style.display = 'block';
        restoreButton.style.display = 'none';
    });

    // Wrapper to neatly organize form elements
    const formWrapper = document.createElement('div');
    formWrapper.style.display = 'flex';
    formWrapper.style.flexDirection = 'column';
    formWrapper.style.gap = '5px';

    // Retrieve stored values (if any)
    const storedSendTo = GM_getValue('converterSendTo', '');
    const storedDdgo = GM_getValue('converterDdgo', '');

    // Label and input for "send email to who?"
    const labelSendTo = document.createElement('label');
    labelSendTo.textContent = 'Send email to who: ';
    labelSendTo.style.marginRight = '10px';

    const inputSendTo = document.createElement('input');
    inputSendTo.type = 'text';
    inputSendTo.placeholder = 'e.g. [email protected]';
    inputSendTo.style.width = '250px';
    inputSendTo.value = storedSendTo;

    const rowSendTo = document.createElement('div');
    rowSendTo.appendChild(labelSendTo);
    rowSendTo.appendChild(inputSendTo);

    // Label and input for "your ddgo mail?"
    const labelDdgo = document.createElement('label');
    labelDdgo.textContent = 'Your DuckduckGo address: ';
    labelDdgo.style.marginRight = '10px';

    const inputDdgo = document.createElement('input');
    inputDdgo.type = 'text';
    inputDdgo.placeholder = 'e.g. [email protected]';
    inputDdgo.style.width = '250px';
    inputDdgo.value = storedDdgo;

    const rowDdgo = document.createElement('div');
    rowDdgo.appendChild(labelDdgo);
    rowDdgo.appendChild(inputDdgo);

    // Convert button
    const buttonConvert = document.createElement('button');
    buttonConvert.textContent = 'Convert';
    buttonConvert.style.marginRight = '10px';
    buttonConvert.style.cursor = 'pointer';
    buttonConvert.style.width = '250px';

    // Output field for converted email
    const labelOutput = document.createElement('label');
    labelOutput.textContent = 'Converted: ';
    labelOutput.style.marginRight = '10px';

    const outputEmail = document.createElement('input');
    outputEmail.type = 'text';
    outputEmail.readOnly = true;
    outputEmail.style.width = '250px';

    const rowOutput = document.createElement('div');
    rowOutput.appendChild(labelOutput);
    rowOutput.appendChild(outputEmail);

    // Feedback or error message area
    const feedback = document.createElement('p');
    feedback.style.color = 'red';
    feedback.style.fontSize = '14px';
    feedback.style.margin = '5px 0 0 0';
    feedback.style.minHeight = '18px';
    feedback.textContent = '';

    // Conversion function
    buttonConvert.addEventListener('click', () => {
        const originalEmail = inputSendTo.value.trim();
        const ddgoEmail = inputDdgo.value.trim();
        let errorMessage = '';

        // Simple validations
        if (!originalEmail) {
            errorMessage = 'Please enter an email address to convert.';
        } else if (!ddgoEmail) {
            errorMessage = 'Please enter your DDG address.';
        }

        // Handle any errors
        if (errorMessage) {
            feedback.textContent = errorMessage;
            outputEmail.value = '';
            return;
        }

        // Replace '@' with '_at_' and append the ddgo email
        const converted = originalEmail.replace(/@/g, '_at_') + '_' + ddgoEmail;
        outputEmail.value = converted;
        feedback.textContent = '';

        // Save inputs to Tampermonkey storage
        GM_setValue('converterSendTo', originalEmail);
        GM_setValue('converterDdgo', ddgoEmail);
    });

    // Assemble elements in the container
    formWrapper.appendChild(rowSendTo);
    formWrapper.appendChild(rowDdgo);
    formWrapper.appendChild(buttonConvert);
    formWrapper.appendChild(rowOutput);
    formWrapper.appendChild(feedback);

    container.appendChild(formWrapper);

    // Finally, attach the container to document body
    document.body.appendChild(container);
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。