妖火网 - 只看指定用户回帖

在妖火网页面添加输入框,输入用户ID后跳转到只看该用户回帖的页面。(只在全部回帖页面生效)

  1.  
  2. // ==UserScript==
  3. // @license 妖火
  4. // @name 妖火网 - 只看指定用户回帖
  5. // @namespace http://tampermonkey.net/
  6. // @version 1.5
  7. // @description 在妖火网页面添加输入框,输入用户ID后跳转到只看该用户回帖的页面。(只在全部回帖页面生效)
  8. // @author 你的名字
  9. // @match https://yaohuo.me/bbs/book_re.aspx*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // 查找“文件回帖”文本节点
  17. const textNode = [...document.querySelectorAll('*')].find(el => el.textContent.trim() === '文件回帖');
  18.  
  19. if (textNode) {
  20. // 创建输入框
  21. const input = document.createElement('input');
  22. input.type = 'text';
  23. input.placeholder = '输入用户ID并回车';
  24. input.style.width = '150px'; // 固定宽度为 150px
  25. input.style.marginLeft = '10px'; // 与“文件回帖”保持一定距离
  26. input.style.padding = '5px 8px';
  27. input.style.border = '1px solid #ccc';
  28. input.style.borderRadius = '3px';
  29. input.style.fontSize = '14px';
  30. input.style.outline = 'none';
  31. input.style.boxSizing = 'border-box'; // 确保宽度包含 padding 和 border
  32.  
  33. // 将输入框插入到“文件回帖”的右侧
  34. textNode.parentNode.insertBefore(input, textNode.nextSibling);
  35.  
  36. // 监听回车键
  37. input.addEventListener('keypress', function(event) {
  38. if (event.key === 'Enter') {
  39. const userId = input.value.trim();
  40. if (userId) {
  41. // 获取当前URL
  42. const currentUrl = window.location.href;
  43.  
  44. // 判断是否已经包含查询参数
  45. const hasQuery = currentUrl.includes('?');
  46.  
  47. // 构建新URL
  48. const newUrl = currentUrl + (hasQuery ? '&' : '?') + 'mainuserid=' + userId;
  49.  
  50. // 跳转到新URL
  51. window.location.href = newUrl;
  52. }
  53. }
  54. });
  55. }
  56. })();
  57.  

QingJ © 2025

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