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

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

相关推荐
ValhallaCoder1 小时前
hot100-二叉树I
数据结构·python·算法·二叉树
猫头虎2 小时前
如何排查并解决项目启动时报错Error encountered while processing: java.io.IOException: closed 的问题
java·开发语言·jvm·spring boot·python·开源·maven
八零后琐话2 小时前
干货:程序员必备性能分析工具——Arthas火焰图
开发语言·python
青春不朽5123 小时前
Scrapy框架入门指南
python·scrapy
MZ_ZXD0014 小时前
springboot旅游信息管理系统-计算机毕业设计源码21675
java·c++·vue.js·spring boot·python·django·php
全栈老石4 小时前
Python 异步生存手册:给被 JS async/await 宠坏的全栈工程师
后端·python
梨落秋霜5 小时前
Python入门篇【模块/包】
python
阔皮大师6 小时前
INote轻量文本编辑器
java·javascript·python·c#
小法师爱分享6 小时前
StickyNotes,简单便签超实用
java·python