Definition Button for spellbee.org

Click on the words found to go to its definition on Merriam Webster

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Definition Button for spellbee.org
// @author       Minjae Kim
// @version      1.05
// @description  Click on the words found to go to its definition on Merriam Webster
// @match        https://spellbee.org/
// @icon         https://spellbee.org/assets/img/spelling-bee-game.png?v2
// @run-at       document-idle
// @grant        none
// @license      MIT
// @namespace    https://greasyfork.org/en/users/1529082-minjae-kim
// ==/UserScript==

addDefinition();

const enterButton = document.querySelector('#submit_button');
enterButton.addEventListener('click', (event) => {
   addDefinition();
});


window.addEventListener('keydown', (event) => {
    if (event.key === 'Enter') {
        event.preventDefault();
        addDefinition();
        }
});

function addDefinition() {
    'use strict';

    let wordList = document.querySelectorAll('.block-words-select__dropdown-els li');

    wordList.forEach((element) => {
        let word = element.innerText.trim();
        element.style.cursor = 'pointer';
        element.style.backgroundColor = 'rgba(222, 206, 31, 0.4)';
        element.addEventListener('click', () => {
            const url = `https://www.merriam-webster.com/dictionary/${word}`;
            window.open(url, '_blank'); // Opens the definition in a new tab
        });
    });

}