Last active
March 12, 2025 16:14
-
-
Save Hans5958/69126992963f37f0ee0bde9760df1262 to your computer and use it in GitHub Desktop.
Fills VocaDB song name from the original version. Licensed under MIT. More info: https://gitlab.com/Hans5958-MWS/vocadb-docs/-/wikis/notes/web-scripts#name-filler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (async () => { | |
| const sameElStr = "div.editor-field > table > tbody" | |
| const valueEl = i => document.querySelector(sameElStr + `> tr:nth-child(${i}) input:nth-child(1)`) | |
| const keyEl = i => document.querySelector(sameElStr + `> tr:nth-child(${i}) > td`) | |
| const choiceEl = i => document.querySelector(`div.editor-field:nth-child(2) > select > option:nth-child(${i})`) | |
| const originalId = document.querySelector("a.btn-nomargin:nth-child(1)").href.split("S/")[1] | |
| const data = sessionStorage.getItem("cache_orig_" + originalId)?.includes('{') ? JSON.parse(sessionStorage.getItem("cache_orig_" + originalId)) : await fetch("//" + location.host + "/api/songs/" + originalId + "/for-edit").then((response) => response.json()) | |
| sessionStorage.setItem("cache_orig_" + originalId, JSON.stringify(data)) | |
| const langs = ['Japanese', 'Romaji', 'English'] | |
| for (let i = 0; i < langs.length; i++) { | |
| const lang = langs[i] | |
| valueEl(i + 1).value = data.names.filter((el) => lang === el.language)[0]?.value || '' | |
| if (data.defaultNameLanguage === lang) { | |
| console.log(keyEl(i + 1)) | |
| keyEl(i + 1).style.fontWeight = '600 !important' | |
| if (choiceEl(i + 2)) choiceEl(i + 2).style.fontWeight = '600' | |
| } | |
| } | |
| // console.log("defaultNameLanguage:", data.defaultNameLanguage) | |
| // console.log("Unspecified:", data.names.filter((el) => "Unspecified" === el.language).map(a => a.value)) | |
| const unspecified = data.names.filter((el) => "Unspecified" === el.language).map(a => a.value) | |
| const aliasesLabelEl = document.querySelector('div.editor-field:nth-child(4) > span:nth-child(2)') | |
| if (!aliasesLabelEl.querySelector('br')) { | |
| aliasesLabelEl.innerHTML += "<br>" + unspecified.join('<br>') | |
| } | |
| })() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:(async()=>{const e="div.editor-field > table > tbody",t=t=>document.querySelector(e+`> tr:nth-child(${t}) input:nth-child(1)`),n=t=>document.querySelector(e+`> tr:nth-child(${t}) > td`),o=e=>document.querySelector(`div.editor-field:nth-child(2) > select > option:nth-child(${e})`),i=document.querySelector("a.btn-nomargin:nth-child(1)").href.split("S/")[1],l=sessionStorage.getItem("cache_orig_"+i)?.includes("{")?JSON.parse(sessionStorage.getItem("cache_orig_"+i)):await fetch("//"+location.host+"/api/songs/"+i+"/for-edit").then((e=>e.json()));sessionStorage.setItem("cache_orig_"+i,JSON.stringify(l));const c=["Japanese","Romaji","English"];for(let e=0;e<c.length;e++){const i=c[e];t(e+1).value=l.names.filter((e=>i===e.language))[0]?.value||"",l.defaultNameLanguage===i&&(console.log(n(e+1)),n(e+1).style.fontWeight="600 !important",o(e+2)&&(o(e+2).style.fontWeight="600"))}const r=l.names.filter((e=>"Unspecified"===e.language)).map((e=>e.value)),a=document.querySelector("div.editor-field:nth-child(4) > span:nth-child(2)");a.querySelector("br")||(a.innerHTML+="<br>"+r.join("<br>"))})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment