在已经加载的页面中动态显示一段话或者一张图片

JavaScript部分

显示一段话,8秒后消失

javascript 复制代码
 // 创建显示消息的元素
    const messageDiv = document.createElement('div');
    messageDiv.id = 'message';
    messageDiv.textContent = '文件已下载完毕,数字员工正在后台稽核数据 . . .';

    // 在JavaScript中设置元素样式
    messageDiv.style.position = 'fixed';
    messageDiv.style.top = '50%';
    messageDiv.style.left = '50%';
    messageDiv.style.transform = 'translate(-50%, -50%)';
    messageDiv.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
    messageDiv.style.color = 'white';
    messageDiv.style.padding = '20px';
    messageDiv.style.borderRadius = '5px';
    messageDiv.style.zIndex = '99999';
    // 设置字体大小为 24 像素(可根据需要调整)
    messageDiv.style.fontSize = '24px';

    document.body.appendChild(messageDiv);

    // 设置定时器,6秒后移除该元素
    setTimeout(() => {
      document.body.removeChild(messageDiv);
    }, 8000);

显示一张GIF图片

javascript 复制代码
// 1. 创建一个新的 <img> 元素
var img = document.createElement('img');

// 2. 设置图片的 src 属性
img.src = 'https://s1.aigei.com/src/img/gif/fe/fe50b2f296c3445b922fe72d2dd82747.gif?imageMogr2/auto-orient/thumbnail/!282x282r/gravity/Center/crop/282x282/quality/85/%7CimageView2/2/w/282&e=1735488000&token=P7S2Xpzfz11vAkASLTkfHN7Fw-oOZBecqeJaxypL:kYC4vqYuMrQ4wiWB80oExhjlWXc=';

// 可选:设置其他属性,如 alt 文本
img.alt = '描述图片的文字';

// 设置 CSS 样式使其悬浮在页面最中心
img.style.position = 'fixed';
img.style.top = '50%';
img.style.left = '50%';
img.style.transform = 'translate(-50%, -50%)';
img.style.zIndex = '1000'; // 确保图片在最上方

// 3. 找到一个父元素,并将 <img> 添加到其中
// 假设我们要将其添加到 body 中
document.body.appendChild(img);

python拾取页面,并发送JS脚本

相关推荐
databook2 小时前
Manim实现闪光轨迹特效
后端·python·动效
Juchecar3 小时前
解惑:NumPy 中 ndarray.ndim 到底是什么?
python
用户8356290780514 小时前
Python 删除 Excel 工作表中的空白行列
后端·python
Json_4 小时前
使用python-fastApi框架开发一个学校宿舍管理系统-前后端分离项目
后端·python·fastapi
数据智能老司机10 小时前
精通 Python 设计模式——分布式系统模式
python·设计模式·架构
数据智能老司机11 小时前
精通 Python 设计模式——并发与异步模式
python·设计模式·编程语言
数据智能老司机11 小时前
精通 Python 设计模式——测试模式
python·设计模式·架构
数据智能老司机11 小时前
精通 Python 设计模式——性能模式
python·设计模式·架构
c8i12 小时前
drf初步梳理
python·django
每日AI新事件12 小时前
python的异步函数
python