【HTML】输入Pixiv ID跳转对应画师主页

Pixiv的应用内部居然没这个功能,不科学,非常基础的功能。

收录进了小工具页面。👉点击使用小工具

<body>
    <h1>Pixiv用户跳转</h1>
    <input id="input-id" type="text" placeholder="请输入数字ID" oninput="validateInput()" />
    <div>
        <button onclick="generateLink()">生成链接</button>
        <button onclick="openLink()">跳转</button>
    </div>
    <div id="output"></div>

    <script>
        function validateInput() {
            const input = document.getElementById('input-id');
            input.value = input.value.replace(/\D/g, ''); // 只保留数字
        }

        function generateLink() {
            const input = document.getElementById('input-id').value.trim();
            const output = document.getElementById('output');
            if (input === '') {
                output.innerHTML = '<p style="color: red;">请输入有效的数字ID!</p>';
                return;
            }
            const link = `https://www.pixiv.net/member.php?id=${input}`;
            output.innerHTML = `<a href="${link}" target="_blank">点击跳转到 Pixiv 用户页面</a>`;
        }

        function openLink() {
            const input = document.getElementById('input-id').value.trim();
            if (input === '') {
                alert('您还没有输入ID~');
                return;
            }
            const link = `https://www.pixiv.net/member.php?id=${input}`;
            window.open(link, '_blank');
        }
    </script>
</body>

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注