1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-15 23:00:28 +05:30
Piped/src/components/Preferences.vue

170 lines
6.3 KiB
Vue
Raw Normal View History

2020-11-17 10:45:35 +05:30
<template>
2020-11-22 10:04:27 +05:30
<h1 class="uk-text-bold uk-text-center">Preferences</h1>
<hr />
2021-02-25 20:10:40 +05:30
<h2>SponsorBlock</h2>
<p>Uses the API from <a href="https://sponsor.ajay.app/">sponsor.ajay.app</a></p>
2021-02-25 20:10:40 +05:30
<b>Enable Sponsorblock</b>
<br />
<input class="uk-checkbox" v-model="sponsorBlock" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
<b>Skip Sponsors</b>
<br />
<input class="uk-checkbox" v-model="skipSponsor" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
<b>Skip Intermission/Intro Animation</b>
<br />
<input class="uk-checkbox" v-model="skipIntro" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
<b>Skip Endcards/Credits</b>
<br />
<input class="uk-checkbox" v-model="skipOutro" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
<b>Skip Interaction Reminder (Subscribe)</b>
<br />
<input class="uk-checkbox" v-model="skipInteraction" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
<b>Skip Unpaid/Self Promotion</b>
<br />
<input class="uk-checkbox" v-model="skipSelfPromo" @change="onChange($event)" type="checkbox" />
2021-02-25 20:48:59 +05:30
<br />
<b>Skip Music: Non-Music Section</b>
<br />
<input class="uk-checkbox" v-model="skipMusicOffTopic" @change="onChange($event)" type="checkbox" />
<br />
<b>Autoplay Video</b>
<br />
<input class="uk-checkbox" v-model="autoPlayVideo" @change="onChange($event)" type="checkbox" />
2020-11-22 10:04:27 +05:30
<h2>Instances List</h2>
2020-11-17 10:45:35 +05:30
<table class="uk-table">
<thead>
<tr>
<th>Instance Name</th>
<th>Instance Locations</th>
<th>Has CDN?</th>
2020-11-30 12:09:40 +05:30
<th>SSL Score</th>
2020-11-17 10:45:35 +05:30
</tr>
</thead>
<tbody v-bind:key="instance.name" v-for="instance in instances">
<tr>
<td>{{ instance.name }}</td>
<td>{{ instance.locations }}</td>
<td>{{ instance.cdn }}</td>
2020-11-30 12:09:40 +05:30
<td>
<a :href="sslScore(instance.apiurl)" target="_blank">Click Here</a>
2020-11-30 12:09:40 +05:30
</td>
2020-11-17 10:45:35 +05:30
</tr>
</tbody>
</table>
2020-11-22 10:04:27 +05:30
<hr />
<b>Instance Selection:</b>
<select class="uk-select" v-model="selectedInstance" @change="onChange($event)">
<option v-bind:key="instance.name" v-for="instance in instances" v-bind:value="instance.apiurl">
2020-11-17 10:45:35 +05:30
{{ instance.name }}
</option>
</select>
</template>
<script>
export default {
data() {
return {
selectedInstance: null,
2021-02-25 20:10:40 +05:30
instances: [],
2021-02-25 20:48:59 +05:30
sponsorBlock: true,
skipSponsor: true,
skipIntro: false,
skipOutro: false,
skipInteraction: true,
skipSelfPromo: true,
skipMusicOffTopic: true,
autoPlayVideo: true,
2020-11-17 10:45:35 +05:30
};
},
mounted() {
fetch("https://raw.githubusercontent.com/wiki/TeamPiped/Piped-Frontend/Instances.md")
2020-11-17 10:45:35 +05:30
.then(resp => resp.text())
.then(body => {
var skipped = 0;
const lines = body.split("\n");
lines.map(line => {
const split = line.split("|");
if (split.length == 4) {
if (skipped < 2) {
skipped++;
return;
}
this.instances.push({
name: split[0].trim(),
apiurl: split[1].trim(),
locations: split[2].trim(),
cdn: split[3].trim(),
2020-11-17 10:45:35 +05:30
});
}
});
});
2021-02-25 20:10:40 +05:30
if (localStorage) {
this.selectedInstance = localStorage.getItem("instance") || "https://pipedapi.kavin.rocks";
2021-02-25 20:10:40 +05:30
this.sponsorBlock = localStorage.getItem("sponsorblock") || true;
2021-04-21 19:08:50 +05:30
if (localStorage.getItem("selectedSkip") !== null) {
2021-02-25 20:48:59 +05:30
var skipList = localStorage.getItem("selectedSkip").split(",");
this.skipSponsor = this.skipIntro = this.skipOutro = this.skipInteraction = this.skipSelfPromo = this.skipMusicOffTopic = false;
skipList.forEach(skip => {
switch (skip) {
case "sponsor":
this.skipSponsor = true;
break;
case "intro":
this.skipIntro = true;
break;
case "outro":
this.skipOutro = true;
break;
case "interaction":
this.skipInteraction = true;
break;
case "selfpromo":
this.skipSelfPromo = true;
break;
case "music_offtopic":
this.skipMusicOffTopic = true;
break;
default:
console.log("Unknown sponsor type: " + skip);
break;
}
});
}
this.autoPlayVideo =
localStorage.getItem("playerAutoPlay") === null || localStorage.getItem("playerAutoPlay") === "true";
2021-02-25 20:10:40 +05:30
}
2020-11-17 10:45:35 +05:30
},
methods: {
onChange() {
2021-02-25 20:10:40 +05:30
if (localStorage) {
2020-11-17 10:45:35 +05:30
localStorage.setItem("instance", this.selectedInstance);
2021-02-25 20:10:40 +05:30
localStorage.setItem("sponsorblock", this.sponsorBlock);
2021-02-25 20:48:59 +05:30
var sponsorSelected = [];
if (this.skipSponsor) sponsorSelected.push("sponsor");
if (this.skipIntro) sponsorSelected.push("intro");
if (this.skipOutro) sponsorSelected.push("outro");
if (this.skipInteraction) sponsorSelected.push("interaction");
if (this.skipSelfPromo) sponsorSelected.push("selfpromo");
if (this.skipMusicOffTopic) sponsorSelected.push("music_offtopic");
2021-02-25 20:48:59 +05:30
localStorage.setItem("selectedSkip", sponsorSelected);
localStorage.setItem("playerAutoPlay", this.autoPlayVideo);
2021-02-25 20:10:40 +05:30
}
2020-11-30 12:09:40 +05:30
},
sslScore(url) {
return "https://www.ssllabs.com/ssltest/analyze.html?d=" + new URL(url).host + "&latest";
},
},
2020-11-17 10:45:35 +05:30
};
</script>