0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

TamperMonkey用 東工大ポータル自動ログイン ソースコード

Posted at

東工大ポータル自動ログインのソース

// ==UserScript==
// @name         Tokyo Tech Matrix Autofill
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Auto-fill matrix codes on Tokyo Tech Portal
// @author       You
// @match        https://portal.nap.gsic.titech.ac.jp/GetAccess/Login?Template=idg_key*
// @match        https://portal.nap.gsic.titech.ac.jp/GetAccess/ResourceList
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    //あなたのマトリクスコード表をここに入力してください(例: A1: 'X')
    console.log("made by y.k");
    const matrixValues = {
        'A1': 'value1', 'A2': 'value2', 'A3': 'value3', 'A4': 'value4', 'A5': 'value5', 'A6': 'value6', 'A7': 'value7',
        'B1': 'value8', 'B2': 'value9', 'B3': 'value10', 'B4': 'value11', 'B5': 'value12', 'B6': 'value13', 'B7': 'value14',
        'C1': 'value15', 'C2': 'value16', 'C3': 'value17', 'C4': 'value18', 'C5': 'value19', 'C6': 'value20', 'C7': 'value21',
        'D1': 'value22', 'D2': 'value23', 'D3': 'value24', 'D4': 'value25', 'D5': 'value26', 'D6': 'value27', 'D7': 'value28',
        'E1': 'value29', 'E2': 'value30', 'E3': 'value31', 'E4': 'value32', 'E5': 'value33', 'E6': 'value34', 'E7': 'value35',
        'F1': 'value36', 'F2': 'value37', 'F3': 'value38', 'F4': 'value39', 'F5': 'value40', 'F6': 'value41', 'F7': 'value42',
        'G1': 'value43', 'G2': 'value44', 'G3': 'value45', 'G4': 'value46', 'G5': 'value47', 'G6': 'value48', 'G7': 'value49',
        'H1': 'value50', 'H2': 'value51', 'H3': 'value52', 'H4': 'value53', 'H5': 'value54', 'H6': 'value55', 'H7': 'value56',
        'I1': 'value57', 'I2': 'value58', 'I3': 'value59', 'I4': 'value60', 'I5': 'value61', 'I6': 'value62', 'I7': 'value63',
        'J1': 'value64', 'J2': 'value65', 'J3': 'value66', 'J4': 'value67', 'J5': 'value68', 'J6': 'value69', 'J7': 'value70'
    };

    const thElements = document.querySelectorAll('form th');
    const positions = [];
    thElements.forEach(th => {
        const match = th.textContent.match(/\[([A-J]),\s*(\d)\]/);
        if (match) {
            positions.push(match[1] + match[2]);
        }
    });

    positions.forEach((pos, index) => {
        const value = matrixValues[pos.toUpperCase()];
        if (value) {
            const input = document.querySelector(`input[name="message${index + 3}"]`);
            if (input) {
                input.value = value;
            }
        }
    });

    function showImageFor8Seconds(imageUrl) {
        const img = document.createElement('img');
        img.src = imageUrl;
        img.style.position = 'fixed';
        img.style.top = '50%';
        img.style.left = '50%';
        img.style.transform = 'translate(-50%, -50%)';
        img.style.zIndex = '9999';
        img.style.maxWidth = '80%';
        img.style.maxHeight = '80%';
        img.id = 'titech-auth-image';

        document.body.appendChild(img);

        setTimeout(() => {
            img.remove();
        }, 8000);
    }
    if (window.location.href.includes('https://portal.nap.gsic.titech.ac.jp/GetAccess/ResourceList')) {
        showImageFor8Seconds('https://imgur.com/a/a9f5LwT');
    }
    const okButton = document.querySelector('input[type="submit"][value="    OK    "]');
    if (okButton) {
        okButton.click();
    }
})();

このままコピペしてマトリクスの部分を書き換えればよいです。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?