如何使用滑脂猴检查是否在页面上找到文字 [英] How to have greasemonkey Check if text if found on page
本文介绍了如何使用滑脂猴检查是否在页面上找到文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我确实在google和用户脚本网站上进行了一些研究,但未找到答案.
因此,基本上我该如何检查页面上是否找到了特定文本? 文本中没有任何特殊标签或其他任何内容.
解决方案
一种简单但快速的方法,用于FF GM:
if (/Text you are looking for/i.test (document.body.innerHTML) )
{
alert ("Found it!");
}
//--- Looking for one of two different texts...
if (/(Text ONE that you are looking for)|(Text TWO that you are looking for)/i.test (document.body.innerHTML) )
{
alert ("Found one!");
}
对于更集中的搜索,请使用 jQuery contains
,如 解决方案
A crude but fast way, for FF GM:
if (/Text you are looking for/i.test (document.body.innerHTML) )
{
alert ("Found it!");
}
//--- Looking for one of two different texts...
if (/(Text ONE that you are looking for)|(Text TWO that you are looking for)/i.test (document.body.innerHTML) )
{
alert ("Found one!");
}
For more focused searches use jQuery contains
as in this previous question.
这篇关于如何使用滑脂猴检查是否在页面上找到文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文