在带有 Greasemonkey 扩展的 Chrome 中,如何修改 `` 结构以删除 onclick= 属性?
我想修改内部网页以消除某些链接的一些 onclick
行为。
内部网页有一堆链接,例如:
<a href="/slm/detail/ar/3116370" onclick="rallyPorthole.showDetail('/ar/view.sp','3116370','pj/b');return false;">foo de fa fa</a>
How can I do an extension to Chrome so it does the following:
for link in all_links:
if link's href attribute matches '/slm/detail/ar/...':
remove the onclick attribute
I want to modify an internal webpage to strip away some of the onclick
behavior of certain links.
The internal webpage has a bunch of links like:
<a href="/slm/detail/ar/3116370" onclick="rallyPorthole.showDetail('/ar/view.sp','3116370','pj/b');return false;">foo de fa fa</a>
How can I do an extension to Chrome so it does the following:
for link in all_links:
if link's href attribute matches '/slm/detail/ar/...':
remove the onclick attribute
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找到 此脚本,以下代码可以放入以
.user.js
结尾的文件中并安装在 Firefox 或 Chrome 中。After finding this script, the following code can be put in a file ending in
.user.js
and installed in Firefox or Chrome.除了
document.getElementByTagName("a")
,您还可以使用document.links
,您可以阅读有关 此处。因此要修改 Ross Rogers 的代码:
Instead of
document.getElementByTagName("a")
you can also usedocument.links
which you can read about here.So to modify Ross Rogers' code: