Greasy Fork 支持简体中文。

Convert Email Address to Duckduckgo Anonymous email format

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

目前為 2025-03-01 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Convert Email Address to Duckduckgo Anonymous email format
  3. // @namespace http://tampermonkey.net/
  4. // @author aspen138
  5. // @version 1.1.2
  6. // @description Converts an email to duckgo anonymous email format, now with minimize functionality
  7. // @match https://mail.google.com/*
  8. // @match https://gmail.com/*
  9. // @match https://outlook.live.com/*
  10. // @match https://outlook.com/*
  11. // @match https://mail.yahoo.com/*
  12. // @match https://yahoo.com/mail/*
  13. // @match https://mail.qq.com/*
  14. // @match https://exmail.qq.com/*
  15. // @match https://proton.me/*
  16. // @match https://mail.proton.me/*
  17. // @match https://icloud.com/mail/*
  18. // @match https://mail.apple.com/*
  19. // @match https://zoho.com/mail/*
  20. // @match https://mail.zoho.com/*
  21. // @match https://mail.aol.com/*
  22. // @match https://aol.com/mail/*
  23. // @match https://www.mail.com/*
  24. // @match https://email.mail.com/*
  25. // @match https://mail.yandex.com/*
  26. // @match https://yandex.com/mail/*
  27. // @match https://mail.163.com/*
  28. // @match https://www.163.com/mail/*
  29. // @match https://mail.126.com/*
  30. // @match https://www.126.com/*
  31. // @match https://mail.sina.com/*
  32. // @match https://mail.sina.com.cn/*
  33. // @match https://gmx.com/*
  34. // @match https://mail.gmx.com/*
  35. // @match https://fastmail.com/*
  36. // @match https://mail.fastmail.com/*
  37. // @icon https://ssl.gstatic.com/ui/v1/icons/mail/rfr/gmail.ico
  38. // @license MIT
  39. // @grant GM_getValue
  40. // @grant GM_setValue
  41. // ==/UserScript==
  42.  
  43. (function() {
  44. 'use strict';
  45.  
  46. // Retrieve a stored value for demonstration (not essential for minimizing logic)
  47. const testStoredSendTo = GM_getValue('whatever', '');
  48. console.log("testStoredSendTo", testStoredSendTo);
  49.  
  50. // Create a container for the floating box
  51. const container = document.createElement('div');
  52. container.style.position = 'fixed';
  53. container.style.bottom = '20px';
  54. container.style.left = '20px';
  55. container.style.zIndex = '9999';
  56. container.style.padding = '10px';
  57. container.style.backgroundColor = '#fff';
  58. container.style.border = '1px solid #ccc';
  59. container.style.borderRadius = '5px';
  60. container.style.boxShadow = '0 0 5px rgba(0,0,0,0.3)';
  61. container.style.fontFamily = 'Arial, sans-serif';
  62. container.style.maxWidth = '280px';
  63.  
  64. // Title or heading
  65. const heading = document.createElement('h4');
  66. heading.textContent = 'Email Converter';
  67. heading.style.margin = '0 0 10px 0';
  68. container.appendChild(heading);
  69.  
  70. // Close (minimize) button
  71. const minimizeButton = document.createElement('button');
  72. minimizeButton.textContent = 'X';
  73. minimizeButton.style.position = 'absolute';
  74. minimizeButton.style.top = '5px';
  75. minimizeButton.style.right = '10px';
  76. minimizeButton.style.cursor = 'pointer';
  77. minimizeButton.style.border = 'none';
  78. minimizeButton.style.background = 'none';
  79. minimizeButton.style.fontSize = '16px';
  80. container.appendChild(minimizeButton);
  81.  
  82. // This button will appear when the container is minimized
  83. const restoreButton = document.createElement('button');
  84. restoreButton.textContent = 'Email Converter';
  85. restoreButton.style.position = 'fixed';
  86. restoreButton.style.left = '0';
  87. restoreButton.style.bottom = '20px';
  88. restoreButton.style.zIndex = '9999';
  89. restoreButton.style.padding = '6px 12px';
  90. restoreButton.style.cursor = 'pointer';
  91. restoreButton.style.border = '1px solid #ccc';
  92. restoreButton.style.borderRadius = '5px';
  93. restoreButton.style.fontFamily = 'Arial, sans-serif';
  94. restoreButton.style.backgroundColor = '#fff';
  95. restoreButton.style.boxShadow = '0 0 5px rgba(0,0,0,0.3)';
  96. // Initially hidden
  97. // restoreButton.style.display = 'none';
  98. container.style.display = 'none';
  99. restoreButton.style.display = 'block';
  100. document.body.appendChild(restoreButton);
  101.  
  102. // When the user clicks the "X", hide the container and show the restore button
  103. minimizeButton.addEventListener('click', () => {
  104. container.style.display = 'none';
  105. restoreButton.style.display = 'block';
  106. });
  107.  
  108. // When the user clicks restore, show the container and hide the restore button
  109. restoreButton.addEventListener('click', () => {
  110. container.style.display = 'block';
  111. restoreButton.style.display = 'none';
  112. });
  113.  
  114. // Wrapper to neatly organize form elements
  115. const formWrapper = document.createElement('div');
  116. formWrapper.style.display = 'flex';
  117. formWrapper.style.flexDirection = 'column';
  118. formWrapper.style.gap = '5px';
  119.  
  120. // Retrieve stored values (if any)
  121. const storedSendTo = GM_getValue('converterSendTo', '');
  122. const storedDdgo = GM_getValue('converterDdgo', '');
  123.  
  124. // Label and input for "send email to who?"
  125. const labelSendTo = document.createElement('label');
  126. labelSendTo.textContent = 'Send email to who: ';
  127. labelSendTo.style.marginRight = '10px';
  128.  
  129. const inputSendTo = document.createElement('input');
  130. inputSendTo.type = 'text';
  131. inputSendTo.placeholder = 'e.g. 123@qq.com';
  132. inputSendTo.style.width = '250px';
  133. inputSendTo.value = storedSendTo;
  134.  
  135. const rowSendTo = document.createElement('div');
  136. rowSendTo.appendChild(labelSendTo);
  137. rowSendTo.appendChild(inputSendTo);
  138.  
  139. // Label and input for "your ddgo mail?"
  140. const labelDdgo = document.createElement('label');
  141. labelDdgo.textContent = 'Your DuckduckGo address: ';
  142. labelDdgo.style.marginRight = '10px';
  143.  
  144. const inputDdgo = document.createElement('input');
  145. inputDdgo.type = 'text';
  146. inputDdgo.placeholder = 'e.g. dd@duck.com';
  147. inputDdgo.style.width = '250px';
  148. inputDdgo.value = storedDdgo;
  149.  
  150. const rowDdgo = document.createElement('div');
  151. rowDdgo.appendChild(labelDdgo);
  152. rowDdgo.appendChild(inputDdgo);
  153.  
  154. // Convert button
  155. const buttonConvert = document.createElement('button');
  156. buttonConvert.textContent = 'Convert';
  157. buttonConvert.style.marginRight = '10px';
  158. buttonConvert.style.cursor = 'pointer';
  159. buttonConvert.style.width = '250px';
  160.  
  161. // Output field for converted email
  162. const labelOutput = document.createElement('label');
  163. labelOutput.textContent = 'Converted: ';
  164. labelOutput.style.marginRight = '10px';
  165.  
  166. const outputEmail = document.createElement('input');
  167. outputEmail.type = 'text';
  168. outputEmail.readOnly = true;
  169. outputEmail.style.width = '250px';
  170.  
  171. const rowOutput = document.createElement('div');
  172. rowOutput.appendChild(labelOutput);
  173. rowOutput.appendChild(outputEmail);
  174.  
  175. // Feedback or error message area
  176. const feedback = document.createElement('p');
  177. feedback.style.color = 'red';
  178. feedback.style.fontSize = '14px';
  179. feedback.style.margin = '5px 0 0 0';
  180. feedback.style.minHeight = '18px';
  181. feedback.textContent = '';
  182.  
  183. // Conversion function
  184. buttonConvert.addEventListener('click', () => {
  185. const originalEmail = inputSendTo.value.trim();
  186. const ddgoEmail = inputDdgo.value.trim();
  187. let errorMessage = '';
  188.  
  189. // Simple validations
  190. if (!originalEmail) {
  191. errorMessage = 'Please enter an email address to convert.';
  192. } else if (!ddgoEmail) {
  193. errorMessage = 'Please enter your DDG address.';
  194. }
  195.  
  196. // Handle any errors
  197. if (errorMessage) {
  198. feedback.textContent = errorMessage;
  199. outputEmail.value = '';
  200. return;
  201. }
  202.  
  203. // Replace '@' with '_at_' and append the ddgo email
  204. const converted = originalEmail.replace(/@/g, '_at_') + '_' + ddgoEmail;
  205. outputEmail.value = converted;
  206. feedback.textContent = '';
  207.  
  208. // Save inputs to Tampermonkey storage
  209. GM_setValue('converterSendTo', originalEmail);
  210. GM_setValue('converterDdgo', ddgoEmail);
  211. });
  212.  
  213. // Assemble elements in the container
  214. formWrapper.appendChild(rowSendTo);
  215. formWrapper.appendChild(rowDdgo);
  216. formWrapper.appendChild(buttonConvert);
  217. formWrapper.appendChild(rowOutput);
  218. formWrapper.appendChild(feedback);
  219.  
  220. container.appendChild(formWrapper);
  221.  
  222. // Finally, attach the container to document body
  223. document.body.appendChild(container);
  224. })();