mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-08-20 04:15:37 +00:00
cleaner settings handler, minor fixes
This commit is contained in:
parent
63d2043db6
commit
59820d67e0
4 changed files with 31 additions and 70 deletions
|
|
@ -291,11 +291,11 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="custom-switch mb-10">
|
||||
<input type="checkbox" id="player4">
|
||||
<input type="checkbox" id="player4" checked>
|
||||
<label for="player4">Miniplayer</label>
|
||||
</div>
|
||||
<div class="custom-switch mb-10">
|
||||
<input type="checkbox" id="player5">
|
||||
<input type="checkbox" id="player5" checked>
|
||||
<label for="player5">Seek Previews</label>
|
||||
</div>
|
||||
<div class="custom-switch mb-10">
|
||||
|
|
@ -303,11 +303,11 @@
|
|||
<label for="player6">Autoplay Next Episode</label>
|
||||
</div>
|
||||
<div class="custom-switch mb-10">
|
||||
<input type="checkbox" id="player7">
|
||||
<input type="checkbox" id="player7" checked>
|
||||
<label for="player7">Picture In Picture</label>
|
||||
</div>
|
||||
<div class="custom-switch mb-20">
|
||||
<input type="checkbox" id="player8">
|
||||
<input type="checkbox" id="player8" checked>
|
||||
<label for="player8">Post-Download Processing [Improves UX and performance after a download
|
||||
finishes, initially CPU intensive]</label>
|
||||
</div>
|
||||
|
|
@ -322,16 +322,16 @@
|
|||
</div>
|
||||
<select class="form-control" id="subtitle1">
|
||||
<option value="'Open Sans', sans-serif">Open Sans</option>
|
||||
<option value="Roboto,Arial,Helvetica,sans-serif">Roboto</option>
|
||||
<option value="Roboto,Arial,Helvetica,sans-serif" selected>Roboto</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="custom-switch mb-10">
|
||||
<input type="checkbox" id="subtitle2">
|
||||
<input type="checkbox" id="subtitle2" checked>
|
||||
<label for="subtitle2">Async Rendering [Might cause desync on low end devices but greatly
|
||||
improves performance]</label>
|
||||
</div>
|
||||
<div class="custom-switch mb-20">
|
||||
<input type="checkbox" id="subtitle3">
|
||||
<input type="checkbox" id="subtitle3" checked>
|
||||
<label for="subtitle3">Video Canvas Merging [Displays subtitles in PiP and ChromeCast, requires
|
||||
<a href="chrome://flags/#disable-accelerated-2d-canvas"
|
||||
target="_blank">chrome://flags/#disable-accelerated-2d-canvas</a> set to
|
||||
|
|
@ -347,7 +347,7 @@
|
|||
<span class="input-group-text">Quality</span>
|
||||
</div>
|
||||
<select class="form-control" id="torrent1">
|
||||
<option value="1080">1080p</option>
|
||||
<option value="1080" selected>1080p</option>
|
||||
<option value="720">720p</option>
|
||||
<option value="480">480p</option>
|
||||
</select>
|
||||
|
|
@ -357,7 +357,7 @@
|
|||
<span class="input-group-text">Feed</span>
|
||||
</div>
|
||||
<select class="form-control" id="torrent4">
|
||||
<option value="https://subsplease.org/rss/?r=">SubsPlease</option>
|
||||
<option value="https://subsplease.org/rss/?r=" selected>SubsPlease</option>
|
||||
<option value="https://miru.kirdow.com/request/?url=https://www.erai-raws.info/rss-">
|
||||
Erai-raws</option>
|
||||
</select>
|
||||
|
|
@ -368,7 +368,7 @@
|
|||
played]</label>
|
||||
</div>
|
||||
<div class="custom-switch mb-10">
|
||||
<input type="checkbox" id="torrent3">
|
||||
<input type="checkbox" id="torrent3" checked>
|
||||
<label for="torrent3">Trusted Only [Less results but higher quality and more seeders]</label>
|
||||
</div>
|
||||
<div class="custom-switch mb-20">
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ const nameParseRegex = {
|
|||
"https://miru.kirdow.com/request/?url=https://www.erai-raws.info/rss-": /(\[.*\]\ ?)?(.+?(?=\ \–\ \d))?(\ \–\ )?(\d+)?/i,
|
||||
fallback: /((?:\[[^\]]*\])*)?\s*((?:[^\d\[\.](?!S\d))*)?\s*((?:S\d+[^\w\[]*E?)?[\d\-]*)\s*(.*)?/i
|
||||
}
|
||||
let store = JSON.parse(localStorage.getItem("store")),
|
||||
let store = JSON.parse(localStorage.getItem("store")) || {},
|
||||
lastResult
|
||||
|
||||
async function hsRss() {
|
||||
|
|
|
|||
|
|
@ -49,9 +49,7 @@ function resetVideo() {
|
|||
|
||||
dl.removeAttribute("href")
|
||||
video = document.createElement("video")
|
||||
if (settings.player7 && 'pictureInPictureEnabled' in document) {
|
||||
video.setAttribute("autoPictureInPicture", "")
|
||||
} else {
|
||||
if (!settings.player7 || !'pictureInPictureEnabled' in document) {
|
||||
video.setAttribute("disablePictureInPicture", "")
|
||||
bpip.setAttribute("disabled", "")
|
||||
}
|
||||
|
|
@ -271,7 +269,7 @@ function btnmute() {
|
|||
|
||||
function updateVolume(a) {
|
||||
let level
|
||||
if (a == null) {
|
||||
if (!a) {
|
||||
level = volume.value;
|
||||
} else {
|
||||
level = a;
|
||||
|
|
@ -489,8 +487,8 @@ if ('mediaSession' in navigator) {
|
|||
}
|
||||
|
||||
//AL entry auto add
|
||||
function checkCompletion(){
|
||||
if(settings.other2 && video.duration - 120 < video.currentTime && !playerData.completed){
|
||||
function checkCompletion() {
|
||||
if (settings.other2 && video.duration - 120 < video.currentTime && !playerData.completed) {
|
||||
playerData.completed = true
|
||||
alEntry()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,58 +1,20 @@
|
|||
const settingsElements = {
|
||||
player1: player1,
|
||||
player2: player2,
|
||||
player3: player3,
|
||||
player4: player4,
|
||||
player5: player5,
|
||||
player6: player6,
|
||||
player7: player7,
|
||||
player8: player8,
|
||||
subtitle1: subtitle1,
|
||||
subtitle2: subtitle2,
|
||||
subtitle3: subtitle3,
|
||||
torrent1: torrent1,
|
||||
torrent2: torrent2,
|
||||
torrent3: torrent3,
|
||||
torrent4: torrent4,
|
||||
torrent5: torrent5,
|
||||
other1: other1,
|
||||
other2: other2
|
||||
}
|
||||
let settings
|
||||
const settingsElements = [
|
||||
player1, player2, player3, player4, player5, player6, player7, player8, subtitle1, subtitle2, subtitle3, torrent1, torrent2, torrent3, torrent4, torrent5, other1, other2
|
||||
]
|
||||
let settings = {}
|
||||
function restoreDefaults() {
|
||||
localStorage.clear();
|
||||
settings = {
|
||||
player1: "100",
|
||||
player2: "4",
|
||||
player3: "3",
|
||||
player4: "2",
|
||||
player5: true,
|
||||
player6: false,
|
||||
player7: true,
|
||||
player8: true,
|
||||
subtitle1: "'Open Sans', sans-serif",
|
||||
subtitle2: true,
|
||||
subtitle3: true,
|
||||
torrent1: "1080",
|
||||
torrent2: false,
|
||||
torrent3: true,
|
||||
torrent4: "https://subsplease.org/rss/?r=",
|
||||
torrent5: false,
|
||||
other1: 100,
|
||||
other2: true
|
||||
}
|
||||
localStorage.setItem("settings", JSON.stringify(settings))
|
||||
renderSettings()
|
||||
localStorage.removeItem("settings");
|
||||
location.reload()
|
||||
}
|
||||
let applyTimeout
|
||||
function applySettings() {
|
||||
clearTimeout(applyTimeout)
|
||||
applyTimeout = setTimeout(() => {
|
||||
Object.entries(settingsElements).forEach(setting => {
|
||||
if (settingsElements[setting[0]].type == "checkbox") {
|
||||
settings[setting[0]] = settingsElements[setting[0]].checked
|
||||
settingsElements.forEach(element => {
|
||||
if (element.type == "checkbox") {
|
||||
settings[element.id] = element.checked
|
||||
} else {
|
||||
settings[setting[0]] = settingsElements[setting[0]].value
|
||||
settings[element.id] = element.value
|
||||
}
|
||||
})
|
||||
localStorage.setItem("settings", JSON.stringify(settings))
|
||||
|
|
@ -61,10 +23,10 @@ function applySettings() {
|
|||
|
||||
function renderSettings() {
|
||||
Object.entries(settings).forEach(setting => {
|
||||
if (settingsElements[setting[0]].type == "checkbox") {
|
||||
settingsElements[setting[0]].checked = setting[1]
|
||||
if (settingsElements.filter(e => e.id == setting[0])[0].type == "checkbox") {
|
||||
settingsElements.filter(e => e.id == setting[0])[0].checked = setting[1]
|
||||
} else {
|
||||
settingsElements[setting[0]].value = setting[1]
|
||||
settingsElements.filter(e => e.id == setting[0])[0].value = setting[1]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -79,9 +41,10 @@ function registerProtocol() {
|
|||
}
|
||||
|
||||
if (!localStorage.getItem("settings")) {
|
||||
restoreDefaults()
|
||||
applySettings()
|
||||
} else {
|
||||
settings = JSON.parse(localStorage.getItem("settings"))
|
||||
}
|
||||
settings = JSON.parse(localStorage.getItem("settings"))
|
||||
renderSettings()
|
||||
setRes.addEventListener("click", restoreDefaults)
|
||||
settingsTab.addEventListener("click", applySettings)
|
||||
|
|
|
|||
Loading…
Reference in a new issue