Greasy Fork

Greasy Fork is available in English.

Drawaria Word Helper Fixed by YouTubeDrawaria

A script that shows a list of possible words for the current target word and allows the user to easily input them into the chat. for Word guessing game Fixed by YouTubeDrawaria

当前为 2025-01-11 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Drawaria Word Helper Fixed by YouTubeDrawaria
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  A script that shows a list of possible words for the current target word and allows the user to easily input them into the chat. for Word guessing game Fixed by YouTubeDrawaria
// @match        https://*.drawaria.online/*
// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js
// @author       Vholran And YouTubeDrawaria
// @icon         https://www.google.com/s2/favicons?domain=drawaria.online
// @grant        none
// @license MIT
// ==/UserScript==

(($, undefined) => {
    $(() => {
        let wordCheatPanel = () => {
            const $sendButton = $('#chatattop-sendbutton');
            const $inputChat = $('#chatbox_textinput');
            const $targetWord = $('#targetword_tip');
            const $rightBar = $('#rightbar');
            const $hintsBox = $('<span id="hintsBox">');
            let lang = $('#langselector').val();
            let wordList;

            $('<div id="hintsPanel" style="display:none; background: #eeeeee; overflow-wrap: anywhere; border: 4px solid #eeeeee; border-radius: 2px; overflow-y: scroll; height: 100%; width:100%; margin: 8px 0 0 0; color: #3675ce;">')
                .insertAfter($rightBar.children().eq(3))
                .append($hintsBox);

            $("body").on('click', '.hintClick', event => {
                $inputChat.val(event.target.innerHTML);
                $sendButton.click();
            });

            const assist = () => {
                if (!wordList) {
                    return;
                }

                $hintsBox.empty();
                let wordRegex = $targetWord.text().replace(/_/g, '[^ \\-"]');
                wordRegex = `"${wordRegex}"`;
                wordRegex = new RegExp(wordRegex, 'g');
                let hints = wordList.match(wordRegex);

                if (!hints) {
                    $hintsBox.append('<span style="color:red; font-weight:bold">Sorry, no word found!</span>');
                } else {
                    $hintsBox.append('<span style="color:green; font-weight:bold">Click any word to send it: </span><br>');
                    hints = hints.map(hint => hint.slice(1, -1));
                    let newHints = hints.filter(hint => !$inputChat.val() || hint.toLowerCase().search($inputChat.val().toLowerCase()) === -1);
                    hints = hints.filter(hint => !newHints.includes(hint));
                    let html = [...hints.map(hint => `<a style="color:#007CFF; background:#C6FE71; user-select:none" href="javascript:void(0);" class="hintClick">${hint}</a>`),
                                ...newHints.map(hint => `<a style="background:none; user-select:none" href="javascript:void(0);" class="hintClick">${hint}</a>`)].join(', ');
                    $hintsBox.append(html);
                }
            };

            $inputChat.on('input', assist);

            const targetWord = $targetWord[0];
            const hintsPanel = $('#hintsPanel');

            const initialize = async () => {
                try {
                    wordList = await fetch(`https://api.npoint.io/0fc9dd19c4867f584b74/${lang}`).then(response => response.text());
                    wordList = wordList.slice(1, -1);
                } catch (e) {
                    await new Promise((resolve) => setTimeout(resolve, 300));
                    return initialize();
                }
            };
            initialize();

            const wordTipObserver = new MutationObserver((mutations) => {
                mutations.forEach((mutation) => {
                    if (targetWord.style.display === 'none') {
                        hintsPanel.hide();
                    } else {
                        hintsPanel.show();
                        assist();
                    }
                });
            });
            wordTipObserver.observe(targetWord, { attributes: true, attributeFilter: ['style'] });

            const refreshWordObserver = new MutationObserver((mutations) => {
                if (mutations[0].target.disabled) {
                    $('#wordchooser-refreshlist').prop("disabled", false);
                }
            });
            refreshWordObserver.observe($('#wordchooser-refreshlist')[0], { attributes: true });
        };

        const roomKeywords = /\слов|Palabras|Word/;
        const infotextObserver = new MutationObserver((mutations) => {
            mutations.forEach((mutation) => {
                if (roomKeywords.test(mutation.target.textContent)) {
                    wordCheatPanel();
                    infotextObserver.disconnect();
                }
            });
        });

        const infotextElement = $('#infotext')[0];
        if (infotextElement) {
            infotextObserver.observe(infotextElement, { childList: true, subtree: true });
        }
    });
})(window.jQuery.noConflict(true));