Skip to content

Commit 890aba2

Browse files
committed
feat: 新增标签屏蔽功能(从原来的关键词屏蔽功能中分离)
1 parent ed942a2 commit 890aba2

8 files changed

Lines changed: 123 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
- style: 修复简约模式下扩散光影错位问题
1+
- style: 修复简约模式下扩散光影错位问题
2+
- feat: 新增标签屏蔽功能(从原来的关键词屏蔽功能中分离)
3+
- fix: 修复部分新标签页打开的 Bug

entrypoints/App.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,14 @@
171171
<MenuCreatereply :sort="3" v-model:value="settingData.QuickReply" />
172172
<!-- 关键词屏蔽功能 -->
173173
<MenuBlockKeyword :sort="4" v-model:value="settingData.blockkeywrod" />
174+
<!-- 标签屏蔽功能 -->
175+
<MenuBlockTags :sort="6" v-model:value="settingData.blocktags" />
176+
<!-- 屏蔽用户功能 -->
174177
<MenuBlockuserlist :sort="5" v-model:value="settingData.blockList" />
175178
<!-- 屏蔽指定分类的多少天前的帖子 -->
176-
<MenuShieldPosts :sort="6" v-model:value="settingData.checked21" />
179+
<MenuShieldPosts :sort="7" v-model:value="settingData.checked21" />
177180
<!-- 自定义 CSS -->
178-
<MenuOtherCss :sort="7" v-model:value="settingData.othercss" />
181+
<MenuOtherCss :sort="8" v-model:value="settingData.othercss" />
179182
</div>
180183
<div class="menu-body-item" v-show="activeIndex == 2">
181184
<!-- 是否开启用户标签 -->
@@ -270,6 +273,7 @@ import MenuCreatereply from "./components/CustomText/MenuCreatereply.vue";
270273
import MenuBlockuserlist from "./components/CustomText/MenuBlockuserlist.vue";
271274
import MenuBlockKeyword from "./components/CustomText/MenuBlockKeyword.vue";
272275
import MenuShieldPosts from "./components/CustomText/MenuShieldPosts.vue";
276+
import MenuBlockTags from "./components/CustomText/MenuBlockTags.vue";
273277
274278
// 用户标签
275279
import UserTags from "./components/UserTags/UserTags.vue";
@@ -380,6 +384,7 @@ export default {
380384
MenuExportArticle,
381385
MenuTopicOwnerBadge,
382386
MenuAlwaysFirstPost,
387+
MenuBlockTags,
383388
},
384389
data() {
385390
return {
@@ -411,6 +416,7 @@ export default {
411416
QuickReply: "",
412417
blockList: "",
413418
blockkeywrod: "",
419+
blocktags: "",
414420
checked10: false,
415421
othercss: "",
416422
logourl: "",

entrypoints/components/BasicSettings/MenuOpenpostblank.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ export default {
1616
function handleLinkClick(e) {
1717
e.preventDefault();
1818
e.stopPropagation(); // 阻止事件冒泡
19+
e.stopImmediatePropagation(); // 阻止事件捕获和后续相同事件的处理
1920
window.open(this.href, '_blank', 'noopener,noreferrer');
2021
}
2122
2223
// 主要功能
2324
function processLinks() {
2425
// 查找所有帖子标题链接,扩展选择器以包含搜索页面的链接
25-
const links = document.querySelectorAll('.link-top-line a.title:not([data-processed]), .search-results a.search-link:not([data-processed]), .search-result-topic a:not([data-processed])');
26+
const links = document.querySelectorAll('.link-top-line a.title:not([data-processed]), .search-results a.search-link:not([data-processed]), .search-result-topic .search-link:not([data-processed])');
2627
2728
links.forEach(link => {
2829
// 标记该链接已处理

entrypoints/components/BasicSettings/MenuSimpleMode.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ section.post-menu-area{position:absolute!important;bottom:-30px;right:0;transiti
3434
.category-boxes .description{display:none!important}
3535
.category-boxes h3{font-size:18px!important;font-weight:400;display:flex;align-items:center;justify-content:center}
3636
.category-boxes h3 .ember-view{margin-right:10px}
37-
.post-avatar:has(img.avatar[src^="/user_avatar/linux.do/neo/"]):after, .post-avatar:has(img.avatar[src^="https://cdn.linux.do/user_avatar/linux.do/neo/"]):after{width:30px!important;height:30px!important}
37+
.post-avatar:has(img.avatar[src^="/user_avatar/linux.do/neo/"]):after,
38+
.post-avatar:has(img.avatar[src^="https://cdn.linux.do/user_avatar/linux.do/neo/"]):after,
39+
.post-avatar:has(a.trigger-user-card[data-user-card=kevin]):after, .post-avatar:has(a.trigger-user-card[data-user-card=delph1s]):after, .post-avatar:has(a.trigger-user-card[data-user-card=King-Huiwen-of-Qin]):after, .post-avatar:has(a.trigger-user-card[data-user-card=NullUser]):after, .post-avatar:has(a.trigger-user-card[data-user-card="DOS.DO"]):after, .post-avatar:has(a.trigger-user-card[data-user-card=Musifei]):after, .post-avatar:has(a.trigger-user-card[data-user-card=SMNET]):after, .post-avatar:has(a.trigger-user-card[data-user-card=syokatu]):after,
3840
div.group-g-merchant>article>div.row>div.topic-avatar>.post-avatar:after{width:30px!important;height:30px!important}
3941
</style>`)
4042
}

entrypoints/components/CustomText/MenuBlockKeyword.vue

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="item">
33
<div class="tit">
4-
{{ sort }}. 关键词屏蔽功能(使用英文,分隔)屏蔽包含关键字的话题标题、标签、回复
4+
{{ sort }}. 关键词屏蔽功能(使用英文,分隔)屏蔽包含关键字的话题标题、回复
55
</div>
66
</div>
77
<textarea v-model="textarea" @input="handleChange"> </textarea>
@@ -55,15 +55,6 @@ export default {
5555
.parents("tr.topic-list-item")
5656
.remove();
5757
58-
// 检查话题标签
59-
$(".topic-list-item .discourse-tags a")
60-
.filter((index, element) => {
61-
const text = $(element).text();
62-
return keywords.some((keyword) => text.includes(keyword));
63-
})
64-
.parents("tr.topic-list-item")
65-
.remove();
66-
6758
// 检查评论回复
6859
$(".topic-body .cooked")
6960
.filter((index, element) => {
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<template>
2+
<div class="item">
3+
<div class="tit">
4+
{{ sort }}. 标签屏蔽功能(使用英文,分隔)屏蔽指定标签
5+
</div>
6+
</div>
7+
<textarea v-model="textarea" @input="handleChange"> </textarea>
8+
</template>
9+
10+
<script>
11+
import $ from "jquery";
12+
export default {
13+
props: {
14+
value: {
15+
type: String,
16+
default: "",
17+
},
18+
sort: {
19+
type: Number,
20+
required: true,
21+
},
22+
},
23+
data() {
24+
return {
25+
textarea: this.value,
26+
};
27+
},
28+
watch: {
29+
value(newValue) {
30+
this.textarea = newValue;
31+
},
32+
},
33+
methods: {
34+
handleChange() {
35+
this.$emit("update:value", this.textarea);
36+
},
37+
init() {
38+
if (!this.textarea) return;
39+
40+
// 将用户输入的关键字分割为数组,并去除空格和空值
41+
const keywords = this.textarea
42+
.split(",")
43+
.map((keyword) => keyword.trim())
44+
.filter(Boolean);
45+
if (keywords.length === 0) return;
46+
47+
// 安全检查 jQuery 的使用,防止元素不可用时出错
48+
try {
49+
// 检查话题标签
50+
$(".topic-list-item .discourse-tags a")
51+
.filter((index, element) => {
52+
const text = $(element).text();
53+
return keywords.some((keyword) => text.includes(keyword));
54+
})
55+
.parents("tr.topic-list-item")
56+
.remove();
57+
} catch (error) {
58+
console.error("init 方法出错:", error);
59+
}
60+
},
61+
},
62+
created() {
63+
if (this.textarea) {
64+
let previousTopicListLength = 0;
65+
let previousPostStreamLength = 0;
66+
67+
this.pollingInterval = setInterval(() => {
68+
try {
69+
const currentTopicListLength = $(".topic-list-body tr").length || 0;
70+
const currentPostStreamLength = $(".post-stream .topic-post").length || 0;
71+
72+
if (previousTopicListLength !== currentTopicListLength) {
73+
previousTopicListLength = currentTopicListLength;
74+
this.init();
75+
}
76+
if (previousPostStreamLength !== currentPostStreamLength) {
77+
previousPostStreamLength = currentPostStreamLength;
78+
this.init();
79+
}
80+
} catch (error) {
81+
console.error("轮询逻辑出错:", error);
82+
}
83+
}, 1000);
84+
}
85+
},
86+
beforeDestroy() {
87+
// 在组件销毁前清除定时器,防止内存泄漏
88+
if (this.pollingInterval) {
89+
clearInterval(this.pollingInterval);
90+
}
91+
},
92+
};
93+
</script>
94+
95+
<style lang="less" scoped>
96+
.item {
97+
border: none !important;
98+
}
99+
</style>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "linuxdo-scripts",
33
"description": "manifest.json description",
44
"private": true,
5-
"version": "1.1.11",
5+
"version": "1.1.12",
66
"type": "module",
77
"scripts": {
88
"dev": "wxt",

version-log.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.1.12
2+
3+
- style: 修复简约模式下扩散光影错位问题
4+
- feat: 新增标签屏蔽功能(从原来的关键词屏蔽功能中分离)
5+
- fix: 修复部分新标签页打开的 Bug
6+
17
## 1.1.11
28

39
- fix: 修复搜索页面链接无法在新标签页打开的问题 #193

0 commit comments

Comments
 (0)