Grease/tamper 用于在页面中查找特定 HTML 的猴子脚本并发出警报

Grease/tamper monkey script to look for specific HTML in page and alert

我想要一个 grease/tamper monkey 脚本,当我访问一个页面时,它会在页面上查找以下 HTML,如果存在则发出警报。

<p>
  <script 
    type='text/javascript' 
    src='https://site_im_visiting.com/?a(6 hex characters)=(numbers)'>
  </script>
</p>

此外,我想查看一个数组(大约 4k 个网站),看看该网站是否在数组中。

我自己想出来的,但不是寻找 HTML,而是寻找脚本块 src 的 URL

var scripts = document.getElementsByTagName("script")
var expression = /.*\/\?a[a-f0-9]{6}\=\d+?/gi;
const domains =["something.com","google.com"]
for (var i = 0; i < scripts.length; ++i) {
    var regex = new RegExp(expression)
    var t = scripts[i].src
    if (t.match(regex)) {        
        const url = new URL(t)
        if(domains.includes(url.hostname)){
            console.log(url.hostname)
        }else{
            alert(url.hostname)
        }
    }
}