简体   繁体   English

刷新页面的Chrome脚本,如果元素存在则通知我

[英]Chrome script that refreshes page, notifies me if element exists

I'm looking to make a chrome script that refreshes multiple pages every minute or so, and if an element on the page exists, I need it to notify me somehow. 我正在寻找一个chrome脚本,该脚本每分钟左右刷新一次多个页面,如果页面上的某个元素存在,则我需要它以某种方式通知我。

I've heard of the Tampermonkey extension for chrome, but I don't know how to continue from here as I'm new to all this. 我听说过chrome的Tampermonkey扩展,但我不知道如何从这里继续,因为我是这一切的新手。

Thanks. 谢谢。

A simple approach might be to use Selenium with the Chrome webdriver instead of trying to use a in browser script. 一种简单的方法可能是将Selenium与Chrome网络驱动程序一起使用,而不是尝试使用in浏览器脚本。 Its standard library is designed to do exactly what it sounds like you want to do. 它的标准库旨在完全按照您想要的方式运行。

I won't write whole script for you, but here's a list of things you need to google: 我不会为您编写整个脚本,但这是您需要用Google进行搜索的列表:

  • Fetching pages's HTML with AJAX - this will save a lot of bandwidth and CPU. 使用AJAX获取页面的HTML-这样可以节省大量带宽和CPU。 You only need page HTML, not all the images and scripts 您只需要页面HTML,而不是所有图像和脚本
  • Regular expressions - although generally using regular expressions to parse HTML is a BadThing™, for specific case like this it's OK 正则表达式 -尽管通常使用正则表达式来解析HTML是BadThing™,但对于这种特定情况,可以
  • Notifications API - you can send desktop notifications using JavaScript. 通知API-您可以使用JavaScript发送桌面通知。 Google it. 谷歌一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM