Taipower Captcha Unlocker

自動解鎖「台電停電查詢」頁面的驗證碼輸入框,省去先查詢失敗的步驟。

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Taipower Captcha Unlocker
// @namespace    https://greasyfork.org/users/abc0922001
// @version      1.0.0
// @description  自動解鎖「台電停電查詢」頁面的驗證碼輸入框,省去先查詢失敗的步驟。
// @author       abc0922001
// @match        https://service.taipower.com.tw/nds/ndsWeb/ndft112.aspx*
// @icon         https://service.taipower.com.tw/nds/ndsWeb/images/TaipowerLogo.png
// @grant        none
// @license      MIT
// ==/UserScript==

(() => {
    'use strict';

    const custNoInput  = document.getElementById('TextBox_CustNo');
    const captchaInput = document.getElementById('TextBox_Captcha');

    if (!custNoInput || !captchaInput) { return; }

    /** 判斷電號輸入長度滿 11 碼就解鎖驗證碼欄位 */
    const unlock = () => {
        captchaInput.disabled = custNoInput.value.trim().length < 11;
    };

    /* 支援手打、貼上、表單自動填 */
    custNoInput.addEventListener('input', unlock);
    window.addEventListener('load', unlock);
})();