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

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

相关推荐
破茧蝴蝶7 小时前
Python分布式爬虫完整教程
开发语言·python
benchmark_cc7 小时前
量化系统架构设计:为什么应该将数据获取与策略逻辑解耦?
python·数据分析·pandas·量化交易·股票数据·quantdash
凤山老林7 小时前
Spring Boot 启动冲刺:耗时剖析、懒加载策略与事件驱动初始化优化
spring boot·后端·python
小白快快跑哦7 小时前
python-字符串全解(六):正则表达式-逻辑运算或
python·正则表达式·字符串·逻辑运算
Thinker QAQ8 小时前
并发编程(九):BlockingQueue 与 Channel——语言层的原子性、可见性与有序性
java·python·go·并发编程·channel·blockingqueue·message passing
道满科技8 小时前
Function Calling 参数总出错?只修参数就行
linux·windows·python
霸道流氓气质9 小时前
RAG 可观测性与生产监控实战:四层遥测模型、五大仪表盘与 OpenTelemetry 全链路追踪的 Java 生产级实现
java·人工智能·python
ch62311 小时前
《AI 辅助编程实战:从零跑通一个 Excel 报表生成脚本的踩坑与复盘》
人工智能·python
import_random11 小时前
[python]conda和pip(区别和联系2)
python
Aurorar0rua11 小时前
CS50 x 2024 Notes Python - 01
开发语言·python·学习方法