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

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脚本

相关推荐
xcLeigh1 天前
Python入门:Python3 requests模块全面学习教程
开发语言·python·学习·模块·python3·requests
xcLeigh1 天前
Python入门:Python3 statistics模块全面学习教程
开发语言·python·学习·模块·python3·statistics
YongCheng_Liang1 天前
从零开始学 Python:自动化 / 运维开发实战(核心库 + 3 大实战场景)
python·自动化·运维开发
鸽芷咕1 天前
为什么越来越多开发者转向 CANN 仓库中的 Python 自动化方案?
python·microsoft·自动化·cann
秋邱1 天前
用 Python 写出 C++ 的性能?用CANN中PyPTO 算子开发硬核上手指南
开发语言·c++·python
wazmlp0018873691 天前
python第三次作业
开发语言·python
深蓝电商API1 天前
住宅代理与数据中心代理在爬虫中的选择
爬虫·python
历程里程碑1 天前
普通数组----合并区间
java·数据结构·python·算法·leetcode·职场和发展·tornado
weixin_395448911 天前
mult_yolov5_post_copy.c_cursor_0205
c语言·python·yolo
执风挽^1 天前
Python基础编程题2
开发语言·python·算法·visual studio code