自定义实现浏览网页小功能

1、隐藏页面中所有图片、视频、音频等多媒体元素

localStorage.setItem('clearMeadiaTiemer', `
if (!localStorage.clearMeadiaTiemer) {
  setInterval(() => {
    var imgs = document.getElementsByTagName('img')
    if (imgs.length > 0) {
      console.info('imgs.length', imgs.length)
      for (var i = 0; i < imgs.length; i++) {
        imgs[i].remove()
      }
    }
    var videos = document.getElementsByTagName('video')
    if (videos.length > 0) {
      console.info('videos.length', videos.length)
      for (var i = 0; i < videos.length; i++) {
        videos[i].remove()
      }
    }
    var iframes = document.getElementsByTagName('iframe')
    if (iframes.length > 0) {
      for (var i = 0; i < iframes.length; i++) {
        var iframeImgs = iframes[i].getElementsByTagName('img')
        if (iframeImgs.length > 0) {
          console.info('iframeImgs.length', iframeImgs.length)
          for (var j = 0; j < iframeImgs.length; j++) {
            iframeImgs[j].remove()
          }
        }
      }
    }
  }, 100)
} else {
  eval(
    setInterval(() => {
      var imgs = document.getElementsByTagName('img')
      if (imgs.length > 0) {
        console.info('imgs.length', imgs.length)
        for (var i = 0; i < imgs.length; i++) {
          imgs[i].remove()
        }
      }
      var videos = document.getElementsByTagName('video')
      if (videos.length > 0) {
        console.info('videos.length', videos.length)
        for (var i = 0; i < videos.length; i++) {
          videos[i].remove()
        }
      }
      var iframes = document.getElementsByTagName('iframe')
      if (iframes.length > 0) {
        for (var i = 0; i < iframes.length; i++) {
          var iframeImgs = iframes[i].getElementsByTagName('img')
          if (iframeImgs.length > 0) {
            console.info('iframeImgs.length', iframeImgs.length)
            for (var j = 0; j < iframeImgs.length; j++) {
              iframeImgs[j].remove()
            }
          }
        }
      }
    }, 100),
  )
}
`)
eval(localStorage.getItem('clearMeadiaTiemer'))


 

 

2、PC端浏览器查看腾讯新闻被遮挡时:

localStorage.setItem('showWholeNewsArticle', `
if (document.getElementById('article_body')) {

   document.getElementById('article_body').style.maxHeight = '99999px'

}
`)
eval(localStorage.getItem('showWholeNewsArticle'))

 

 

3、PC端浏览器查看微信公众号文章提示"请在微信客户端打开链接"时:

localStorage.setItem('formatAndReloadWeixinArticlePage', `
location.href = location.href
.replace(/(^[https://open.weixin.qq.com/connect/oauth2/authorize?appid=])([\\S]+)(\\&redirect_uri=)([\\S]+)([(%26)|\\&]auth_switch([%3D|=]))([\\S]+$)/, '$4')
.replaceAll('%3A', ':')
.replaceAll('%2F', '/')
.replaceAll('%3F', '?')
.replaceAll('%3D', '=')
.replaceAll('%26', '&')
`)
eval(localStorage.getItem('formatAndReloadWeixinArticlePage'))

 

上一篇:HTML5新增的标签、表单中新增的属性、元素、事件及音视频标签的使用


下一篇:js实现多个video,一个播放其他暂停