如何为页面中的每个'a'标记执行此操作。我的目标是使用Google的搜索结果来访问没有谷歌重定向的结果(在href属性中使用),因为实际链接存储在data-href属性中。因此,使用Tampermonkey与下面的脚本没有工作,我don'k知道为什么:使用Javascript替换使用data-href属性的href属性
$('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);
});
我怎样才能做到这一点?
灿你会在操作前后显示你的元素的一个例子,以显示你想要的结果? – 2014-10-19 11:29:27
让Google知道您点击的搜索结果是*有用*。此反馈用于不断改进每个人的搜索结果。使用类似上述的脚本意味着您停止对该反馈作出贡献,并且只从其他人提供的反馈中受益,而不会互动。 – 2014-10-19 11:34:07
这里有[undirect](https://github.com/xwipeoutx/undirect),不需要重新发明轮子。 – georg 2014-10-19 11:35:50