AO3: just my languages

Reduce language options to your preferences

< 腳本AO3: just my languages的回應

評論:正評 - 腳本一切正常

§
發表於:2025-06-14

hi. I noticed a couple of bugs on the New Work page :)

I have this config for testing:

    const dropdownLanguages = ['en', 'de', 'es', 'fr', 'qmd']
    const boldedLanguages = ['en']
    const languagesForMultilingualSearch = ['en', 'de']

    const modifyFilterDropdown = false
    const autofillSearch = 2
    const defaultLanguage = 'es'

    // new work / new imported work / edit work
    const modifyEditorDropdown = true
    const defaultWritingLanguage = 'en' // OPTIONAL: add a language to autofill on new works

first, modifyEditorDropdown gets ignored. the if in line #84 uses the wrong config variable:

if (modifyFilterDropdown) {reduceDropdownLangs(); boldDropdownLangs()}

instead of

if (modifyEditorDropdown) {reduceDropdownLangs(); boldDropdownLangs()}

so in my config the New Work page should have a filtered dropdown, but doesn't.


second, defaultWritingLanguage also is ignored. although the function call is

if (pageURL.includes('/works/new')) {autofillBlankDropdown(defaultWritingLanguage)}

the function itself has a typo. the [lang=""] selector uses the defaultLanguage config, instead of the function parameter defaultLang:

    // Autofill the dropdown if it is empty and the user selected a default language
    function autofillBlankDropdown(defaultLang) {
        if (!defaultLang || dropdown.val()) {return}
        dropdown.children(`[lang="${defaultLanguage}"]`).attr('selected','selected')
    }

therefore it ends up always setting Spanish instead of English in my config.

§
發表於:2025-06-26

Many thanks for the detailed write-up! Sorry it took me a while to get back to you, the heat's been horrendous and doesn't lend itself to debugging. There were a couple of extra bugs complicating matters: the "new" page actually has a second, hidden language dropdown for "inspired by" / "parent" works, which the code couldn't handle, and I also managed to break the CSS for that one page, so nothing was being hidden.

All bugs are now fixed (I hope) and the page should work as expected. Note that I renamed the config variables for clarity, so you'll need to paste in your saved variables for each one.

§
發表於:2025-07-05

awesome, thank you!! <3 especially filtering down the language list to a few entries makes my life so much easier.

§
發表於:2025-07-06

:D

Made a new script by the way, take a look: https://greasyfork.org/en/scripts/541375-ao3-prioritise-my-faves

發表回覆

登入以回覆