Jinxin Util Button

界面按钮工具类

2024-02-10 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트는 직접 설치하는 용도가 아닙니다. 다른 스크립트에서 메타 지시문 // @require https://update.greatest.deepsurf.us/scripts/460642/1325650/Jinxin%20Util%20Button.js을(를) 사용하여 포함하는 라이브러리입니다.

// ==UserScript==
// @name         Jinxin Util Button
// @namespace    https://gitee.com/jinxin11112/tampermonkey
// @version      0.1.0
// @description  界面按钮工具类
// @author       jinxin
// @icon         <$ICON$>
// @resource     fontAwesome https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css
// @grant        GM_addStyle
// @grant        GM_getResourceText
// @license MIT
// ==/UserScript==

function addDownloadButton(buttonFun) {

    GM_addStyle(GM_getResourceText("fontAwesome"));

    let button = document.createElement('i');
    button.className = 'fa fa-download';
    button.innerHTML = '下载';
    // noinspection JSValidateTypes
    button.style = `
            position: fixed;
            bottom: 20px;
            left: 20px;
            display: flex;
            flex-direction: column;
            align-items: end;
            z-index: 999;
            cursor:pointer;
        `;
    button.addEventListener('click', buttonFun);
    (document.body || document.documentElement).appendChild(button);
}