如何爲頁面中的每個'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