// ==UserScript== // @name 微信客服消息导出 // @namespace https://greasyfork.org/zh-CN/users/443879-fanzhixin // @version 0.3 // @description 导出选中的小程序客服消息,包括客户和客服名字,图片地址 // @author Bill Fan 范志鑫 // @match https://mpkf.weixin.qq.com/* // @include https://mpkf.weixin.qq.com/* // @run-at document-end // @grant GM_xmlhttpRequest // @downloadURL https://update.greasyfork.icu/scripts/396374/%E5%BE%AE%E4%BF%A1%E5%AE%A2%E6%9C%8D%E6%B6%88%E6%81%AF%E5%AF%BC%E5%87%BA.user.js // @updateURL https://update.greasyfork.icu/scripts/396374/%E5%BE%AE%E4%BF%A1%E5%AE%A2%E6%9C%8D%E6%B6%88%E6%81%AF%E5%AF%BC%E5%87%BA.meta.js // ==/UserScript== ( function() { 'use strict'; // Your code here... var iconSize = 24; var translationTestSize = 16; var icon = document.createElement('div'); var style = '' + 'width:24px;' + 'height:24px;' + 'margin:4px!important;' + ''; icon.innerHTML = '' + '' + ' ' + '' + '' + '' + '' + '' + ''; icon.setAttribute('style', '' + 'width:32px!important;' + 'height:32px!important;' + 'display:none!important;' + 'background:#fff!important;' + 'border-radius:16px!important;' + 'box-shadow:4px 4px 8px #888!important;' + 'position:absolute!important;' + 'z-index:2147483647!important;' + ''); // 添加翻译图标到 DOM document.documentElement.appendChild(icon); // 鼠标事件:防止选中的文本消失 document.addEventListener('mousedown', function (e) { if (e.target == icon || (e.target.parentNode && e.target.parentNode == icon) || (e.target.parentNode.parentNode && e.target.parentNode.parentNode == icon)) {// 点击了翻译图标 e.preventDefault(); } }); // 选中变化事件:当点击已经选中的文本的时候,隐藏翻译图标和翻译面板(此时浏览器动作是:选中的文本已经取消选中了) document.addEventListener("selectionchange", function () { if (!window.getSelection().toString().trim()) { icon.style.display = 'none'; } }); // 鼠标事件:防止选中的文本消失;显示、隐藏翻译图标 document.addEventListener('mouseup', function (e) { if (e.target == icon || (e.target.parentNode && e.target.parentNode == icon) || (e.target.parentNode.parentNode && e.target.parentNode.parentNode == icon)) {// 点击了翻译图标 e.preventDefault(); return; } var text = window.getSelection().toString().trim(); if (text && icon.style.display == 'none') { icon.style.top = e.pageY + 12 + 'px'; icon.style.left = e.pageX + 'px'; icon.style.display = 'block'; } else if (!text) { icon.style.display = 'none'; } }); // 翻译图标点击事件 icon.addEventListener('click', function (e) { var divtime =new RegExp("
","g"); var divs =new RegExp("
","g"); var spans =new RegExp("","g"); var ps =new RegExp("

","g"); var as =new RegExp("","g"); var imgtou =new RegExp("","g"); var imgsreenshot =new RegExp("","g"); var audiorex =new RegExp("