-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
212 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<template> | ||
<div class="mb-0.5 mt-1 flex items-center py-1 text-black"> | ||
<div>{{ name }}</div> | ||
<input | ||
type="text" | ||
v-model="currValue" | ||
class="ml-4 block flex-1 rounded-md border border-gray-300 bg-white p-1.5 text-sm outline-none invalid:border-red-500 focus:border-gray-500 focus:invalid:border-red-500" | ||
/> | ||
</div> | ||
<DescriptionComp v-if="description?.length" :description="description"></DescriptionComp> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { GM_getValue, GM_setValue } from '$' | ||
import { ref, watch } from 'vue' | ||
import { IStringItem } from '../../types/item' | ||
import { error } from '../../utils/logger' | ||
import DescriptionComp from './DescriptionComp.vue' | ||
const item = defineProps<IStringItem>() | ||
const currValue = ref(GM_getValue(item.id, item.defaultValue)) | ||
watch(currValue, (newValue, oldValue) => { | ||
try { | ||
// 样式生效、失效 | ||
if (oldValue === item.disableValue) { | ||
if (!item.noStyle) { | ||
document.documentElement.setAttribute(item.attrName ?? item.id, '') | ||
} | ||
} | ||
if (newValue === item.disableValue) { | ||
if (!item.noStyle) { | ||
document.documentElement.removeAttribute(item.attrName ?? item.id) | ||
} | ||
} else if (currValue.value !== oldValue) { | ||
console.log(newValue, oldValue) | ||
item | ||
.fn(currValue.value) | ||
?.then() | ||
.catch((err) => { | ||
throw err | ||
}) | ||
} | ||
GM_setValue(item.id, currValue.value) | ||
} catch (err) { | ||
error(`string item ${item.id} error`, err) | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// 字幕颜色 | ||
html[video-page-subtitle-font-color] { | ||
.bpx-player-subtitle-panel-text { | ||
color: var(--video-page-subtitle-font-color) !important; | ||
} | ||
} | ||
|
||
// 字体设定 | ||
html[video-page-subtitle-font-family] { | ||
.bpx-player-subtitle-panel-text { | ||
font-family: var(--video-page-subtitle-font-family) !important; | ||
} | ||
} | ||
|
||
// 描边颜色 | ||
html[video-page-subtitle-text-stroke-color] { | ||
.bpx-player-subtitle-panel-text { | ||
background: unset !important; | ||
background-color: var(--video-page-subtitle-text-stroke-color) !important; | ||
background-clip: text !important; | ||
} | ||
} | ||
|
||
// 描边宽度 | ||
html[video-page-subtitle-text-stroke-width] { | ||
.bpx-player-container:where([data-screen='normal'], [data-screen='wide']) .bpx-player-subtitle-panel-text { | ||
-webkit-text-stroke: calc(0.6 * var(--video-page-subtitle-text-stroke-width)) transparent !important; | ||
-moz-text-stroke: calc(0.6 * var(--video-page-subtitle-text-stroke-width)) transparent !important; | ||
-ms-text-stroke: calc(0.6 * var(--video-page-subtitle-text-stroke-width)) transparent !important; | ||
} | ||
.bpx-player-container:where([data-screen='web'], [data-screen='full']) .bpx-player-subtitle-panel-text { | ||
-webkit-text-stroke: var(--video-page-subtitle-text-stroke-width) transparent !important; | ||
-moz-text-stroke: var(--video-page-subtitle-text-stroke-width) transparent !important; | ||
-ms-text-stroke: var(--video-page-subtitle-text-stroke-width) transparent !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Item } from '../../../../types/item' | ||
|
||
export const videoSubtitleItems: Item[] = [ | ||
{ | ||
type: 'string', | ||
id: 'video-page-subtitle-font-color', | ||
name: '字幕颜色', | ||
description: ['遵循 CSS 的 color 语法,留空为禁用'], | ||
defaultValue: '', | ||
disableValue: '', | ||
fn: (value: string) => { | ||
document.documentElement.style.setProperty('--video-page-subtitle-font-color', value) | ||
}, | ||
}, | ||
{ | ||
type: 'string', | ||
id: 'video-page-subtitle-font-family', | ||
name: '字体设定', | ||
description: ['遵循 CSS 的 font-family 语法,留空为禁用', '请确保本地已安装字体,检查家族名是否正确'], | ||
defaultValue: 'PingFang SC,HarmonyOS_Regular,Helvetica Neue,Microsoft YaHei,sans-serif', | ||
disableValue: '', | ||
fn: (value: string) => { | ||
document.documentElement.style.setProperty('--video-page-subtitle-font-family', value) | ||
}, | ||
}, | ||
{ | ||
type: 'string', | ||
id: 'video-page-subtitle-text-stroke-color', | ||
name: '描边颜色', | ||
description: ['遵循 CSS 的 color 语法,留空为禁用', '会覆盖官方字幕设定'], | ||
defaultValue: '#444', | ||
disableValue: '', | ||
fn: (value: string) => { | ||
document.documentElement.style.setProperty('--video-page-subtitle-text-stroke-color', value) | ||
}, | ||
}, | ||
{ | ||
type: 'number', | ||
id: 'video-page-subtitle-text-stroke-width', | ||
name: '描边宽度 (0为禁用)', | ||
minValue: 0, | ||
maxValue: 10, | ||
defaultValue: 4, | ||
disableValue: 0, | ||
addonText: 'px', | ||
fn: (value: number) => { | ||
document.documentElement.style.setProperty('--video-page-subtitle-text-stroke-width', `${value}px`) | ||
}, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.