本站公收录50年前的影片
 找回密码
 立即注册
快捷导航
搜索
回复: 0

发表带百度网盘链接和提取码时自动添加隐藏代码

[复制链接]
发表于 2025-3-4 19:24:47 | 显示全部楼层 |阅读模式
template\default\forum\post.htm
搜索
  1. <iframe name="ajaxpostframe" id="ajaxpostframe" style="display: none;"></iframe>
复制代码

下面添加
  1. <script>
  2. (function() {
  3.     // 确保代码仅在发帖页执行
  4.     if (!document.getElementById('postform')) return;

  5.     // 保存原始提交函数
  6.     var originalSubmitHandler = document.getElementById('postform').onsubmit;
  7.     var isProcessing = false; // 防止重复处理标志

  8.     document.getElementById('postform').onsubmit = function(e) {
  9.         if (isProcessing) return false; // 如果正在处理中,直接拦截
  10.         isProcessing = true;

  11.         try {
  12.             var messageBox = document.getElementById('e_textarea');
  13.             var pattern = /链接[::]\s*((?:https?:\/\/)?pan\.baidu\.com\/s\/[a-zA-Z0-9_-]+)\s+提取码[::]\s*(\w{4})/gi;
  14.             messageBox.value = messageBox.value.replace(pattern, '[hide]链接: $1 提取码: $2[/hide]');
  15.             
  16.             // 调用原始提交逻辑(含Discuz!的防灌水校验)
  17.             if (originalSubmitHandler) {
  18.                 return originalSubmitHandler.call(this, e);
  19.             }
  20.         } catch (err) {
  21.             console.error('提交处理异常:', err);
  22.             isProcessing = false;
  23.             return false;
  24.         } finally {
  25.             isProcessing = false;
  26.         }
  27.     };
  28. })();
  29. </script>
复制代码

上面是百度网盘的

以下是兼容百度网盘、迅雷,夸克,115,阿里
  1. <script>
  2. (function() {
  3.     var form = document.getElementById('postform');
  4.     if (!form) return;

  5.     var originalSubmitHandler = form.onsubmit;
  6.     var isProcessing = false;

  7.     form.onsubmit = function(e) {
  8.         if (isProcessing) return false;
  9.         isProcessing = true;

  10.         try {
  11.             var messageBox = document.querySelector('textarea[name="message"]');
  12.             if (!messageBox) {
  13.                 console.error('未找到文本域');
  14.                 return false;
  15.             }

  16.             // 终极正则(精确匹配所有网盘)
  17.             var pattern = /链接[::]\s*((?:https?:\/\/)?(?:pan\.baidu\.com\/s\/|pan\.quark\.cn\/s\/|www\.alipan\.com\/s\/|pan\.xunlei\.com\/s\/|www\.115\.com\/\w+\/folder\/)[a-zA-Z0-9_\/-]+)\s+提取码[::]\s*(\w{4})/gi;
  18.             messageBox.value = messageBox.value.replace(pattern, '[hide]链接: $1 提取码: $2[/hide]');

  19.             if (originalSubmitHandler) {
  20.                 return originalSubmitHandler.call(this, e);
  21.             }
  22.         } catch (err) {
  23.             console.error('提交异常:', err);
  24.             isProcessing = false;
  25.             return false;
  26.         } finally {
  27.             isProcessing = false;
  28.         }
  29.     };
  30. })();
  31. </script>
复制代码




您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|联系管理|sitemap|老影迷

GMT+8, 2025-8-26 07:33 , Processed in 0.115831 second(s), 30 queries .

Powered by Discuz! X3.5

快速回复 返回顶部 返回列表