Pojie52_TimeDown

吾爱破解回帖倒计时

当前为 2023-10-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Pojie52_TimeDown
  3. // @namespace Pojie52_TimeDown
  4. // @version 1.2
  5. // @description 吾爱破解回帖倒计时
  6. // @author Pwnint32
  7. // @match https://www.52pojie.cn/thread*
  8. // @include https://www.52pojie.cn/forum.php?mod=viewthread*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
  10. // @grant GM_addElement
  11. // ==/UserScript==
  12.  
  13. var PostLimitTime = 40;
  14. var PostLimitEndTime = 0;
  15.  
  16. // 对回帖下方的头像处插入提示节点
  17. function addTimeLabel() {
  18. var replyAvatar = document.querySelector('.avatar.avtm');
  19.  
  20. if (replyAvatar) {
  21. GM_addElement(
  22. replyAvatar,
  23. "div", {
  24. class: "avatar avtm",
  25. id: "timeDown",
  26. style: "text-align:center;font-size:16px;color:red",
  27. textContent: "允许回帖"
  28. }
  29. );
  30. }
  31. }
  32.  
  33. function injectReplySubmit() {
  34. var fastSubmit = document.querySelector("#fastpostsubmit");
  35. var postSubmit = document.querySelector("#postsubmit");
  36. var timeDown = document.querySelector("#timeDown");
  37.  
  38. if (fastSubmit) {
  39. fastSubmit.onclick = function () {
  40.  
  41. if (timeDown && timeDown.textContent=="允许回帖") {
  42. PostLimitTime = 40;
  43. // 设置倒计时
  44. var interval = setInterval(function () {
  45. if (PostLimitTime > 0) {
  46. timeDown.textContent = "剩余:" + PostLimitTime + "秒";
  47. PostLimitTime--;
  48. } else {
  49. clearInterval(interval); // 停止倒计时
  50. timeDown.textContent = "允许回帖";
  51. }
  52. }, 1000); // 每秒更新一次
  53. }
  54.  
  55. };
  56. }
  57.  
  58. if (postSubmit) {
  59. postSubmit.onclick = function () {
  60. if (timeDown && timeDown.textContent=="允许回帖") {
  61. PostLimitTime = 40;
  62. // 设置倒计时
  63. var interval = setInterval(function () {
  64. if (PostLimitTime > 0) {
  65. timeDown.textContent = "剩余:" + PostLimitTime + "秒";
  66. PostLimitTime--;
  67. } else {
  68. clearInterval(interval); // 停止倒计时
  69. timeDown.textContent = "允许回帖";
  70. }
  71. }, 1000); // 每秒更新一次
  72. }
  73. };
  74. }
  75. }
  76.  
  77. addTimeLabel();
  78.  
  79. setInterval(injectReplySubmit,1000)