我目前正在创建Chrome扩展程序, 并希望获得页面上以“https://google.com”开头的任何网址。
感谢。
答案 0 :(得分:1)
以下内容在文档中创建以“https://google.com”
开头的网址列表var checkRE = new RegExp('^https://google.com');
var list = []
for (var i = 0; i < document.links.length; i++) {
if(checkRE.test(document.links[i].href)) {
list.push(document.links[i].href)
}
}
console.log(list);