Steam Comments ErrorProofing

防止留言被误删

  1. // ==UserScript==
  2. // @name Steam Comments ErrorProofing
  3. // @namespace steam
  4. // @author 伟大鱼塘
  5. // @description 防止留言被误删
  6. // @include https://steamcommunity.com/
  7. // @match https://steamcommunity.com/*
  8. // @version 1.0.2
  9. // ==/UserScript==
  10.  
  11. {
  12. const appendModal = fun => {
  13. const html =
  14. '<div id="del_confirm_modal" class="newmodal" style="position: fixed;z-index: 1000; max-width: 1826px;left: 681px;top: 346px;">' +
  15. '<div class="modal_top_bar"></div>' +
  16. '<div class="newmodal_header_border">' +
  17. '<div class="newmodal_header">' +
  18. '<div class="newmodal_close"></div>' +
  19. '<div class="title_text">确认删除?</div>' +
  20. '</div>' +
  21. '</div>' +
  22. '<div class="newmodal_content_border">' +
  23. '<div class="newmodal_content" style="max-height: 816px">' +
  24. '<div class="profileedit_SaveCancelButtons_2KJ8a">' +
  25. '<button type="button" id="confirm_btn" class="DialogButton _DialogLayout Primary">确认</button>' +
  26. '<button type="button" class="DialogButton _DialogLayout Secondary">取消</button>' +
  27. '</div>' +
  28. '</div>' +
  29. '</div>' +
  30. '</div>'
  31. document.querySelector('body').insertAdjacentHTML('afterBegin', html)
  32. bindEvent(fun)
  33. }
  34.  
  35. const bindEvent = fun => {
  36. const modal = document.querySelector('#del_confirm_modal')
  37. modal.addEventListener('click', e => {
  38. const t = e.target
  39. if (t.id == 'confirm_btn') {
  40. const eventFun = new Function(fun)
  41. eventFun()
  42. }
  43. document.querySelector('body').removeChild(modal)
  44. })
  45. }
  46.  
  47. const resetClickEvent = () => {
  48. const del_nodeList = document.querySelectorAll('.actionlink')
  49. for (let el of del_nodeList) {
  50. const fun = el.href.substring(11)
  51. el.href = 'javascript:;'
  52. el.addEventListener('click', () => {
  53. appendModal(fun)
  54. })
  55. }
  56. }
  57.  
  58. const obs = () => {
  59. const targetList = document.querySelectorAll('.commentthread_comments')
  60. const observer = new MutationObserver(mutations => {
  61. mutations.forEach(mutation => {
  62. resetClickEvent()
  63. })
  64. })
  65. for (let el of targetList) {
  66. observer.observe(el, {
  67. childList: true,
  68. subtree: true,
  69. })
  70. }
  71. }
  72.  
  73. resetClickEvent()
  74. obs()
  75. }

QingJ © 2025

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