nodeseek论坛屏蔽词

为nodeseek论坛添加屏蔽词功能

  1. // ==UserScript==
  2. // @name nodeseek论坛屏蔽词
  3. // @namespace http://tampermonkey.net/
  4. // @version 2023-12-30
  5. // @description 为nodeseek论坛添加屏蔽词功能
  6. // @author bigQY
  7. // @match https://www.nodeseek.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=nodeseek.com
  9. // @grant none
  10. // @require https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. // 设置按钮
  17. var headerDiv = document.querySelector("#nsk-head")
  18. var btn = document.createElement("button");
  19. btn.innerHTML = "屏蔽词设置";
  20. btn.classList.add("btn");
  21. btn.style = "margin-left: 10px;";
  22. headerDiv.appendChild(btn);
  23.  
  24. // 设置面板
  25. var panel = document.createElement("div");
  26. panel.innerHTML = `
  27. <div id="ns-block-words-setting">
  28. <h2>屏蔽词设置</h2>
  29. <input type="checkbox" id="ns-block-words-checkbox-enable" name="ns-block-words-checkbox-enable" checked />
  30. <label for="ns-block-words-checkbox-enable">启用屏蔽词</label>
  31. <br/>
  32. <input type="checkbox" id="ns-block-words-checkbox-hide" name="ns-block-words-checkbox-enable" checked />
  33. <label for="ns-block-words-checkbox-hide">不显示被屏蔽的帖子或楼层</label>
  34. <br/>
  35. <p>屏蔽词列表(逗号分隔)</p>
  36. <textarea id='ns-block-words' style='width: 98%; height: 50vh;'></textarea>
  37. <br/>
  38. <div style="display: flex;justify-content: end;margin:10px">
  39. <button id='ns-block-words-btn-save' class='btn' style="margin:0 10px">保存</button>
  40. <button id='ns-block-words-btn-cance' class='btn'>取消</button>
  41. </div>
  42. </div>
  43. `;
  44. panel.style = `
  45. position: fixed;
  46. top: 10vh;
  47. left: 10vw;
  48. z-index: -1;
  49. display: block;
  50. width: 80vw;
  51. height: 0;
  52. background-color: rgba(255, 255, 255, 0.8);
  53. border-radius: 10px;
  54. backdrop-filter: blur(10px);
  55. padding:20px;
  56. transition: all 0.5s;
  57. opacity: 0;
  58. overflow: hidden;
  59. `;
  60. document.body.appendChild(panel);
  61.  
  62. // 设置按钮点击事件
  63. btn.onclick = function() {
  64. showSetting();
  65. document.getElementById("ns-block-words").value = localStorage.getItem("ns-block-words");
  66. };
  67. // 保存按钮点击事件
  68. document.getElementById("ns-block-words-btn-save").onclick = function() {
  69. localStorage.setItem("ns-block-words", document.getElementById("ns-block-words").value);
  70. localStorage.setItem("ns-block-words-enable", document.getElementById("ns-block-words-checkbox-enable").checked);
  71. localStorage.setItem("ns-block-words-hide", document.getElementById("ns-block-words-checkbox-hide").checked);
  72. hideSetting();
  73. };
  74. // 取消按钮点击事件
  75. document.getElementById("ns-block-words-btn-cance").onclick = function() {
  76. hideSetting();
  77. };
  78.  
  79. function showSetting() {
  80. panel.style.zIndex = 9998;
  81. panel.style.opacity = 1;
  82. panel.style.height = "80vh";
  83. }
  84.  
  85. function hideSetting() {
  86. panel.style.opacity = 0;
  87. panel.style.height = "0";
  88. setTimeout(function() {
  89. if(panel.style.opacity == 0){
  90. panel.style.zIndex = -1;
  91. }
  92. }, 500);
  93. }
  94.  
  95. // dom ready初始化
  96. $(document).ready(function() {
  97. // 屏蔽词列表
  98. var blockWords = localStorage.getItem("ns-block-words");
  99. if (blockWords == null) {
  100. blockWords = "";
  101. }
  102. blockWords = blockWords.split(",");
  103. // 启用屏蔽词
  104. var enable = localStorage.getItem("ns-block-words-enable");
  105. enable = enable == 'true' ? true : false;
  106. var checkbox = document.getElementById("ns-block-words-checkbox-enable");
  107. checkbox.checked = enable;
  108. // 隐藏屏蔽词
  109. var hide = localStorage.getItem("ns-block-words-hide");
  110. hide = hide == 'true' ? true : false;
  111. var checkbox2 = document.getElementById("ns-block-words-checkbox-hide");
  112. checkbox2.checked = hide;
  113. // 屏蔽词列表
  114. var textarea = document.getElementById("ns-block-words");
  115. textarea.value = blockWords.join(",");
  116. // 屏蔽词
  117. if (enable) {
  118. // 帖子界面
  119. var comments = document.querySelectorAll(".content-item");
  120. if (comments != null) {
  121. comments.forEach(function(comment) {
  122. var content = comment.querySelector(".post-content");
  123. var contentText = content.innerText;
  124. blockWords.forEach(function(word) {
  125. if (contentText.indexOf(word) != -1) {
  126. if (word==="") return;
  127. if (hide) {
  128. comment.style.display = "none";
  129. } else {
  130. content.innerHTML = `<span style="color: red;">触发屏蔽词:${word}</span>`
  131. }
  132. }
  133. });
  134. });
  135. }
  136. // 列表界面
  137. var posts = document.querySelectorAll(".post-list-content");
  138. if (posts != null) {
  139. posts.forEach(function(post) {
  140. var content = post.querySelector(".post-title > a");
  141. var contentText = content.innerText;
  142. blockWords.forEach(function(word) {
  143. if (contentText.indexOf(word) != -1) {
  144. if (word==="") return;
  145. if (hide) {
  146. post.parentNode.style.display='none'
  147. } else {
  148. content.innerHTML = `<span style="color: red;">触发屏蔽词:${word}</span>`
  149. }
  150. }
  151. });
  152. });
  153. }
  154. }
  155. });
  156. })();

QingJ © 2025

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