entItem(el); if (!item) return; var now = Date.now(); if (lastSelect.text === text && lastSelect.item === item && (now - lastSelect.ts) < 1200) { return; } lastSelect.text = text; lastSelect.item = item; lastSelect.ts = now; reportMarketing('select', el, text); } function reportCopyIfAny() { if (ignoreNativeCopyUntil && Date.now() < ignoreNativeCopyUntil) return; var sel = window.getSelection ? window.getSelection() : null; if (!sel || sel.isCollapsed) return; var text = (sel.toString() || '').trim(); if (!text) return; var el = getClosestMarketingElFromNode(sel.anchorNode); if (!el) return; var item = getEventItem(el); if (!item) return; var now = Date.now(); if (lastCopy.text === text && lastCopy.item === item && (now - lastCopy.ts) < 1200) { return; } lastCopy.text = text; lastCopy.item = item; lastCopy.ts = now; reportMarketing('copy', el, text); } // 点击:记录 click(不改变现有跳转/交互) $(document).on('click', '[data-marketing="1"]', function () { // 如果刚刚触发过双击复制,避免 double click 产生多余 click 埋点 var el = this; var ts = parseInt(el.getAttribute('data-mkt_dbl_ts') || '0', 10); if (ts && Date.now() - ts < 450) return; reportMarketing('click', el); }); // 双击:复制 + 记录 copy $(document).on('dblclick', '[data-marketing="1"][data-marketing-copy]', function (e) { var el = this; el.setAttribute('data-mkt_dbl_ts', Date.now().toString()); var mode = el.getAttribute('data-marketing-copy'); var val = ''; if (mode === 'href') { val = el.getAttribute('href') || ''; // 双击复制链接时,避免重复打开新窗口/跳转 e.preventDefault(); e.stopPropagation(); } else { val = (el.textContent || '').trim(); } if (val) { copyText(val); reportMarketing('copy', el, val); } }); // 选择:选中文本时记录 select(用 mouseup/touchend/keyup,避免 selectionchange 过于频繁) $(document).on('mouseup touchend', function () { setTimeout(reportSelectIfAny, 0); }); $(document).on('keyup', function (e) { // 常见的键盘选择:Shift+方向键 if (e && e.shiftKey) { setTimeout(reportSelectIfAny, 0); } }); // 复制:Ctrl+C / 右键复制(只能可靠拿到“选中文本”的复制) document.addEventListener('copy', function () { setTimeout(reportCopyIfAny, 0); }); })();
Choose another language
×
English
Français
Deutsch
Português
Español
Italiano
Русский
한국어
日本語
العربية
ภาษาไทย
Tiếng Việt
Türkçe
Bahasa Indonesia
हिंदी
Pilipino
فارسی
Bahasa Melayu
KiSwahili
Polski