Skip to content

Commit

Permalink
YouTubeの代替えドメイン (#4728)
Browse files Browse the repository at this point in the history
* wip

* preview from alts

* a

* merge
  • Loading branch information
mei23 authored Oct 22, 2023
1 parent 652a5e1 commit 1f7f7c3
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 36 deletions.
1 change: 1 addition & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ common:
cheep: "Cheep"
useOrthographicCamera: "Use Orthographic Camera"
nitter: "Alternate domains for Twitter"
altYoutube: "Alternate domains for YouTube"
search: "Search"
delete: "Delete"
loading: "Loading"
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ common:
cheep: "最低"
useOrthographicCamera: "平行投影カメラを使用"
nitter: "Twitterの代替ドメイン"
altYoutube: "YouTubeの代替ドメイン"

search: "検索"
delete: "削除"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"stringz": "2.1.0",
"stylus": "0.59.0",
"stylus-loader": "7.1.3",
"summaly": "mei23/summaly#3.8.3",
"summaly": "mei23/summaly#3.9.0",
"suncalc": "1.9.0",
"systeminformation": "5.21.7",
"syuilo-password-strength": "0.0.1",
Expand Down
98 changes: 64 additions & 34 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/client/app/common/views/components/settings/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@
<header>{{ $t('@._settings.nitter') }}</header>
<ui-input v-model="nitter" :debounce="true">
</ui-input>
<header>{{ $t('@._settings.altYoutube') }}</header>
<ui-input v-model="altYoutube" :debounce="true">
</ui-input>
</section>

<section>
Expand Down Expand Up @@ -595,6 +598,14 @@ export default Vue.extend({
}
},
altYoutube: {
get() { return this.$store.state.device.altYoutube; },
set(value: string) {
this.$store.commit('device/set', { key: 'altYoutube', value: value.trim() });
this.$notify(this.$t('@._settings.saved'));
}
},
roomUseOrthographicCamera: {
get() { return this.$store.state.device.roomUseOrthographicCamera; },
set(value) { this.$store.commit('device/set', { key: 'roomUseOrthographicCamera', value }); }
Expand Down
10 changes: 9 additions & 1 deletion src/client/app/common/views/components/url-preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default Vue.extend({
},
created() {
const requestUrl = new URL(this.url);
let requestUrl = new URL(this.url);
if (this.isBlokedUrl(requestUrl)) {
return;
Expand All @@ -135,6 +135,14 @@ export default Vue.extend({
}
}
// Alt YouTube
if (this.$store.state.device.altYoutube) {
if (requestUrl.hostname === 'www.youtube.com' || requestUrl.hostname === 'm.youtube.com' || requestUrl.hostname === 'youtu.be') {
const youtubePath = `${requestUrl.pathname}${requestUrl.search}`;
requestUrl = new URL(`https://${this.$store.state.device.altYoutube}${youtubePath}`);
}
}
if (requestUrl.hostname === 'music.youtube.com' && requestUrl.pathname.match('^/(?:watch|channel)')) {
requestUrl.hostname = 'www.youtube.com';
}
Expand Down
1 change: 1 addition & 0 deletions src/client/app/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const defaultDeviceSettings = Object.assign({
appType: 'auto',
emojiSkinTone: null,
nitter: '',
altYoutube: '',
}, mods.defaultDeviceSettings || {});

export default (os: MiOS) => new Vuex.Store({
Expand Down

0 comments on commit 1f7f7c3

Please sign in to comment.