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

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

相关推荐
Eiceblue2 小时前
Python读取PDF:文本、图片与文档属性
数据库·python·pdf
weixin_527550402 小时前
初级程序员入门指南
javascript·python·算法
程序员的世界你不懂2 小时前
Appium+python自动化(十)- 元素定位
python·appium·自动化
CryptoPP3 小时前
使用WebSocket实时获取印度股票数据源(无调用次数限制)实战
后端·python·websocket·网络协议·区块链
树叶@3 小时前
Python数据分析7
开发语言·python
老胖闲聊4 小时前
Python Rio 【图像处理】库简介
开发语言·图像处理·python
码界奇点4 小时前
Python Flask文件处理与异常处理实战指南
开发语言·python·自然语言处理·flask·python3.11
浠寒AI4 小时前
智能体模式篇(上)- 深入 ReAct:LangGraph构建能自主思考与行动的 AI
人工智能·python
行云流水剑5 小时前
【学习记录】如何使用 Python 提取 PDF 文件中的内容
python·学习·pdf
心扬6 小时前
python生成器
开发语言·python