主页源代码获取

获取个人主页源代码

当前为 2023-06-26 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         主页源代码获取
// @namespace    https://www.luogu.com.cn/user/486799/
// @description  获取个人主页源代码
// @author       BlackPanda
// @license      MIT
// @version      0.1
// @match        https://www.luogu.com.cn/user/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    async function user_detail(){
        var button = document.createElement('button');
        button.textContent = 'Copy';
        button.classList.add('red-button', 'button-size');
        button.addEventListener('click', async function() {
            var introduction = _feInstance.currentData.user.introduction;
            await navigator.clipboard.writeText(introduction);
            alert('复制成功');
        });
        var tmp = document.getElementsByClassName('card padding-default');
        var pos = tmp[0];
        pos.appendChild(button);
    };
    var style = document.createElement('style');
    style.textContent = `
        .red-button {
            background-color: rgba(0, 0, 0, 0.5);
            position: relative;
            display: inline-block;
            padding: 1px 10px 3px;
            color: #fff;
            border-radius: 6px;
            box-shadow: 0 0 7px #1e90ff;
            cursor: pointer;
        }
        .button-size {
            width: 75px;
            height: 25px;
        }
        `;
    document.head.appendChild(style);
    window.addEventListener('load', user_detail);
})();