0

使用 crossrider,是否可以在 dom 中获取链接对象并更改链接的标题。我正在创建一个插件来检测恶意站点并在链接前面添加 [Malicious]。

我可能可以通过解析字符串来做到这一点,但如果 DOM 支持它,它会让我的生活变得更轻松。

4

1 回答 1

4

Crossrider 扩展支持 jQuery ($) 对象,因此您可以使用它从 extension.js 文件中获取链接,如下所示:

appAPI.ready(function ($) {
    // Where <linkSel> is the selector for retrieving the link or links you require
    $(<linkSel>).text(); // retrieves the text for the specified <linkSel> object

    // OR the following to prefix the link's text with '[Malicious] '
    $(<linkSel>).text('[Malicious] ' + $(<linkSel>).text());
});
于 2012-12-30T09:06:58.893 回答