Skip to content

Commit

Permalink
🐛 fix: 修复屏蔽指定天数前的帖子会隐藏收藏夹的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
dlzmoe committed Sep 20, 2024
1 parent d23503f commit 8d26b7c
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 108 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- 优化:调整 UI 样式 [#39](https://github.com/dlzmoe/linuxdo-scripts/pull/39)
- 修复:屏蔽指定天数前的帖子会隐藏收藏夹
74 changes: 38 additions & 36 deletions dist/linuxdo-scripts.user.js

Large diffs are not rendered by default.

74 changes: 38 additions & 36 deletions linuxdo-scripts.user.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linuxdo-scripts",
"version": "0.3.40",
"version": "0.3.41",
"author": "dlzmoe",
"description": "An enhanced script for the linux.do forum",
"type": "module",
Expand Down
74 changes: 40 additions & 34 deletions src/components/CustomText/MenuShieldPosts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,41 +62,47 @@ export default {
},
// 屏蔽指定分类、指定时间
GetTimestamp() {
if (this.localChecked.cate == "") {
$(".topic-list .age").each((index, element) => {
const str = $(element).attr("title");
const match = str.match(/创建日期:([\s\S]*?)最新:/);
if (match && match[1]) {
const creationDate = match[1].trim();
const timestamp = this.convertToTimestamp(creationDate);
const days = Number(this.localChecked.days) * 86400000;
if (Date.now() - timestamp > days) {
$(element).parents("tr.topic-list-item").remove();
}
}
});
} else {
const cateArray = this.localChecked.cate.split(",").map((item) => item.trim());
$(".badge-category__wrapper .badge-category__name").each((index, element) => {
let htmlContent = $(element).html();
htmlContent = htmlContent.replace(/,\s*Lv[1-3]/g, "");
if (cateArray.includes(htmlContent.trim())) {
// console.log($(element).parents("tr.topic-list-item"));
$(element).parents("tr.topic-list-item").find('.age').each((index, element) => {
const str = $(element).attr("title");
const match = str.match(/创建日期:([\s\S]*?)最新:/);
if (match && match[1]) {
const creationDate = match[1].trim();
const timestamp = this.convertToTimestamp(creationDate);
const days = Number(this.localChecked.days) * 86400000;
if (Date.now() - timestamp > days) {
$(element).parents("tr.topic-list-item").remove();
}
if (
!$(".nav-pills > li.nav-item_posted").hasClass("active") &&
!$(".nav-pills > li.nav-item_bookmarks").hasClass("active")
) {
if (this.localChecked.cate == "") {
$(".topic-list .age").each((index, element) => {
const str = $(element).attr("title");
const match = str.match(/创建日期:([\s\S]*?)最新:/);
if (match && match[1]) {
const creationDate = match[1].trim();
const timestamp = this.convertToTimestamp(creationDate);
const days = Number(this.localChecked.days) * 86400000;
if (Date.now() - timestamp > days) {
$(element).parents("tr.topic-list-item").remove();
}
});
}
});
}
});
} else {
const cateArray = this.localChecked.cate.split(",").map((item) => item.trim());
$(".badge-category__wrapper .badge-category__name").each((index, element) => {
let htmlContent = $(element).html();
htmlContent = htmlContent.replace(/,\s*Lv[1-3]/g, "");
if (cateArray.includes(htmlContent.trim())) {
$(element)
.parents("tr.topic-list-item")
.find(".age")
.each((index, element) => {
const str = $(element).attr("title");
const match = str.match(/创建日期:([\s\S]*?)最新:/);
if (match && match[1]) {
const creationDate = match[1].trim();
const timestamp = this.convertToTimestamp(creationDate);
const days = Number(this.localChecked.days) * 86400000;
if (Date.now() - timestamp > days) {
$(element).parents("tr.topic-list-item").remove();
}
}
});
}
});
}
}
},
},
Expand Down
4 changes: 4 additions & 0 deletions version-log.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.41

- 修复:屏蔽指定天数前的帖子会隐藏收藏夹

## 0.3.40

- 优化:调整 UI 样式 [#39](https://github.com/dlzmoe/linuxdo-scripts/pull/39)
Expand Down

0 comments on commit 8d26b7c

Please sign in to comment.