Jquery 交换谷歌搜索结果中的网站标题和链接URL

Jquery 交换谷歌搜索结果中的网站标题和链接URL,jquery,html,greasemonkey,tampermonkey,userscripts,Jquery,Html,Greasemonkey,Tampermonkey,Userscripts,这是谷歌搜索结果页面源代码的一部分。我想将div元素移动到href容器中。在本例中,我想交换第一个div.TbwUpd和最后一个h3.LC20lb。所以,我想要这个: 为此: 我试图在这个用户脚本中这样做,但没有成功 /==UserScript== //@name重新排列Goggle搜索结果:交换标题和URL //@包括https://www.google.com/search* //@version 1 //@grant none //@需要http://ajax.googleapis

这是谷歌搜索结果页面源代码的一部分。我想将div元素移动到href容器中。在本例中,我想交换第一个div.TbwUpd和最后一个h3.LC20lb。所以,我想要这个:


为此:


我试图在这个用户脚本中这样做,但没有成功

/==UserScript==
//@name重新排列Goggle搜索结果:交换标题和URL
//@包括https://www.google.com/search*
//@version 1
//@grant none
//@需要http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
//==/UserScript==
$('.TbwUpd')。附录('.LC20lb');


1-谷歌搜索结果是动态创建的,因此如果是这种情况,则需要大量其他代码来查找动态更改
2-不需要为一个小代码添加700多个函数长的JQuery。与纯JavaScript相比,它的效率要高得多。(注意:JQuery 1和JQuery 2不推荐使用,因为它们有问题,应该避免使用)
3-我猜要查找和更改的项目不止一个,因此fowling代码将查找所有项目

// ==UserScript==
// @name        Rearrange Google Search result :Swap Title and URL
// @include     https://www.google.com/search*
// @version     1
// @grant       none
// ==/UserScript==

document.querySelectorAll('a div.TbwUpd').forEach(item => {
  item.parentNode.appendChild(item.nextElementSibling); // put the <br> at the end
  item.parentNode.appendChild(item);                    // put the <div> at the end
});
/==UserScript==
//@name重新排列谷歌搜索结果:交换标题和URL
//@包括https://www.google.com/search*
//@version 1
//@grant none
//==/UserScript==
document.querySelectorAll('a div.TbwUpd').forEach(item=>{
item.parentNode.appendChild(item.nextElementSibling);//将
放在末尾 item.parentNode.appendChild(item);//将 });
4-如果只有一项,则

// ==UserScript==
// @name        Rearrange Google Search result :Swap Title and URL
// @include     https://www.google.com/search*
// @version     1
// @grant       none
// ==/UserScript==


const div = document.querySelector('a div.TbwUpd');
div.parentNode.appendChild(div.nextElementSibling); // put the <br> at the end
div.parentNode.appendChild(div);                    // put the div at the end
/==UserScript==
//@name重新排列谷歌搜索结果:交换标题和URL
//@包括https://www.google.com/search*
//@version 1
//@grant none
//==/UserScript==
const div=document.querySelector('a div.TbwUpd');
div.parentNode.appendChild(div.nextElementSibling);//将
放在末尾 div.parentNode.appendChild(div);//把div放在末尾
@boolfalse我想这就是问题的目的。应移动所选的
div
!是的,但是线断了。。还有另一个容器。