shensuming commited on
Commit
2d520cd
·
verified ·
1 Parent(s): a5d3136

Update data.html

Browse files
Files changed (1) hide show
  1. data.html +66 -67
data.html CHANGED
@@ -8,7 +8,7 @@
8
  <body class="bg-slate-50 min-h-screen">
9
  <div class="max-w-4xl mx-auto py-12 px-6">
10
  <h1 class="text-3xl font-bold text-slate-900 mb-2 tracking-tight">📋 数据整理</h1>
11
- <p class="text-sm text-slate-500 mb-8">粘贴生数据 → 格式清洗 + 去重 → 复制干净列表 → 拿去发送</p>
12
 
13
  <!-- 退信记录管理 -->
14
  <div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-8 space-y-6 mb-8">
@@ -25,50 +25,46 @@
25
  <div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-8 space-y-6">
26
  <div>
27
  <label class="block text-sm font-semibold text-slate-700 mb-2">粘贴生数据</label>
28
- <textarea id="rawInput" rows="10" placeholder="每行一个邮箱地址..." class="w-full px-4 py-3 border border-slate-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:outline-none text-sm font-mono resize-y"></textarea>
29
  </div>
30
  <div class="flex items-center gap-4">
31
- <button onclick="processData()" class="bg-blue-600 text-white px-8 py-3 rounded-xl hover:bg-blue-700 shadow-lg font-bold transition active:scale-95">🔍 整理</button>
32
  <button onclick="copyResult()" class="bg-emerald-600 text-white px-8 py-3 rounded-xl hover:bg-emerald-700 shadow-lg font-bold transition active:scale-95 hidden" id="copyBtn">📋 复制结果</button>
33
  <span id="processStatus" class="text-sm text-slate-500"></span>
34
  </div>
 
 
 
 
 
 
 
35
  <div id="resultArea" class="hidden mt-4 p-4 bg-slate-50 rounded-xl border border-slate-200">
36
  <div class="text-sm font-semibold text-slate-700 mb-2">整理结果:</div>
37
  <div id="resultStats" class="text-xs text-slate-500 mb-3 space-y-1"></div>
38
- <textarea id="resultOutput" rows="8" readonly class="w-full px-4 py-3 border border-slate-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:outline-none text-sm font-mono resize-y bg-white"></textarea>
39
  </div>
40
  </div>
41
  </div>
42
  <script>
43
- // ========== 退信管理 ==========
44
  const BOUNCE_KEY = 'data_bounce_list';
 
 
45
  function getBounces() {
46
  try { return JSON.parse(localStorage.getItem(BOUNCE_KEY) || '[]'); } catch(e) { return []; }
47
  }
48
- function saveBounces(list) {
49
- localStorage.setItem(BOUNCE_KEY, JSON.stringify(list));
50
- }
51
- function updateBounceCount() {
52
- document.getElementById('bounceCount').textContent = getBounces().length;
53
- }
54
  updateBounceCount();
55
 
56
  function loadBounceFiles(files) {
57
- let bounces = getBounces();
58
- let added = 0;
59
- let processed = 0;
60
  const total = files.length;
61
  for (const file of files) {
62
  const reader = new FileReader();
63
  reader.onload = function(e) {
64
- const content = e.target.result;
65
- const emails = content.split(/[\n\r]+/).map(l => l.trim()).filter(l => l && l.includes('@'));
66
- for (const email of emails) {
67
- if (!bounces.includes(email)) {
68
- bounces.push(email);
69
- added++;
70
- }
71
- }
72
  processed++;
73
  if (processed === total) {
74
  saveBounces(bounces);
@@ -82,77 +78,80 @@
82
  }
83
 
84
  function clearBounceData() {
85
- if (confirm('确定要清空所有退信记录吗?')) {
86
- saveBounces([]);
87
- updateBounceCount();
88
- document.getElementById('bounceStatus').textContent = '已记录 0 个退信地址';
89
- }
90
  }
91
 
92
- // ========== 数据整理 ==========
93
- function processData() {
94
  const raw = document.getElementById('rawInput').value;
95
- const bounces = getBounces();
96
- const resultOutput = document.getElementById('resultOutput');
97
- const resultArea = document.getElementById('resultArea');
98
- const resultStats = document.getElementById('resultStats');
99
- const copyBtn = document.getElementById('copyBtn');
100
- const processStatus = document.getElementById('processStatus');
101
-
102
- if (!raw.trim()) {
103
- processStatus.textContent = '请先粘贴邮箱地址';
104
- processStatus.className = 'text-sm text-red-500';
105
- return;
106
- }
107
 
108
- // 通用邮箱黑名单
109
- const genericPrefixes = ['info','admin','support','hr','sales','contact','office','service','webmaster','marketing','business','help','jobs','careers','press','media','news','noreply','no-reply','mail','postmaster','abuse'];
110
 
111
- // 1. 分割并清洗空行/空格
 
 
112
  const lines = raw.split(/[\n\r]+/).map(l => l.trim()).filter(l => l);
 
113
 
114
- // 2. 格式过滤:必须包含 @ 且不包含空格
115
  const validFormat = lines.filter(l => l.includes('@') && !l.includes(' '));
 
116
 
117
  // 3. 过滤通用邮箱
118
- const notGeneric = validFormat.filter(l => {
119
- const prefix = l.split('@')[0].toLowerCase();
120
- return !genericPrefixes.includes(prefix);
121
- });
122
 
123
- // 4. 本批去重
124
  const unique = [...new Set(notGeneric)];
 
125
 
126
- // 5. 过滤退信记录
127
- const clean = unique.filter(l => !bounces.includes(l));
 
128
 
129
- // 统计
130
  const stats = [
131
  `原始行数:${lines.length} 条`,
132
- `格式过滤:去掉 ${lines.length - validFormat.length} 条(不含@或含空格)`,
133
- `通用邮箱:去掉 ${validFormat.length - notGeneric.length} 条(info/admin/support等)`,
134
  `本批去重:去掉 ${notGeneric.length - unique.length} 条`,
135
  `退信过滤:去掉 ${unique.length - clean.length} 条`,
136
  `最终可用:${clean.length} 条`
137
  ];
 
 
 
 
138
 
139
- resultOutput.value = clean.join('\n');
140
- resultStats.innerHTML = stats.map(s => `<div>${s}</div>`).join('');
141
- resultArea.classList.remove('hidden');
142
- copyBtn.classList.remove('hidden');
143
- processStatus.textContent = `整理完成,最终可用 ${clean.length} 条`;
144
- processStatus.className = 'text-sm text-emerald-600';
145
  }
146
 
147
  function copyResult() {
148
- const resultOutput = document.getElementById('resultOutput');
149
- if (!resultOutput.value) return;
150
- navigator.clipboard.writeText(resultOutput.value).then(() => {
151
- const processStatus = document.getElementById('processStatus');
152
- processStatus.textContent = '已复制到剪贴板,现在可以去 CRM 或 SES 页面粘贴发送';
153
- processStatus.className = 'text-sm text-emerald-600';
154
  });
155
  }
 
 
 
 
 
 
156
  </script>
157
  </body>
158
  </html>
 
8
  <body class="bg-slate-50 min-h-screen">
9
  <div class="max-w-4xl mx-auto py-12 px-6">
10
  <h1 class="text-3xl font-bold text-slate-900 mb-2 tracking-tight">📋 数据整理</h1>
11
+ <p class="text-sm text-slate-500 mb-8">粘贴生数据 → 格式清洗 + 去重 → 复制干净列表 → 拿去 CRM/SES 发送</p>
12
 
13
  <!-- 退信记录管理 -->
14
  <div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-8 space-y-6 mb-8">
 
25
  <div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-8 space-y-6">
26
  <div>
27
  <label class="block text-sm font-semibold text-slate-700 mb-2">粘贴生数据</label>
28
+ <textarea id="rawInput" rows="12" placeholder="每行一个邮箱地址..." class="w-full px-4 py-3 border border-slate-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:outline-none text-sm font-mono resize-y"></textarea>
29
  </div>
30
  <div class="flex items-center gap-4">
31
+ <button onclick="processData()" id="processBtn" class="bg-blue-600 text-white px-8 py-3 rounded-xl hover:bg-blue-700 shadow-lg font-bold transition active:scale-95">🔍 整理</button>
32
  <button onclick="copyResult()" class="bg-emerald-600 text-white px-8 py-3 rounded-xl hover:bg-emerald-700 shadow-lg font-bold transition active:scale-95 hidden" id="copyBtn">📋 复制结果</button>
33
  <span id="processStatus" class="text-sm text-slate-500"></span>
34
  </div>
35
+ <!-- 进度条 -->
36
+ <div id="progressBar" class="hidden mt-2">
37
+ <div class="h-2 bg-slate-200 rounded-full overflow-hidden">
38
+ <div id="progressFill" class="h-full bg-blue-500 transition-all duration-300" style="width:0%"></div>
39
+ </div>
40
+ <div id="progressText" class="text-xs text-slate-400 mt-1"></div>
41
+ </div>
42
  <div id="resultArea" class="hidden mt-4 p-4 bg-slate-50 rounded-xl border border-slate-200">
43
  <div class="text-sm font-semibold text-slate-700 mb-2">整理结果:</div>
44
  <div id="resultStats" class="text-xs text-slate-500 mb-3 space-y-1"></div>
45
+ <textarea id="resultOutput" rows="10" readonly class="w-full px-4 py-3 border border-slate-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:outline-none text-sm font-mono resize-y bg-white"></textarea>
46
  </div>
47
  </div>
48
  </div>
49
  <script>
 
50
  const BOUNCE_KEY = 'data_bounce_list';
51
+ const GENERIC_PREFIXES = ['info','admin','support','hr','sales','contact','office','service','webmaster','marketing','business','help','jobs','careers','press','media','news','noreply','no-reply','mail','postmaster','abuse'];
52
+
53
  function getBounces() {
54
  try { return JSON.parse(localStorage.getItem(BOUNCE_KEY) || '[]'); } catch(e) { return []; }
55
  }
56
+ function saveBounces(list) { localStorage.setItem(BOUNCE_KEY, JSON.stringify(list)); }
57
+ function updateBounceCount() { document.getElementById('bounceCount').textContent = getBounces().length; }
 
 
 
 
58
  updateBounceCount();
59
 
60
  function loadBounceFiles(files) {
61
+ let bounces = getBounces(), added = 0, processed = 0;
 
 
62
  const total = files.length;
63
  for (const file of files) {
64
  const reader = new FileReader();
65
  reader.onload = function(e) {
66
+ const emails = e.target.result.split(/[\n\r]+/).map(l => l.trim()).filter(l => l && l.includes('@'));
67
+ for (const email of emails) { if (!bounces.includes(email)) { bounces.push(email); added++; } }
 
 
 
 
 
 
68
  processed++;
69
  if (processed === total) {
70
  saveBounces(bounces);
 
78
  }
79
 
80
  function clearBounceData() {
81
+ if (confirm('确定要清空所有退信记录吗?')) { saveBounces([]); updateBounceCount(); document.getElementById('bounceStatus').textContent = '已记录 0 个退信地址'; }
 
 
 
 
82
  }
83
 
84
+ async function processData() {
 
85
  const raw = document.getElementById('rawInput').value;
86
+ const bouncesSet = new Set(getBounces());
87
+ const btn = document.getElementById('processBtn');
88
+ const status = document.getElementById('processStatus');
89
+ const progressBar = document.getElementById('progressBar');
90
+ const progressFill = document.getElementById('progressFill');
91
+ const progressText = document.getElementById('progressText');
92
+
93
+ if (!raw.trim()) { status.textContent = '请先粘贴邮箱地址'; status.className = 'text-sm text-red-500'; return; }
94
+
95
+ btn.disabled = true; btn.textContent = '整理中...';
96
+ progressBar.classList.remove('hidden');
97
+ status.textContent = ''; status.className = 'text-sm text-slate-500';
98
 
99
+ await sleep(30);
 
100
 
101
+ // 1. 分割
102
+ updateProgress(10, '分割行...');
103
+ await sleep(20);
104
  const lines = raw.split(/[\n\r]+/).map(l => l.trim()).filter(l => l);
105
+ updateProgress(20, `原始 ${lines.length} 行`);
106
 
107
+ // 2. 格式过滤
108
  const validFormat = lines.filter(l => l.includes('@') && !l.includes(' '));
109
+ updateProgress(40, `格式过滤完成,剩余 ${validFormat.length}`);
110
 
111
  // 3. 过滤通用邮箱
112
+ const notGeneric = validFormat.filter(l => { const p = l.split('@')[0].toLowerCase(); return !GENERIC_PREFIXES.includes(p); });
113
+ updateProgress(55, `通用邮箱过滤完成,剩余 ${notGeneric.length}`);
 
 
114
 
115
+ // 4. 去重
116
  const unique = [...new Set(notGeneric)];
117
+ updateProgress(70, `去重完成,剩余 ${unique.length}`);
118
 
119
+ // 5. 过滤退信
120
+ const clean = unique.filter(l => !bouncesSet.has(l));
121
+ updateProgress(90, `退信过滤完成,剩余 ${clean.length}`);
122
 
123
+ // 结果
124
  const stats = [
125
  `原始行数:${lines.length} 条`,
126
+ `格式过滤:去掉 ${lines.length - validFormat.length} 条`,
127
+ `通用邮箱:去掉 ${validFormat.length - notGeneric.length} 条`,
128
  `本批去重:去掉 ${notGeneric.length - unique.length} 条`,
129
  `退信过滤:去掉 ${unique.length - clean.length} 条`,
130
  `最终可用:${clean.length} 条`
131
  ];
132
+ document.getElementById('resultOutput').value = clean.join('\n');
133
+ document.getElementById('resultStats').innerHTML = stats.map(s => `<div>${s}</div>`).join('');
134
+ document.getElementById('resultArea').classList.remove('hidden');
135
+ document.getElementById('copyBtn').classList.remove('hidden');
136
 
137
+ updateProgress(100, `完成!最终可用 ${clean.length} 条`);
138
+ btn.disabled = false; btn.textContent = '🔍 整理';
 
 
 
 
139
  }
140
 
141
  function copyResult() {
142
+ const val = document.getElementById('resultOutput').value;
143
+ if (!val) return;
144
+ navigator.clipboard.writeText(val).then(() => {
145
+ document.getElementById('processStatus').textContent = '已复制到剪贴板,现在可以去 CRM 或 SES 页面粘贴发送';
146
+ document.getElementById('processStatus').className = 'text-sm text-emerald-600';
 
147
  });
148
  }
149
+
150
+ function updateProgress(pct, text) {
151
+ document.getElementById('progressFill').style.width = pct + '%';
152
+ document.getElementById('progressText').textContent = text;
153
+ }
154
+ function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
155
  </script>
156
  </body>
157
  </html>