您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Converts an email to duckgo anonymous email format, now with minimize functionality
当前为
// ==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/* // @icon 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); })();