其他分享
首页 > 其他分享> > 自定义实现浏览网页小功能

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

作者:互联网

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'))

 

标签:网页,自定义,videos,浏览,imgs,length,var,document,iframeImgs
来源: https://www.cnblogs.com/shoryee/p/14153649.html