水印2.js 1.26 KB
// ==UserScript==
// @name        脚本2
// @namespace   Scripts
// @match       *://test2.adsdesk.cn/*
// @grant       none
// @version     1.0
// @author      -
// @require     https://unpkg.com/l-watermark@2.1.1/dist/l-watermark.umd.js
// @description 2023/12/6 13:42:17
// ==/UserScript==

(function () {
    'use strict';
    console.log("begin")

    setInterval(addWatermark, 1000)


    let myWaterMark;

    function addWatermark() {
        if (myWaterMark) {
            myWaterMark.remove()
        }
        myWaterMark = WaterMark.page({
            targe: document.body,
            text: '模拟环境[' + 'xbz' + ']' + getNowTime(),
            color: "rgba(0, 0, 0, 0.1)",
            fontSize: 24
        })
    }

    function getNowTime() {
        const now = new Date();
        let year = now.getFullYear(),
            month = now.getMonth() + 1,
            date = now.getDate(),
            h = now.getHours(),
            m = now.getMinutes(),
            s = now.getSeconds()
        month = month < 10 ? '0' + month : month
        date = date < 10 ? '0' + date : date
        h = h < 10 ? '0' + h : h
        m = m < 10 ? '0' + m : m
        // year + "-" + month + "-" + date + " " +
        return h + ":" + m + ":" + s;
    }

    console.log("end")
})()