Skip WeCom Email Safe Alert

try to skip WeCom Email Safe Alert

  1. // ==UserScript==
  2. // @name Skip WeCom Email Safe Alert
  3. // @namespace https://work.weixin.qq.com/
  4. // @version 2025-06-05.02
  5. // @description try to skip WeCom Email Safe Alert
  6. // @author Bevis
  7. // @match https://open.work.weixin.qq.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. if (window.location.host !== 'open.work.weixin.qq.com') {
  17. return;
  18. }
  19.  
  20. function getAndDecodeUriParameter() {
  21. let finalUrl = "错误:未能获取或解码 'uri' 参数。";
  22.  
  23. try {
  24. // 1. 获取当前页面的完整 URL
  25. const pageUrlString = window.location.href;
  26.  
  27. // 2. 创建 URL 对象以方便地访问查询参数
  28. const url = new URL(pageUrlString);
  29.  
  30. // 3. 获取 'uri' 参数的值
  31. const uriParamValue = url.searchParams.get('uri');
  32.  
  33. if (uriParamValue) {
  34. // 4. 对 'uri' 参数的值进行第一次 URL 解码
  35. // 示例原始 uriParamValue: "https%3A%2F%2Ftracker.com%2FCL0%2Fhttps%3A%252F%252Ftarget.com..."
  36. // 解码后 (firstDecodedUri): "https://tracker.com/CL0/https%3A%2F%2Ftarget.com..."
  37. const firstDecodedUri = decodeURIComponent(uriParamValue);
  38.  
  39. let secondEncodedPart = null;
  40.  
  41. // 5. 从第一次解码后的字符串中,提取出那个被再次编码的最终目标网址部分。
  42. // 这部分通常以 "http%3A%2F%2F" 或 "https%3A%2F%2F" 开头,
  43. // 并且不是 firstDecodedUri 自身的协议头。
  44. const httpsMarker = "https%3A%2F%2F";
  45. const httpMarker = "http%3A%2F%2F";
  46.  
  47. let searchStartIndex = 0;
  48. // 确定开始搜索内嵌编码URL的起始位置,通常是在跟踪URL的域名和第一个路径段之后
  49. const schemeEndIndex = firstDecodedUri.indexOf("://");
  50. if (schemeEndIndex !== -1) {
  51. // 找到域名后的第一个 '/'
  52. const domainAndPathPrefixEnd = firstDecodedUri.indexOf("/", schemeEndIndex + 3);
  53. if (domainAndPathPrefixEnd !== -1) {
  54. searchStartIndex = domainAndPathPrefixEnd + 1; // 从 "domain.com/" 之后开始搜索
  55. } else {
  56. // 如果URL类似于 "https://domain.com" (没有路径),则不太可能包含嵌套的编码URL
  57. searchStartIndex = firstDecodedUri.length;
  58. }
  59. }
  60.  
  61. // 在 firstDecodedUri 的 searchStartIndex 之后查找 "https%3A%2F%2F"
  62. const indexHttps = firstDecodedUri.indexOf(httpsMarker, searchStartIndex);
  63. // 在 firstDecodedUri 的 searchStartIndex 之后查找 "http%3A%2F%2F"
  64. const indexHttp = firstDecodedUri.indexOf(httpMarker, searchStartIndex);
  65.  
  66. if (indexHttps !== -1 && (indexHttp === -1 || indexHttps < indexHttp)) {
  67. // 如果找到了 "https%3A%2F%2F",并且它在 "http%3A%2F%2F" 之前 (或者 "http%3A%2F%2F" 未找到)
  68. secondEncodedPart = firstDecodedUri.substring(indexHttps);
  69. } else if (indexHttp !== -1) {
  70. // 否则,如果找到了 "http%3A%2F%2F"
  71. secondEncodedPart = firstDecodedUri.substring(indexHttp);
  72. }
  73.  
  74. if (secondEncodedPart) {
  75. // 6. 对提取出的这部分进行第二次 URL 解码
  76. // 示例 secondEncodedPart: "https%3A%2F%2Ftarget.com..."
  77. // 解码后 (finalUrl): "https://target.com..."
  78. try {
  79. finalUrl = decodeURIComponent(secondEncodedPart);
  80. } catch (e) {
  81. finalUrl = "错误:解码提取出的 URL 部分时出错: " + e.message + ". 提取的部分是: " + secondEncodedPart;
  82. }
  83. } else {
  84. console.log("错误:在 'uri' 参数第一次解码后,未能找到预期的双重编码 URL 模式 (例如 '.../http%3A%2F%2F...')。第一次解码的结果是: " + firstDecodedUri);
  85. finalUrl = firstDecodedUri;
  86. // 这种情况可能意味着 'uri' 参数的结构与预期不同,或者它只被编码了一层。
  87. // 如果 'firstDecodedUri' 已经是您期望的“正常网址”,您可以直接使用它。
  88. // 但根据您的示例,目标网址是嵌套且再次编码的。
  89. }
  90. } else {
  91. finalUrl = "错误:URL 中未找到 'uri' 参数,或其值为空。";
  92. }
  93. } catch (e) {
  94. finalUrl = "处理 URL 时发生 JavaScript 错误: " + e.message;
  95. }
  96.  
  97. return finalUrl;
  98. }
  99.  
  100. // --- 使用示例 ---
  101. // 假设当前页面的 URL 就是您提供的那个:
  102. // "https://open.work.weixin.qq.com/wwopen/uriconfirm?uri=https%3A%2F%2F52bb7ac08e78da0781cace19b1a1acee.us-east-1.resend-links.com%2FCL0%2Fhttps%3A%252F%252Fdoc.rti-tek.fr%252Fdoc%252F6zmn6zuo5oq6yas5yqf6io95lyy5yyw6k05pio-dRc9GgA8t2%2F1%2F010001973f118aee-4bc2f0e0-4368-47ce-9e20-a902e9676516-000000%2FXLmT9olksc8mRFnul6GIYhXCatnxgBxV4Nlux9Kzzy8%3D408&desc=7_0&err_type=high_risk_forbid&ts"
  103.  
  104. const restoredUrl = getAndDecodeUriParameter();
  105. console.log("还原后的网址是:", restoredUrl);
  106.  
  107. // 添加电子符箓
  108. if (document.getElementsByClassName('spam_title')[0]) {
  109. document.getElementsByClassName('spam_title')[0].textContent = '祝开发此屏蔽功能的工作人员工作顺利!';
  110. document.getElementsByClassName('spam_title')[0].style.textAlign = 'center';
  111. }
  112. if (document.getElementsByClassName('spam_desc')[0]) {
  113. document.getElementsByClassName('spam_desc')[0].textContent = '正在加载所谓的 “不安全网址”';
  114. }
  115.  
  116. const rectElement = document.querySelector('.stage_result > svg.comm_infoAttention72_Red > rect');
  117.  
  118. if (rectElement) {
  119. // Change the fill attribute to 'green'
  120. rectElement.style.setProperty('fill', 'green', 'important');
  121. console.log('The <rect> element background has been changed to green.');
  122. } else {
  123. console.error('Could not find the target <rect> element to change its color.');
  124. }
  125.  
  126. if (restoredUrl && /^https:\/\//.test(restoredUrl)) {
  127. window.location.href = restoredUrl;
  128. }
  129. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址