fix selection bugs
This commit is contained in:
parent
f7773a3f1c
commit
2537532a98
1 changed files with 37 additions and 35 deletions
40
rot.js
40
rot.js
|
@ -117,12 +117,14 @@
|
|||
console.log("Applying main theme");
|
||||
setMusic(null);
|
||||
|
||||
//<meta name="pageMusic" content="/assets/music.ogg">
|
||||
waitUntilSpecial('meta[name="pageMusic"]').then((pageMusic) => {
|
||||
setMusic(pageMusic.content);
|
||||
playMusic();
|
||||
return true;
|
||||
});
|
||||
|
||||
//<a id="pageMusic" href="/assets/music.ogg"></a>
|
||||
waitUntilSpecial("#pageMusic").then((pageMusic) => {
|
||||
setMusic(pageMusic.getAttribute("href"));
|
||||
playMusic();
|
||||
|
@ -134,6 +136,7 @@
|
|||
console.log("Applying user theme");
|
||||
setMusic(null);
|
||||
|
||||
//Configure by post
|
||||
waitUntilSpecial(".pin").then((pinnedPost) => {
|
||||
if (pinnedPost.nextElementSibling
|
||||
.querySelector(".StatusBody")
|
||||
|
@ -143,45 +146,44 @@
|
|||
.search(/profile theming post/ig) == -1)
|
||||
return false;
|
||||
|
||||
let ptp = pinnedPost.nextElementSibling.querySelector(".StatusBody");
|
||||
if (ptp) {
|
||||
//Configured by post
|
||||
let musicContainer = ptp.querySelector(".audio-container")
|
||||
const ptp = pinnedPost.nextElementSibling.querySelector(".StatusBody");
|
||||
if (!ptp)
|
||||
return false;
|
||||
|
||||
const musicContainer = ptp.querySelector(".audio-container")
|
||||
if (musicContainer)
|
||||
setMusic(rand(musicContainer.children).src);
|
||||
else
|
||||
setMusic(null);
|
||||
|
||||
let imageContainer = ptp.querySelector(".image-container")
|
||||
const imageContainer = ptp.querySelector(".image-container")
|
||||
if (imageContainer)
|
||||
setImage(rand(imageContainer.getElementsByTagName("img")).src);
|
||||
else
|
||||
setImage(null);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}, observers);
|
||||
|
||||
return musicContainer || imageContainer;
|
||||
});
|
||||
|
||||
//Configure by fields
|
||||
waitUntilSpecial(".user-profile-field-name").then(() => {
|
||||
let fields = [...document.getElementsByClassName("user-profile-field-name")]
|
||||
if (fields.length != 0) {
|
||||
//Configured by fields
|
||||
let musicFields = fields.filter((x) => x.title.toLowerCase().replace(/\s+/g, '') == "music")
|
||||
const fields = [...document.getElementsByClassName("user-profile-field-name")]
|
||||
if (fields.length == 0)
|
||||
return false;
|
||||
|
||||
const musicFields = fields.filter((x) => x.title.toLowerCase().replace(/\s+/g, '') == "music")
|
||||
if (musicFields.length > 0)
|
||||
setMusic(rand(musicFields).nextElementSibling.title);
|
||||
else
|
||||
setMusic(null);
|
||||
|
||||
let imageFields = fields.filter((x) => x.title.toLowerCase().replace(/\s+/g, '') == "image")
|
||||
const imageFields = fields.filter((x) => x.title.toLowerCase().replace(/\s+/g, '') == "image")
|
||||
if (imageFields.length > 0)
|
||||
setImage(rand(imageFields).nextElementSibling.title);
|
||||
else
|
||||
setImage(null);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return musicFields.length > 0 || imageFields.length > 0;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue