From c8431edea5bc34bcaf701156c4659b9b9161ffd7 Mon Sep 17 00:00:00 2001 From: Patric Gruber Date: Fri, 7 Jun 2024 02:58:14 +0200 Subject: [PATCH 1/3] add sponsorblock url setting --- client/components/Settings.vue | 126 ++++++++++++++++++++++------- client/composables/sponsorBlock.ts | 7 +- client/store/settings.ts | 1 + 3 files changed, 101 insertions(+), 33 deletions(-) diff --git a/client/components/Settings.vue b/client/components/Settings.vue index e87711cc6..7dd0bfa49 100644 --- a/client/components/Settings.vue +++ b/client/components/Settings.vue @@ -6,6 +6,7 @@ import Dropdown from '@/components/filter/Dropdown.vue'; import '@/assets/styles/popup.scss'; import { type SegmentOption, useSettingsStore } from '@/store/settings'; import CheckBox from '~/components/form/CheckBox.vue'; +import BadgeButton from './buttons/BadgeButton.vue'; defineEmits<{ (e: 'close'): void; @@ -17,9 +18,35 @@ const sponsorblockSegmentOptions = reactive([ { label: 'Ask', value: 'ask' }, { label: 'None', value: 'none' } ]); +const defaultSponsorBlockUrl = "https://sponsor.ajay.app/"; +const sponsorBlockUrl = ref(settingsStore.sponsorblockUrl); + +const isSponsorBlockUrlValid = computed(() => { + try { + const url = new URL(sponsorBlockUrl.value); + if (url.protocol != "http:" && url.protocol != "https:") { + return false; + } + return sponsorBlockUrl.value.endsWith("/"); + } catch (e) { + return false; + } +}); const videoQualities = ['144p', '240p', '360p', '720p', '1080p', '1440p', '2160p']; const videoSpeedArray = ['0', '0.25', '0.5', '0.75', '1', '1.25', '1.5', '1.75', '2', '2.25', '2.5', '2.75', '3']; + +function setSponsorBlockUrl() { + if (!isSponsorBlockUrlValid.value) { + return; + } + settingsStore.sponsorblockUrl = sponsorBlockUrl.value; +} + +function resetSponsorBlockUrl() { + settingsStore.sponsorblockUrl = "https://sponsor.ajay.app/"; + sponsorBlockUrl.value = settingsStore.sponsorblockUrl; +}