萌典 搜索框 输入 简体 转换 繁体

萌典查词的时候,搜索框,输入简体,转换成繁体,无需再手动转换输入法

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         萌典 搜索框 输入 简体 转换 繁体
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description    萌典查词的时候,搜索框,输入简体,转换成繁体,无需再手动转换输入法
// @author        批小将
// @match        https://www.moedict.tw/*
// @grant         none
// ==/UserScript==

(function() {
    let sswords = "";

    function md_addListener(){
        console.log('mengdian_123');
        if(sswords){
            console.info("mengdian_load success");
            console.log(sswords["一个"]);
            console.log(sswords["一箭双雕"]);
            let input = document.getElementById('query');
            input.addEventListener('input', function(e){
                let jianti = e.target.value;
                if (jianti in sswords){
                    e.target.value = sswords[jianti];
                }
            });
        }else{
            console.error("load conversion data failed");
        }
    }

    async function main(){
        let url = "https://mengdian.xyz/s2t.json";
        let response = await fetch(url);
        //sswords = response.json();  //这里需要一个extra await, fuck.
        sswords = await response.json();
        console.log('mengdian_xxxx');
        md_addListener();
    }

    main();

})();