贴吧助手

能按照用户和关键词屏蔽不想看的贴,屏蔽低于指定等级用户,也可以给用户打标签帮助自己记忆此人的特点,屏蔽置顶直播

  1. // ==UserScript==
  2. // @name 贴吧助手
  3. // @namespace 蒋晓楠
  4. // @version 20240307
  5. // @description 能按照用户和关键词屏蔽不想看的贴,屏蔽低于指定等级用户,也可以给用户打标签帮助自己记忆此人的特点,屏蔽置顶直播
  6. // @author 蒋晓楠
  7. // @license MIT
  8. // @match https://tieba.baidu.com/p/*
  9. // @match https://tieba.baidu.com/f?*kw=*
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @grant GM_deleteValue
  13. // @grant GM_notification
  14. // @grant GM_addStyle
  15. // @grant GM_addElement
  16. // @grant GM_registerMenuCommand
  17. // ==/UserScript==
  18. //执行间隔(秒)
  19. let Interval = 1;
  20. //过期数据清理延时(秒)
  21. let ClearExpireDataDelay = 30;
  22. //过期数据清理几率百分比,范围0-100
  23. let ClearExpireDataPercent = 2;
  24. //以下不懂的不要修改
  25. //页面类型
  26. const PAGE_TYPE_LIST = 0;//列表
  27. const PAGE_TYPE_POST = 1;//帖子
  28. let PageType = location.pathname === "/f" ? PAGE_TYPE_LIST : PAGE_TYPE_POST;
  29.  
  30. //获取数据
  31. function GetData() {
  32. return GM_getValue("List", { User: [], UserTime: {}, Keyword: { Title: {}, Content: {} }, UserTag: {} });
  33. }
  34.  
  35. //保存数据
  36. function SaveData(Data) {
  37. GM_setValue("List", Data);
  38. }
  39.  
  40. //修改配置
  41. function SetConfig(Key, Value) {
  42. GM_setValue("Config:" + Key, Value);
  43. }
  44.  
  45. //获取配置
  46. function GetConfig(Key, Default) {
  47. return GM_getValue("Config:" + Key, Default);
  48. }
  49.  
  50. //删除配置
  51. function RemoveConfig(Key) {
  52. GM_deleteValue("Config:" + Key);
  53. }
  54.  
  55. //提醒
  56. function Tips(Message) {
  57. GM_notification({ title: "贴吧助手", text: Message, timeout: 3000 });
  58. }
  59.  
  60. //初始化样式
  61. function InitCSS() {
  62. GM_addStyle(`.JXNButton{border:1px solid;margin-right:10px}.BlockUser{width:90%}.JXNInput{width:50px;}.JXNTag{border:1px solid black;margin:5px 1px;display:inline-block;min-width:50px;}.JXNTagBox{width:90px;}.JXNHolder{width:250px;position:absolute;left:10px;z-index:1;top:135px}.PostListBlockUser{position:absolute;right:0;margin-right:0;z-index:1}`);
  63. }
  64.  
  65. //获取有效天数
  66. function GetExpireDay() {
  67. return GetConfig("ExpireDay", 180);
  68. }
  69.  
  70. //设置有效天数
  71. function SetExpireDay(Value) {
  72. SetConfig("ExpireDay", parseInt(Value));
  73. }
  74.  
  75. //获取当前时间
  76. function GetNowTime() {
  77. let Now = new Date();
  78. return parseInt(Now.getFullYear().toString() + (Now.getMonth() + 1).toString().padStart(2, "0") + Now.getDate().toString().padStart(2, "0"));
  79. }
  80.  
  81. //获取新的过期时间
  82. function GetNewExpiredDay() {
  83. let Now = new Date();
  84. Now.setDate(Now.getDate() + GetExpireDay());
  85. return parseInt(Now.getFullYear().toString() + (Now.getMonth() + 1).toString().padStart(2, "0") + Now.getDate().toString().padStart(2, "0"));
  86. }
  87.  
  88. //屏蔽用户存在
  89. function BlockUserIsExist(Id) {
  90. return GetData().User.indexOf(Id) > -1;
  91. }
  92.  
  93. //添加屏蔽用户
  94. function AddBlockUser(Id) {
  95. let Data = GetData();
  96. Data.User.push(Id);
  97. Data.UserTime[Id] = GetNewExpiredDay();
  98. SaveData(Data);
  99. }
  100.  
  101. //移除屏蔽用户
  102. function RemoveBlockUser(Id) {
  103. let Data = GetData();
  104. let Index = Data.User.indexOf(Id);
  105. if (Index > -1) {
  106. Data.User.splice(Index, 1);
  107. delete Data.UserTime[Id];
  108. SaveData(Data);
  109. }
  110. }
  111.  
  112. //获取当前关键词类型
  113. function GetNowKeyWordType() {
  114. return parseInt(document.querySelector(".JXNMatchType").value);
  115. }
  116.  
  117. //获取当前关键词模式
  118. function GetNowKeyWordMode() {
  119. return parseInt(document.querySelector(".JXNMatchMode").value);
  120. }
  121.  
  122. //屏蔽关键词存在
  123. function BlockKeywordIsExist(Type, Value) {
  124. return GetData().Keyword[Type === 0 ? "Title" : "Content"][Value] !== undefined;
  125. }
  126.  
  127. //添加屏蔽关键词
  128. function AddBlockKeyword(Type, Mode, Value) {
  129. let Data = GetData();
  130. Data.Keyword[Type === 0 ? "Title" : "Content"][Value] = { Mode: Mode, Time: GetNewExpiredDay() };
  131. SaveData(Data);
  132. }
  133.  
  134. //移除屏蔽关键词
  135. function RemoveBlockKeyword(Type, Value) {
  136. let Data = GetData();
  137. let KeyWord = Data.Keyword;
  138. let Key = Type === 0 ? "Title" : "Content";
  139. if (KeyWord[Key][Value] !== undefined) {
  140. delete Data.Keyword[Key][Value];
  141. SaveData(Data);
  142. }
  143. }
  144.  
  145. //获取用户标签
  146. function GetUserTags(UserId) {
  147. let Data = GetData();
  148. if (Data.UserTag[UserId] === undefined) {
  149. return {};
  150. } else {
  151. return Data.UserTag[UserId];
  152. }
  153. }
  154.  
  155. //用户添加标签
  156. function UserAddTag(UserId, Tag) {
  157. let Data = GetData();
  158. //初始化该用户的标签
  159. if (Data.UserTag[UserId] === undefined) {
  160. Data.UserTag[UserId] = {};
  161. }
  162. Data.UserTag[UserId][Tag] = GetNewExpiredDay();
  163. SaveData(Data);
  164. }
  165.  
  166. //用户移除标签
  167. function UserRemoveTag(UserId, Tag) {
  168. let Data = GetData();
  169. let UserTags = Data.UserTag[UserId];
  170. if (UserTags !== undefined && UserTags[Tag] !== undefined) {
  171. Object.getOwnPropertyNames(UserTags).length === 1 ? delete Data.UserTag[UserId] : delete UserTags[Tag];
  172. SaveData(Data);
  173. }
  174. }
  175.  
  176. //帖子列表的额外屏蔽
  177. function PostListExtraBlock() {
  178. //置顶直播
  179. if (GetConfig("BlockTopLive") === true && document.querySelector("[id^=pagelet_live]") !== null) {
  180. document.querySelector("[id^=pagelet_live]").remove();
  181. }
  182. //关闭会员红贴
  183. if (GetConfig("BanMemberPost", true) && document.querySelector(".member_thread_title_frs") !== null) {
  184. document.querySelectorAll(".member_thread_title_frs").forEach((TitleHolder) => {
  185. TitleHolder.classList.remove("member_thread_title_frs");
  186. });
  187. }
  188. }
  189.  
  190. //内容过滤
  191. function ContentFilter(Content) {
  192. Content = Content.trim();
  193. if (Content !== "") {
  194. //过滤非中文/英文/数字
  195. Content = Content.replace(/[^\da-zA-Z\u4e00-\u9fa5]/g, "");
  196. }
  197. return Content;
  198. }
  199.  
  200. //检测标题关键词
  201. function CheckKeywordTitle(Title) {
  202. let TitleKeyWords = GetData().Keyword.Title;
  203. for (const Keyword in TitleKeyWords) {
  204. if (TitleKeyWords[Keyword].Mode === 0) {
  205. if (Title.indexOf(Keyword) > -1) {
  206. return Keyword;
  207. }
  208. } else if (Keyword === Title) {
  209. return Keyword;
  210. }
  211. }
  212. return false;
  213. }
  214.  
  215. //检测内容关键词
  216. function CheckKeywordContent(Content) {
  217. let ContentWords = GetData().Keyword.Content;
  218. for (const Keyword in ContentWords) {
  219. if (ContentWords[Keyword].Mode === 0) {
  220. if (Content.indexOf(Keyword) > -1) {
  221. return Keyword;
  222. }
  223. } else if (Keyword === Content) {
  224. return Keyword;
  225. }
  226. }
  227. return false;
  228. }
  229.  
  230. //帖子列表初始化
  231. function InitPostList() {
  232. let StartTime = (new Date()).getTime();
  233. let Posts = document.querySelectorAll(".j_thread_list:not(.JXNProcessed)");
  234. let Number = Posts.length;
  235. if (Number > 0) {
  236. let BlockAlphaNumberTitle = GetConfig("BlockAlphaNumberTitle", false),
  237. EnableContentFilter = GetConfig("ContentFilter", false);
  238. for (let i = 0; i < Posts.length; i++) {
  239. let Post = Posts[i];
  240. let User = Post.querySelector(".tb_icon_author");
  241. if (User === null) {
  242. //添加已处理标记
  243. Post.classList.add("JXNProcessed");
  244. } else {
  245. let DisplayName = Post.querySelector(".frs-author-name").textContent;
  246. let UserId = JSON.parse(Post.querySelector(".tb_icon_author").getAttribute("data-field")).user_id;
  247. let Title = Post.querySelector(".threadlist_title>a").getAttribute("title");
  248. //屏蔽纯字母数字标题
  249. if (BlockAlphaNumberTitle && /^[0-9a-zA-Z]*$/.test(Title)) {
  250. console.log(`${DisplayName}(${UserId})的帖子[${Title}]被屏蔽因为标题为纯字母数字`);
  251. Post.remove();
  252. }
  253. //按用户ID屏蔽
  254. else if (BlockUserIsExist(UserId)) {
  255. console.log(`${DisplayName}(${UserId})的帖子[${Title}]被屏蔽因为在用户屏蔽列表内`);
  256. Post.remove();
  257. } else {
  258. //按关键词屏蔽
  259. let Result = CheckKeywordTitle(Title);
  260. if (Result === false) {
  261. let Content = Post.querySelector(".threadlist_abs_onlyline");
  262. if (Content !== null) {
  263. Content = Content.textContent;
  264. if (EnableContentFilter)
  265. Content = ContentFilter(Content);
  266. if (Content !== "") {
  267. Result = CheckKeywordContent(Content);
  268. if (Result !== false) {
  269. console.log(`${DisplayName}(${UserId})的帖子[${Title}]被屏蔽因为内容触发关键词[${Result}]`);
  270. Post.remove();
  271. continue;
  272. }
  273. }
  274. }
  275. //添加屏蔽按钮
  276. let BlockButton = document.createElement("button");
  277. BlockButton.classList.add("JXNButton");
  278. BlockButton.classList.add("PostListBlockUser");
  279. BlockButton.textContent = "屏蔽用户";
  280. BlockButton.onclick = () => {
  281. if (BlockUserIsExist(UserId)) {
  282. Tips("此用户已存在");
  283. } else {
  284. AddBlockUser(UserId)
  285. //添加取消屏蔽按钮
  286. let CancelButton = document.createElement("button");
  287. CancelButton.classList.add("JXNButton");
  288. CancelButton.classList.add("PostListBlockUser");
  289. CancelButton.textContent = "取消屏蔽";
  290. CancelButton.onclick = () => {
  291. if (BlockUserIsExist(UserId)) {
  292. RemoveBlockUser(UserId);
  293. CancelButton.remove();
  294. Tips("已取消对此用户的屏蔽");
  295. } else {
  296. Tips("此用户不存在");
  297. }
  298. }
  299. Post.prepend(CancelButton);
  300. Tips("添加成功,刷新后将自动屏蔽此用户的发帖与回复");
  301. BlockButton.remove();
  302. }
  303. }
  304. Post.prepend(BlockButton);
  305. Post.classList.add("JXNProcessed");
  306. } else {
  307. console.log(`${DisplayName}(${UserId})的帖子[${Title}]被屏蔽因为标题触发关键词[${Result}]`);
  308. Post.remove();
  309. }
  310. }
  311. }
  312. }
  313. //额外屏蔽
  314. PostListExtraBlock();
  315. console.log("屏蔽用时:" + ((new Date()).getTime() - StartTime) + "毫秒");
  316. }
  317. }
  318.  
  319. //初始化用户面板
  320. function InitUserPanel(UserId, UserBlock) {
  321. setTimeout(() => {
  322. let BlockButton = GM_addElement(UserBlock, "button", {
  323. class: "JXNButton BlockUser",
  324. textContent: "屏蔽"
  325. });
  326. BlockButton.onclick = () => {
  327. if (BlockUserIsExist(UserId)) {
  328. Tips("此用户已存在");
  329. } else {
  330. AddBlockUser(UserId)
  331. //添加取消屏蔽按钮
  332. let CancelButton = GM_addElement(UserBlock, "button", {
  333. textContent: "取消屏蔽", class: "JXNButton BlockUser"
  334. });
  335. CancelButton.onclick = () => {
  336. if (BlockUserIsExist(UserId)) {
  337. RemoveBlockUser(UserId);
  338. Tips("已取消对此用户的屏蔽");
  339. } else {
  340. Tips("此用户不存在");
  341. }
  342. }
  343. Tips("添加成功,刷新后将自动屏蔽此用户的发帖与回复");
  344. BlockButton.remove();
  345. }
  346. }
  347. let Tags = GetUserTags(UserId);
  348. for (const Tag in Tags) {
  349. let NowTag = GM_addElement(UserBlock, "button", {
  350. textContent: Tag,
  351. class: "JXNTag",
  352. title: "点击删除此标签"
  353. });
  354. NowTag.onclick = () => {
  355. UserRemoveTag(UserId, Tag);
  356. Tips("删除完成");
  357. NowTag.remove();
  358. }
  359. }
  360. //创建添加标签框
  361. let TagBox = GM_addElement(UserBlock, "input", {
  362. type: "text",
  363. class: "JXNInput JXNTagBox"
  364. });
  365. let Button = GM_addElement(UserBlock, "button", {
  366. textContent: "添加",
  367. class: "JXNButton JXNTagRemove",
  368. title: "添加标签"
  369. });
  370. Button.onclick = () => {
  371. let Tag = TagBox.value;
  372. if (Tag !== "") {
  373. UserAddTag(UserId, Tag);
  374. Tips("添加完成,刷新后会正确显示");
  375. }
  376. }
  377. }, Interval);
  378. }
  379.  
  380. //帖子内初始化
  381. function InitPosts() {
  382. let StartTime = (new Date()).getTime();
  383. let Posts = document.querySelectorAll(".l_post:not([data-index]):not(.JXNProcessed)");
  384. let Number = Posts.length;
  385. if (Number > 0) {
  386. let BlockLevelUserValue = GetConfig("BlockLevelUser", 2),
  387. EnableContentFilter = GetConfig("ContentFilter", false);
  388. let ContentResult;
  389. for (let i = 0; i < Number; i++) {
  390. let Post = Posts[i];
  391. //按等级屏蔽用户
  392. if (BlockLevelUserValue > 18) {
  393. Post.remove();
  394. continue;
  395. }
  396. let UserBlock = Post.querySelector(".p_author");
  397. let DisplayName = UserBlock.querySelector(".p_author_name").textContent;
  398. let UserId = JSON.parse(Post.querySelector(".d_name").getAttribute("data-field")).user_id;
  399. if (BlockLevelUserValue > 1 && parseInt(UserBlock.querySelector(".d_badge_lv").textContent) < BlockLevelUserValue) {
  400. console.log(`${DisplayName}(${UserId})的楼层被屏蔽因为等级低于${BlockLevelUserValue}`);
  401. Post.remove();
  402. continue;
  403. }
  404. if (BlockUserIsExist(UserId)) {
  405. console.log(`${DisplayName}(${UserId})的楼层被屏蔽因为在用户屏蔽列表内`);
  406. Post.remove();
  407. } else {
  408. let Content = Post.querySelector(".d_post_content").textContent;
  409. if (EnableContentFilter)
  410. Content = ContentFilter(Content);
  411. //检测内容关键词
  412. if (Content.length > 0 && (ContentResult = CheckKeywordContent(Content)) !== false) {
  413. console.log(`${DisplayName}(${UserId})的楼层被屏蔽因为内容触发关键词[${ContentResult}]`);
  414. Post.remove();
  415. continue;
  416. }
  417. //初始化用户面板
  418. InitUserPanel(UserId, UserBlock);
  419. //添加已处理标记
  420. Post.classList.add("JXNProcessed");
  421. }
  422. }
  423. console.log("屏蔽用时:" + ((new Date()).getTime() - StartTime) + "毫秒");
  424. }
  425. }
  426.  
  427. //通过地址初始化相应功能
  428. function InitFunctionByURL() {
  429. let Function = PageType === PAGE_TYPE_LIST ? InitPostList : InitPosts;
  430. //初始执行
  431. Function();
  432. //定期执行
  433. setInterval(() => {
  434. Function();
  435. }, Interval * 1000);
  436. }
  437.  
  438. //初始化操作界面
  439. function InitUI() {
  440. //脚本菜单
  441. //屏蔽置顶直播
  442. GM_registerMenuCommand((GetConfig("BlockTopLive", false) === true ? "✅" : "❎") + "屏蔽置顶直播", () => {
  443. SetConfig("BlockTopLive", GetConfig("BlockTopLive", false) !== true);
  444. });
  445. //屏蔽纯字母数字标题
  446. GM_registerMenuCommand((GetConfig("BlockAlphaNumberTitle", false) === true ? "✅" : "❎") + "屏蔽纯字母数字标题", () => {
  447. SetConfig("BlockAlphaNumberTitle", GetConfig("BlockAlphaNumberTitle", false) !== true);
  448. });
  449. //关闭会员红贴
  450. GM_registerMenuCommand((GetConfig("BanMemberPost", true) === true ? "✅" : "❎") + "关闭会员红贴", () => {
  451. SetConfig("BanMemberPost", GetConfig("BanMemberPost", false) !== true);
  452. });
  453. //内容预过滤
  454. GM_registerMenuCommand((GetConfig("ContentFilter", false) === true ? "✅" : "❎") + "内容预过滤", () => {
  455. SetConfig("ContentFilter", GetConfig("ContentFilter", false) !== true);
  456. });
  457. //导出数据
  458. GM_registerMenuCommand("导出数据", () => {
  459. let ExportJson = document.createElement("a");
  460. ExportJson.download = "贴吧助手.json";
  461. ExportJson.href = URL.createObjectURL(new Blob([JSON.stringify(GetData())]));
  462. ExportJson.click();
  463. });
  464. //页面菜单
  465. //油猴脚本不提供在指定元素后面创建的api
  466. let Holder = document.createElement("div");
  467. Holder.classList.add("JXNHolder");
  468. let PositionElement = document.getElementById("head");
  469. PositionElement.after(Holder);
  470. //有效天数
  471. GM_addElement(Holder, "span", { textContent: "有效天数" });
  472. let Expire = GM_addElement(Holder, "input", {
  473. type: "number",
  474. min: 1,
  475. step: 1,
  476. value: GetExpireDay(), class: "JXNInput"
  477. });
  478. GM_addElement(Holder, "br", {});
  479. if (PageType === PAGE_TYPE_POST) {
  480. //按等级屏蔽用户
  481. GM_addElement(Holder, "span", { textContent: "屏蔽低于此等级用户" });
  482. let BlockLevelUser = GM_addElement(Holder, "input", {
  483. type: "number", value: GetConfig("BlockLevelUser", 2), min: 1, max: 19, step: 1
  484. });
  485. BlockLevelUser.onchange = () => {
  486. SetConfig("BlockLevelUser", this.value);
  487. }
  488. GM_addElement(Holder, "br", {});
  489. }
  490. //关键词
  491. GM_addElement(Holder, "span", { textContent: "关键词" });
  492. let Keyword = GM_addElement(Holder, "input", {
  493. type: "text",
  494. });
  495. GM_addElement(Holder, "br", {});
  496. //匹配类型
  497. GM_addElement(Holder, "span", { textContent: "匹配类型" });
  498. let MatchType = GM_addElement(Holder, "select", { class: "JXNMatchType" });
  499. MatchType.add(new Option("标题", 0));
  500. MatchType.add(new Option("内容", 1));
  501. MatchType.value = GetConfig("MatchType", 0);
  502. //匹配模式
  503. GM_addElement(Holder, "span", { textContent: "匹配模式" });
  504. let MatchMode = GM_addElement(Holder, "select", { class: "JXNMatchMode" });
  505. MatchMode.add(new Option("部分", 0));
  506. MatchMode.add(new Option("全部", 1));
  507. MatchMode.value = GetConfig("MatchMode", 0);
  508. GM_addElement(Holder, "br", {});
  509. let AddKeyword = GM_addElement(Holder, "button", {
  510. textContent: "添加", class: "JXNButton"
  511. });
  512. let RemoveKeyword = GM_addElement(Holder, "button", {
  513. textContent: "删除", class: "JXNButton"
  514. });
  515. //导入选择块
  516. let ImportFile = GM_addElement(Holder, "input", {
  517. type: "file",
  518. hidden: true,
  519. accept: "application/json",
  520. value: false
  521. });
  522. //导入数据
  523. let ImportList = GM_addElement(Holder, "button", {
  524. textContent: "导入数据", class: "JXNButton"
  525. });
  526. //绑定事件
  527. //有效天数
  528. Expire.onchange = () => {
  529. SetExpireDay(Expire.value);
  530. }
  531. //匹配类型
  532. MatchType.onchange = () => {
  533. SetConfig("MatchType", MatchType.value);
  534. }
  535. //匹配模式
  536. MatchMode.onchange = () => {
  537. SetConfig("MatchMode", MatchMode.value);
  538. }
  539. //添加删除关键词
  540. AddKeyword.onclick = () => {
  541. let Value = Keyword.value;
  542. if (Value !== "") {
  543. if (BlockKeywordIsExist(GetNowKeyWordType(), Value)) {
  544. Tips("此关键词已存在");
  545. } else {
  546. AddBlockKeyword(GetNowKeyWordType(), GetNowKeyWordMode(), Value);
  547. Tips("添加成功");
  548. }
  549. }
  550. };
  551. RemoveKeyword.onclick = () => {
  552. let Value = Keyword.value;
  553. if (Value !== "") {
  554. if (BlockKeywordIsExist(GetNowKeyWordType(), Value)) {
  555. RemoveBlockKeyword(GetNowKeyWordType(), Value);
  556. Tips("删除成功");
  557. } else {
  558. Tips("此关键词不存在");
  559. }
  560. }
  561. }
  562. //导入数据
  563. ImportFile.onchange = () => {
  564. if (ImportFile.files.length > 0) {
  565. let JsonList = ImportFile.files[0];
  566. let Reader = new FileReader();
  567. Reader.onload = (Result) => {
  568. try {
  569. SaveData(JSON.parse(Result.target.result));
  570. Tips("导入完成");
  571. } catch (e) {
  572. alert("读取的文件格式不正确");
  573. }
  574. };
  575. Reader.readAsText(JsonList);
  576. }
  577. }
  578. ImportList.onclick = () => {
  579. ImportFile.click();
  580. }
  581. }
  582.  
  583. //清理过期数据
  584. function ClearExpireData() {
  585. //浏览帖子达到一定时间才去执行清理
  586. setTimeout(() => {
  587. if (1 + Math.round(Math.random() * 99) <= ClearExpireDataPercent) {
  588. let NowDate = GetNowTime();
  589. let Data = GetData();
  590. //清理用户
  591. for (let i = 0; i < Data.User.length; i++) {
  592. let Id = Data.User[i];
  593. if (Data.UserTime[Id] < NowDate) {
  594. console.log(`删除过期用户[${Id}]因为它的时间${Data.UserTime[Id]}]小于当前时间`);
  595. RemoveBlockUser(Id);
  596. }
  597. }
  598. //清理标签
  599. let UserTag = Data.UserTag;
  600. for (const UserId in UserTag) {
  601. let Tags = UserTag[UserId];
  602. for (const Tag in Tags) {
  603. if (Tags[Tag] < NowDate) {
  604. console.log(`删除过期用户[${UserId}]的标签[${Tag}]因为它的时间${Tags[Tag]}小于当前时间`);
  605. UserRemoveTag(UserId, Tag);
  606. }
  607. }
  608. }
  609. //清理关键词
  610. let KeyWord = Data.Keyword;
  611. for (const BaseKey in KeyWord) {
  612. let Value = KeyWord[BaseKey];
  613. for (const Key in Value) {
  614. let TheKeyWord = Value[Key];
  615. if (TheKeyWord.Time < NowDate) {
  616. console.log(`删除过期${BaseKey === "Title" ? "标题" : "内容"}关键词[${Key}]因为它的时间[${TheKeyWord.Time}]小于当前时间`);
  617. RemoveBlockKeyword(BaseKey === "Title" ? 0 : 1, Key);
  618. }
  619. }
  620. }
  621. }
  622. }, ClearExpireDataDelay * 1000);
  623. }
  624.  
  625. //显示信息
  626. function DisplayInfo() {
  627. setTimeout(() => {
  628. let Data = GetData();
  629. console.log("完整数据", Data);
  630. console.log("屏蔽数量:关键词-标题(" + Object.keys(Data.Keyword.Title).length + "),关键词-内容(" + Object.keys(Data.Keyword.Content).length + "),用户(" + Data.User.length + ")");
  631. console.log("当前时间:" + GetNowTime());
  632. }, 1000);
  633. }
  634.  
  635. //运行
  636. function Run() {
  637. InitCSS();
  638. InitUI();
  639. ClearExpireData();
  640. InitFunctionByURL();
  641. DisplayInfo();
  642. }
  643.  
  644. Run();

QingJ © 2025

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