天道酬勤,厚德载物,自强不息,求真务实,动脑动手,孜孜以求

StudyDo

天道酬勤,厚德载物,自强不息,求真务实,动脑动手,孜孜以求

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  172 随笔 :: 1 文章 :: 2 评论 :: 13万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

初始化脚本

// @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);
posted on   三木人  阅读(1398)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示