如何使用greasemonkey检查是否在页面上找到了文本

Ray*_*ayB 5 text greasemonkey

我确实对google和userscripts网站做了一些研究,但没有找到答案.

那么基本上如何检查页面上是否找到特定文本?并且文本没有特殊标签或任何东西.

Bro*_*ams 5

对于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!");
}
Run Code Online (Sandbox Code Playgroud)


对于更集中的搜索,请使用jQuery,contains就像之前的问题一样.