Skip to content

Commit

Permalink
chore: 0.3.27 屏蔽指定天数及分类的帖子
Browse files Browse the repository at this point in the history
  • Loading branch information
dlzmoe committed Sep 6, 2024
1 parent 188f40f commit ddaa8e6
Show file tree
Hide file tree
Showing 10 changed files with 879 additions and 442 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- 优化;适配论坛主题色彩
- 新增;屏蔽指定天数及分类的帖子
580 changes: 364 additions & 216 deletions dist/linuxdo-scripts.user.js

Large diffs are not rendered by default.

580 changes: 364 additions & 216 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.26",
"version": "0.3.27",
"author": "dlzmoe",
"description": "An enhanced script for the linux.do forum",
"type": "module",
Expand Down
15 changes: 12 additions & 3 deletions src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="menu-flex">
<ul class="menu-nav">
<li class="act"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24" class="icon-sm"><path fill="currentColor" fill-rule="evenodd" d="M11.568 3.5a1 1 0 0 0-.863.494l-.811 1.381A3 3 0 0 1 7.33 6.856l-1.596.013a1 1 0 0 0-.858.501l-.44.761a1 1 0 0 0-.003.992l.792 1.4a3 3 0 0 1 0 2.954l-.792 1.4a1 1 0 0 0 .004.992l.439.76a1 1 0 0 0 .858.502l1.596.013a3 3 0 0 1 2.564 1.48l.811 1.382a1 1 0 0 0 .863.494h.87a1 1 0 0 0 .862-.494l.812-1.381a3 3 0 0 1 2.563-1.481l1.596-.013a1 1 0 0 0 .859-.501l.439-.761a1 1 0 0 0 .004-.992l-.793-1.4a3 3 0 0 1 0-2.953l.793-1.401a1 1 0 0 0-.004-.992l-.439-.76a1 1 0 0 0-.859-.502l-1.596-.013a3 3 0 0 1-2.563-1.48L13.3 3.993a1 1 0 0 0-.862-.494zM8.98 2.981A3 3 0 0 1 11.568 1.5h.87a3 3 0 0 1 2.588 1.481l.81 1.382a1 1 0 0 0 .855.494l1.597.013a3 3 0 0 1 2.575 1.502l.44.76a3 3 0 0 1 .011 2.975l-.792 1.4a1 1 0 0 0 0 .985l.792 1.401a3 3 0 0 1-.012 2.974l-.439.761a3 3 0 0 1-2.575 1.503l-1.597.012a1 1 0 0 0-.854.494l-.811 1.382a3 3 0 0 1-2.588 1.481h-.87a3 3 0 0 1-2.588-1.481l-.811-1.382a1 1 0 0 0-.855-.494l-1.596-.012a3 3 0 0 1-2.576-1.503l-.439-.76a3 3 0 0 1-.012-2.975l.793-1.4a1 1 0 0 0 0-.985l-.793-1.4a3 3 0 0 1 .012-2.975l.44-.761A3 3 0 0 1 5.717 4.87l1.596-.013a1 1 0 0 0 .855-.494z" clip-rule="evenodd"></path><path fill="currentColor" fill-rule="evenodd" d="M12.003 10.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3M8.502 12a3.5 3.5 0 1 1 7 .001 3.5 3.5 0 0 1-7-.001" clip-rule="evenodd"></path></svg>通用设置</li>
<li><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24" class="icon-sm"><path fill="currentColor" fill-rule="evenodd" d="M12 4a3 3 0 1 0 0 6 3 3 0 0 0 0-6M7 7a5 5 0 1 1 10 0A5 5 0 0 1 7 7m12.028 8.626c-.342-.061-.834.027-1.346.557a1 1 0 0 1-1.438 0c-.512-.53-1.003-.618-1.345-.557-.36.064-.681.312-.837.702-.257.643-.16 2.334 2.901 4.134 3.062-1.8 3.159-3.49 2.901-4.134a1.11 1.11 0 0 0-.836-.702m2.693-.041c.854 2.134-.456 4.844-4.284 6.904a1 1 0 0 1-.948 0c-3.828-2.06-5.137-4.77-4.284-6.904a3.11 3.11 0 0 1 2.343-1.929c.809-.144 1.655.035 2.415.536.76-.5 1.607-.68 2.415-.536a3.11 3.11 0 0 1 2.343 1.929m-11.795-1.38a1 1 0 0 1-.548 1.303C7.06 16.453 5.5 18.581 5.5 21a1 1 0 1 1-2 0c0-3.322 2.141-6.128 5.122-7.344a1 1 0 0 1 1.304.549" clip-rule="evenodd"></path></svg>自定义文字</li>
<li><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24" class="icon-sm"><path fill="currentColor" fill-rule="evenodd" d="M12 4a3 3 0 1 0 0 6 3 3 0 0 0 0-6M7 7a5 5 0 1 1 10 0A5 5 0 0 1 7 7m12.028 8.626c-.342-.061-.834.027-1.346.557a1 1 0 0 1-1.438 0c-.512-.53-1.003-.618-1.345-.557-.36.064-.681.312-.837.702-.257.643-.16 2.334 2.901 4.134 3.062-1.8 3.159-3.49 2.901-4.134a1.11 1.11 0 0 0-.836-.702m2.693-.041c.854 2.134-.456 4.844-4.284 6.904a1 1 0 0 1-.948 0c-3.828-2.06-5.137-4.77-4.284-6.904a3.11 3.11 0 0 1 2.343-1.929c.809-.144 1.655.035 2.415.536.76-.5 1.607-.68 2.415-.536a3.11 3.11 0 0 1 2.343 1.929m-11.795-1.38a1 1 0 0 1-.548 1.303C7.06 16.453 5.5 18.581 5.5 21a1 1 0 1 1-2 0c0-3.322 2.141-6.128 5.122-7.344a1 1 0 0 1 1.304.549" clip-rule="evenodd"></path></svg>自定义</li>
<li><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24" class="icon-sm"><path fill="currentColor" fill-rule="evenodd" d="M12.4 3.767a1 1 0 0 0-.8 0l-6 2.625a1 1 0 0 0-.6.916V13c0 1.714.616 3.283 1.638 4.5A6.99 6.99 0 0 1 12 15c2.153 0 4.078.972 5.362 2.5A6.97 6.97 0 0 0 19 13V7.308a1 1 0 0 0-.6-.916zm3.47 15.067A4.99 4.99 0 0 0 12 17a4.99 4.99 0 0 0-3.87 1.834A6.97 6.97 0 0 0 12 20c1.43 0 2.762-.43 3.87-1.166m-5.072-16.9a3 3 0 0 1 2.405 0l6 2.626A3 3 0 0 1 21 7.308V13a9 9 0 1 1-18 0V7.308A3 3 0 0 1 4.798 4.56zM12 8.5a1.75 1.75 0 1 0 0 3.5 1.75 1.75 0 0 0 0-3.5m-3.75 1.75a3.75 3.75 0 1 1 7.5 0 3.75 3.75 0 0 1-7.5 0" clip-rule="evenodd"></path></svg>用户标签</li>
<li><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-brand-openai"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35" /><path d="M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946" /><path d="M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348" /><path d="M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45" /><path d="M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946" /><path d="M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42" /></svg>AI 配置</li>
<li><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-refresh"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4" /><path d="M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4" /></svg>数据备份同步</li>
Expand Down Expand Up @@ -80,7 +80,7 @@
<MenuEditorJa :sort="19" v-model="settingData.checked19" />
<!-- 开启列表页导航栏浮动 -->
<MenuStickyNav :sort="20" v-model="settingData.checked20" />

</div>
<div class="menu-body-item">
<!-- 自定义论坛 logo -->
Expand All @@ -91,8 +91,10 @@
<MenuBlockKeyword :sort="3" v-model:value="settingData.blockkeywrod" />
<!-- 屏蔽指定用户 -->
<MenuBlockuserlist :sort="4" v-model:value="settingData.blockList" />
<!-- 屏蔽指定分类的多少天前的帖子 -->
<MenuShieldPosts :sort="5" v-model:value="settingData.checked21" />
<!-- 自定义 CSS -->
<MenuOtherCss :sort="5" v-model:value="settingData.othercss" />
<MenuOtherCss :sort="6" v-model:value="settingData.othercss" />
</div>
<div class="menu-body-item">
<UserTags v-model:value="settingData.usertags" />
Expand Down Expand Up @@ -172,6 +174,7 @@ import MenuShowAI from "./components/BasicSettings/MenuShowAI.vue";
import MenuEditorJa from "./components/BasicSettings/MenuEditorJa.vue";
import MenuCreatedOrder from "./components/BasicSettings/MenuCreatedOrder.vue";
import MenuStickyNav from "./components/BasicSettings/MenuStickyNav.vue";
import MenuShieldPosts from "./components/CustomText/MenuShieldPosts.vue";
// 自定义文字
import MenuOtherCss from "./components/CustomText/MenuOtherCss.vue";
Expand Down Expand Up @@ -238,6 +241,7 @@ export default {
MenuStickyNav,
MenuBlockKeyword,
SyncBackup,
MenuShieldPosts,
},
data() {
return {
Expand Down Expand Up @@ -285,6 +289,11 @@ export default {
checked18: false,
checked19: false,
checked20: true,
checked21: {
value1: false,
cate: "搞七捻三",
days: "5",
},
usertags: [],
gptdata: {
value1: false,
Expand Down
1 change: 1 addition & 0 deletions src/assets/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

input[type="text"] {
width: 100%;
background: var(--d-input-bg-color);
}

input[type="checkbox"] {
Expand Down
6 changes: 3 additions & 3 deletions src/components/BasicSettings/MenuAutoRead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="item">
<div class="tit">
{{ sort }}. 是否显示自动阅读按钮,可调节速度默认 10
<input v-model="value2" placeholder="默认速度 10" />
<input type="text" v-model="value2" placeholder="默认速度 10" />
</div>
<input
type="checkbox"
Expand Down Expand Up @@ -42,8 +42,8 @@ export default {
};
</script>
<style lang="less" scoped>
input {
width: 70px;
input[type="text"] {
width: 100px !important;
outline: none;
height: 24px;
border: 1px solid #b6b6b6;
Expand Down
127 changes: 127 additions & 0 deletions src/components/CustomText/MenuShieldPosts.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<template>
<div class="item" style="border: none">
<div class="tit">
{{ sort }}. 屏蔽指定天数前的帖子
<input type="text" v-model="localChecked.days" placeholder="默认天数 5" />
</div>
<input type="checkbox" v-model="localChecked.value1" @change="handleChange" />
</div>
<div>
<p>针对分类:留空对全部分类生效,多个分类用英文,分隔</p>
<textarea v-model="localChecked.cate" placeholder="搞七捻三"></textarea>
</div>
</template>

<script>
export default {
props: {
value: {
type: Object,
default: {
value1: false,
cate: "搞七捻三",
days: "5",
},
},
sort: {
type: Number,
required: true,
},
},
data() {
return {
localChecked: this.value,
};
},
watch: {
value(newValue) {
this.localChecked = newValue;
},
},
methods: {
handleChange() {
this.$emit("update:value", this.localChecked);
},
// 过滤时间格式
convertToTimestamp(dateStr) {
const cleanedDateStr = dateStr.replace(/\s+/g, ""); // 去掉所有空格
const datePattern = /(\d{4})年(\d{1,2})月(\d{1,2})日(\d{2}):(\d{2})/;
const dateMatch = cleanedDateStr.match(datePattern);
if (dateMatch) {
const year = parseInt(dateMatch[1], 10);
const month = parseInt(dateMatch[2], 10) - 1;
const day = parseInt(dateMatch[3], 10);
const hours = parseInt(dateMatch[4], 10);
const minutes = parseInt(dateMatch[5], 10);
const date = new Date(year, month, day, hours, minutes);
return date.getTime();
}
return null;
},
// 屏蔽指定分类、指定时间
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();
}
}
});
}
});
}
},
},
created() {
if (this.localChecked.value1) {
let pollinglength1 = 0;
setInterval(() => {
if (pollinglength1 != $(".topic-list-body tr").length) {
pollinglength1 = $(".topic-list-body tr").length;
this.GetTimestamp();
}
}, 1000);
}
},
};
</script>
<style lang="less" scoped>
input[type="text"] {
width: 100px !important;
outline: none;
height: 24px;
border: 1px solid #b6b6b6;
border-radius: 4px;
margin-left: 10px;
padding: 0 10px;
box-sizing: border-box;
}
</style>
4 changes: 2 additions & 2 deletions src/components/UserTags/UserTags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
export default {
props: {
value: {
type: String,
default: "",
type: Array,
default: [],
},
},
data() {
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.27

- 新增;屏蔽指定天数及分类的帖子

## 0.3.26

- 优化;适配论坛主题色彩
Expand Down

0 comments on commit ddaa8e6

Please sign in to comment.