【发布时间】:2021-10-18 19:02:55
【问题描述】:
我收到的 Outlook 收件箱信件代码的一部分:
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
<tbody><tr>
<td height="2" colspan="3" style="line-height:2px;"> </td>
</tr>
<tr>
<td><**a href="https://www.facebook.com/confirmcontact.php?c=31085&z=0&gfid=AQALAirKRBiAw5qf1L4"** target="_blank" rel="noopener noreferrer" data-auth="NotApplicable" style="color:#3B5998;text-decoration:none;" data-linkindex="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
<tbody><tr>
<td style="text-align:center;background-color:#4C649B;display:block;border-collapse:collapse;border-radius:2px;padding:7px 16px 11px 16px;border:1px solid #344C80;">
<a href="https://www.facebook.com/confirmcontact.php?c=31085&z=0&gfid=AQALAirKRBiAw5qf1L4" target="_blank" rel="noopener noreferrer" data-auth="NotApplicable" style="color:#3B5998;display:block;text-decoration:none;" data-linkindex="3">
<center><font size="3"><span style="color:white;font-size:14px;font-family:Helvetica Neue,Helvetica,Lucida Grande,tahoma,verdana,arial,sans-serif;font-weight:bold;vertical-align:middle;white-space:nowrap;line-height:14px;">Подтвердить</span></font></center>
</a></td>
</tr>
</tbody></table>
</a></td>
<td width="100%"></td>
</tr>
<tr>
<td height="32" colspan="3" style="line-height:32px;"> </td>
</tr>
</tbody></table>
</span>
如何找到以https://www.facebook.com/confirmcontact.php 开头的链接并使用苹果脚本/javascript 来点击它。铬。
我尝试过这个,但还不是很多。
tell application "Google Chrome"
activate
tell active tab of window 1
execute javascript "document.querySelector('a[href=www.facebook.com/confirmcontact]').click()"
end tell
end tell
也得到了建议,但出现了错误:Error: ReferenceError: Can't find variable: document
var links=document.getElementsByTagName('a');
for(var i=0; i<links.length;i++){
if(links[i].match('www.facebook.com/confirmcontact')){
links[i].click();
break;//break the loop
}
}
需要你的帮助,同事们。
【问题讨论】:
-
您提供的代码无法编译,您在 facebook 链接周围的引号不应加倍。
-
谢谢。我修好了它。但不起作用。(
标签: javascript google-chrome hyperlink jquery-selectors applescript