AMQ Clear Answer

Add a feature to clear text in the answer column with Delete key.

目前為 2022-09-20 提交的版本,檢視 最新版本

// ==UserScript==
// @name            AMQ Clear Answer
// @namespace       https://github.com/SlashNephy
// @version         1.0.0
// @author          SlashNephy
// @description     Add a feature to clear text in the answer column with Delete key.
// @description:ja  Delete キーを押下することで解答欄のテキストをクリアする機能を追加します。
// @homepage
// @homepageURL
// @icon            https://animemusicquiz.com/favicon-32x32.png
// @supportURL      https://github.com/SlashNephy/.github/issues
// @match           https://animemusicquiz.com/*
// @grant           none
// @license         MIT license
// ==/UserScript==

const createInstalledWindow = () => {
    if (!window.setupDocumentDone)
        return
    if ($('#installedModal').length === 0) {
        $('#gameContainer').append($(`
            <div class="modal fade" id="installedModal" tabindex="-1" role="dialog">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">×</span>
                            </button>
                            <h2 class="modal-title">Installed Userscripts</h2>
                        </div>
                        <div class="modal-body" style="overflow-y: auto;max-height: calc(100vh - 150px);">
                            <div id="installedContainer">
                                You have the following scripts installed (click on each of them to learn more)<br>
                                This window can also be opened by going to AMQ settings (the gear icon on bottom right) and clicking "Installed Userscripts"
                                <div id="installedListContainer"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        `))
        $('#mainMenu')
            .prepend($(`
            <div class="button floatingContainer mainMenuButton" id="mpInstalled" data-toggle="modal" data-target="#installedModal">
                <h1>Installed Userscripts</h1>
            </div>
        `))
            .css('margin-top', '20vh')
        $('#optionsContainer > ul').prepend($(`
            <li class="clickAble" data-toggle="modal" data-target="#installedModal">Installed Userscripts</li>
        `))
        addStyle(`
            .descriptionContainer {
                width: 95%;
                margin: auto;
            }
            .descriptionContainer img {
                width: 80%;
                margin: 10px 10%;
            }
        `)
    }
}
const addScriptData = (metadata) => {
    createInstalledWindow()
    $('#installedListContainer').append($('<div></div>')
        .append($('<h4></h4>')
        .html(`<i class="fa fa-caret-right"></i> ${metadata.name !== undefined ? metadata.name : 'Unknown'} by ${metadata.author !== undefined ? metadata.author : 'Unknown'}`)
        .css('font-weight', 'bold')
        .css('cursor', 'pointer')
        .click(function () {
        const selector = $(this).next()
        if (selector.is(':visible')) {
            selector.slideUp()
            $(this).find('.fa-caret-down').addClass('fa-caret-right').removeClass('fa-caret-down')
        }
        else {
            selector.slideDown()
            $(this).find('.fa-caret-right').addClass('fa-caret-down').removeClass('fa-caret-right')
        }
    }))
        .append($('<div></div>')
        .addClass('descriptionContainer')
        .html(metadata.description !== undefined ? metadata.description : 'No description provided')
        .hide()))
}
const addStyle = (css) => {
    const head = document.head
    const style = document.createElement('style')
    head.appendChild(style)
    style.appendChild(document.createTextNode(css))
}

const handleKeydown = (event) => {
    const target = event.target
    if (target === null) {
        return
    }
    if (event.key === 'Delete') {
        target.value = ''
    }
}
for (const input of document.querySelectorAll('input.flatTextInput')) {
    input.addEventListener('keydown', handleKeydown)
}
addScriptData({
    name: 'Clear Answer',
    author: 'SlashNephy &lt;[email protected]&gt;',
    description: 'Add a feature to clear text in the answer column with delete key.',
})

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址