初始化脚本
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://core.teacher.vocational.smartedu.cn/p/course/vocational/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=smartedu.cn
// @grant none
命名进行修改
// @name 寒假课程视频点击
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://core.teacher.vocational.smartedu.cn/p/course/vocational/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=smartedu.cn
// @grant none
屏蔽广告的方法
- 获取标签
- 删除元素,this.remove(), this.parentElement.remove();, this.parentNode.remove();
- 隐藏元素,this.parentElement.style.display = 'none'; this.parentElement.setAttribute('style','display:none');
获取元素,常用方法
document.getElementsByClassName() | 返回文档中所有指定类名的元素集合,作为 NodeList 对象。 |
---|---|
document.getElementById() | 返回对拥有指定 id 的第一个对象的引用。 |
document.getElementsByName() | 返回带有指定名称的对象集合。 |
document.getElementsByTagName() | 返回带有指定标签名的对象集合。 |
操作元素
点击click,删除remove,隐藏hide,根据情况使用。
操作试用
在网页开发界面进行测试
看是否可行。如果可行,就往下继续
设置定时器
setInterval(() => {
方法
}, 毫秒数);
设置定时器变量
let tips=setInterval(() => {
$(()=>{
console.log("启动完成");
if ($('.layui-layer').length){
console.log($('.layui-layer').length)
var btn=document.getElementsByClassName('layui-layer-btn0')[0];
if (btn){
btn.click();
clearInterval(tips);
console.log("关闭提示");
}
}
});
}, 3000);
设置定时器取消的设定
clearInterval(tips);
站在巨人的肩膀,去学习
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?