Skip to content

Commit

Permalink
✨ feat: 0.3.34 some new features have been added
Browse files Browse the repository at this point in the history
  • Loading branch information
dlzmoe committed Sep 13, 2024
1 parent ff62299 commit 5d73324
Show file tree
Hide file tree
Showing 9 changed files with 1,272 additions and 759 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
- 修复:频繁触发接口的问题
- 新增:快捷阅读下一个帖子
- 新增:屏蔽视频自动播放
- 新增:禁用选中分享功能
- 优化:修改了部分代码逻辑
923 changes: 545 additions & 378 deletions dist/linuxdo-scripts.user.js

Large diffs are not rendered by default.

923 changes: 545 additions & 378 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.32",
"version": "0.3.33",
"author": "dlzmoe",
"description": "An enhanced script for the linux.do forum",
"type": "module",
Expand Down
17 changes: 16 additions & 1 deletion src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
<MenuEditorJa :sort="19" v-model="settingData.checked19" />
<!-- 开启列表页导航栏浮动 -->
<MenuStickyNav :sort="20" v-model="settingData.checked20" />
<!-- 开启快速打开下一个帖子 -->
<MenuNextPosts :sort="21" v-model="settingData.checked22" />
<!-- 禁用选中文字分享功能 -->
<MenuSelectedShare :sort="22" v-model="settingData.checked23" />
<!-- 禁用视频自动播放 -->
<MenuDisableAutoplay :sort="23" v-model="settingData.checked24" />
</div>
<div class="menu-body-item">
<!-- 自定义论坛 logo -->
Expand Down Expand Up @@ -179,14 +185,17 @@ 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 MenuNextPosts from "./components/BasicSettings/MenuNextPosts.vue";
import MenuSelectedShare from "./components/BasicSettings/MenuSelectedShare.vue";
import MenuDisableAutoplay from "./components/BasicSettings/MenuDisableAutoplay.vue";
// 自定义文字
import MenuOtherCss from "./components/CustomText/MenuOtherCss.vue";
import MenuLogoUrl from "./components/CustomText/MenuLogoUrl.vue";
import MenuCreatereply from "./components/CustomText/MenuCreatereply.vue";
import MenuBlockuserlist from "./components/CustomText/MenuBlockuserlist.vue";
import MenuBlockKeyword from "./components/CustomText/MenuBlockKeyword.vue";
import MenuShieldPosts from "./components/CustomText/MenuShieldPosts.vue";
// 用户标签
import UserTags from "./components/UserTags/UserTags.vue";
Expand Down Expand Up @@ -267,6 +276,9 @@ export default {
MenuShieldPosts,
Themes,
Signature,
MenuNextPosts,
MenuSelectedShare,
MenuDisableAutoplay,
},
data() {
return {
Expand Down Expand Up @@ -319,6 +331,9 @@ export default {
cate: "搞七捻三",
days: "5",
},
checked22: true,
checked23: false,
checked24: true,
usertags: [],
gptdata: {
value1: false,
Expand Down
46 changes: 46 additions & 0 deletions src/components/BasicSettings/MenuDisableAutoplay.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<div class="item">
<div class="tit">{{ sort }}. 禁用视频自动播放</div>
<input
type="checkbox"
:checked="modelValue"
@change="$emit('update:modelValue', $event.target.checked)"
/>
</div>
</template>

<script>
export default {
props: ["modelValue", "sort"],
emits: ["update:modelValue"],
created() {
if (this.modelValue) {
setInterval(() => {
$(".cooked iframe, .cooked video").each(function () {
const $element = $(this);
let src = $element.attr("src");
// 检查 src 是否存在
if (src) {
// 检查是否已有 autoplay=false
if (!src.includes("autoplay=false")) {
// 检查是否已有 autoplay 参数
if (src.includes("autoplay=")) {
// 如果存在,替换为 autoplay=false
src = src.replace(/autoplay=[^&]*/, "autoplay=false");
} else {
// 如果不存在,添加 autoplay=false
const separator = src.includes("?") ? "&" : "?";
src += `${separator}autoplay=false`;
}
// 更新 src 属性
$element.attr("src", src);
}
}
});
}, 1000);
}
},
};
</script>
84 changes: 84 additions & 0 deletions src/components/BasicSettings/MenuNextPosts.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<template>
<div class="item">
<div class="tit">{{ sort }}. 开启快速打开下一个帖子(快捷键:双击 <kbd>→</kbd>)</div>
<input
type="checkbox"
:checked="modelValue"
@change="$emit('update:modelValue', $event.target.checked)"
/>
</div>
</template>

<script>
export default {
props: ["modelValue", "sort"],
emits: ["update:modelValue"],
methods: {
messageToast(message) {
const messageElement = $(`<div class="messageToast-text">${message}</div>`);
$("#messageToast").append(messageElement);
setTimeout(() => {
messageElement.remove();
}, 3000);
},
async init() {
const id = $(".post-stream .topic-post:last-child")
.find("article")
.attr("data-topic-id");
let currentId = parseInt(id) + 1;
const maxAttempts = 10;
const checkPageExists = async (idToCheck) => {
const newUrl = `/t/topic/${idToCheck}`;
try {
const response = await fetch(newUrl);
if (response.ok) {
this.messageToast("正在跳转下一个帖子!");
window.location.href = newUrl;
return true;
} else {
return false;
}
} catch (error) {
console.error("请求出错:", error);
this.messageToast("请求出错,请稍后再试。");
return false;
}
};
for (let attempts = 0; attempts < maxAttempts; attempts++) {
const exists = await checkPageExists(currentId);
if (exists) {
break;
}
currentId++;
}
if (currentId === parseInt(id) + 1 + maxAttempts) {
this.messageToast("已是最新帖子!");
}
},
},
created() {
if (this.modelValue) {
let lastKeyTime = 0; // 上一次按键的时间
const doubleClickTime = 300; // 双击的时间间隔(毫秒)
document.addEventListener("keydown", (event) => {
// 检查是否按下右箭头键
if (event.key === "ArrowRight") {
const currentTime = Date.now();
// 检查时间间隔
if (currentTime - lastKeyTime <= doubleClickTime) {
this.init();
}
// 更新上一次按键的时间
lastKeyTime = currentTime;
}
});
}
},
};
</script>
24 changes: 24 additions & 0 deletions src/components/BasicSettings/MenuSelectedShare.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div class="item">
<div class="tit">{{ sort }}. 禁用选中文字分享功能</div>
<input
type="checkbox"
:checked="modelValue"
@change="$emit('update:modelValue', $event.target.checked)"
/>
</div>
</template>

<script>
export default {
props: ["modelValue", "sort"],
emits: ["update:modelValue"],
created() {
if (this.modelValue) {
$("head").append(`<style>
.quote-button .quote-sharing{display:none!important}
</style>`);
}
},
};
</script>
7 changes: 7 additions & 0 deletions version-log.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.3.33

- 新增:快捷阅读下一个帖子
- 新增:屏蔽视频自动播放
- 新增:禁用选中分享功能
- 优化:修改了部分代码逻辑

## 0.3.32

- 修复:频繁触发接口的问题
Expand Down

0 comments on commit 5d73324

Please sign in to comment.