【发布时间】:2014-10-19 11:25:44
【问题描述】:
如何为页面中的每个“a”标签执行此操作。我的目标是将其用于 Google 搜索结果以访问没有 google 重定向的结果(在 href 属性中使用),因为实际链接存储在 data-href 属性中。所以使用 Tampermonkey 和以下脚本不起作用,我不知道为什么:
$('body').append('<input type="button" value="Fix Href Attributes" id="GG">');
$("#GG").css("position", "fixed").css("top", 18).css("left", 770);
$('a').each(function(){
var $currentA = $(this);
var dataHref = $currentA.attr('data-href');
$currentA.attr('href',dataHref);
});
我该怎么做?
【问题讨论】:
-
您能否展示一个操作前后的
<a>元素示例,以显示您想要的结果? -
让 Google 知道您点击了哪个搜索结果有用。此反馈用于不断改进每个人的搜索结果。使用上述脚本意味着您不再为该反馈做出贡献,而只是从其他人提供的反馈中受益,而不是回报。
-
这个有undirect,不用重新发明*。
-
@T.J.Crowder:“复制链接地址”是一项必不可少的功能。在 google 找到一种方法可以在不破坏重定向的情况下进行重定向,我将继续使用 undirect。
-
@georg:所以使用脚本在主要链接旁边放置一个链接,仅在需要时使用。
标签: javascript jquery html google-chrome tampermonkey