修改Google搜索结果页面

发布于 2024-09-30 20:28:48 字数 1184 浏览 2 评论 0原文

我编写了一个greasemonkey脚本,它将执行GM_xmlhttpRequest 到谷歌结果页面的下两页..即如果我当前 第 1 页,那么我的脚本将对第 2 页执行 GM_xmlhttpRequest 操作, 3..

现在我的脚本将从这 3 个页面中提取所有 url 并 将重新排序它们

对于我所做的:

unsafeWindow.addEventListener('load',Reorder,true);

function Reorder()
{
alert("onload fired")
..........
..........
// some code overhere to collect all the urls into an array
// and to reorder the urls in the array

现在我将这些网址注入到我的参考页面中,即我保留一个 引用我应该将这些 url 附加为的节点 childNodes.. 同时我修改了页面编号的链接。 2 和 3(在结果页面的底部),这样现在他们就会指向我这些新动态生成的 页。为此,我修改了这些链接的 onclick 属性, 在当前窗口本身中打开一个新窗口,并将写入 将responseXML对象修改为新创建的窗口。

现在一切都工作得很好 ie url 提取、重新排序、创建新窗口、编写 responseXML 对象..

但问题是,当我单击这些修改后的链接并 我新生成的窗口替换了父窗口,它没有给出“onloadfired”的警报 ...事实上它不会停止加载,即它显示所需的 内容但从未完全加载,因为状态栏不显示 “完成”实际上显示“正在等待clients1.google.com”...

所以有人知道这里到底出了什么问题吗..是因为 到一些在谷歌搜索页面上运行的脚本 与页面内容同步...

基本上对于那些不知道greasemonkey将如何工作的人...我的代码只是删除所有包含url的锚标记并插入具有不同url的类似锚标记...简而言之,问题是我只是创建一个新窗口并执行 document.write(这个新创建的 html 页面)...除了 url 之外,我没有更改任何内容... 所以基本上,脚本以某种方式与页面上存在的 url 同步,或者只要正文包含相同的 DOM 树,脚本中包含的数据是否真的很重要。

请大家知道或有任何想法...请告诉我...

我需要尽快完成这件事..

I have written a greasemonkey script which will do GM_xmlhttpRequest
to the next 2 pages of the google results page.. i.e. if my current
page is 1 then my script will do GM_xmlhttpRequest to page no 2 and
3..

Now my script will extract out all the urls from these 3 pages and
will reorder them

For that I have done:

unsafeWindow.addEventListener('load',Reorder,true);

function Reorder()
{
alert("onload fired")
..........
..........
// some code overhere to collect all the urls into an array
// and to reorder the urls in the array

Now I inject these urls into my reference pages i.e. I keep a
reference to the nodes where I am supposed to append these urls as
childNodes.. and along with that I modify the links to page no. 2 and
3(at the bottom of results page) so that now they'll point to my these newly dynamically generated
pages. For that I modify the onclick attribute of these links that'll
open a new window in the current window itself and will write the
modified responseXML object to the newly created window.

Now everything is working awesome i.e. url
extraction, reordering, creating new window, writing the responseXML
object ..

But the problem is that when my these modified links are clicked and
my newly generated window replaces the parent window it doesn't give the alert of "onload fired"
...infact it doesn't stop loading i.e. it displays the desired
content but is never fully loaded since status bar doesn't shows
"done" in fact it shows "waiting for clients1.google.com"...

So does anyone knows what exactly is going wrong over here.. is it due
to some script running on google search page that is somehow
synchronised with the contents of the page...

Basically for those who do not know how greasemonkey will work.....my code is just removing all the anchor tags that contain url and inserting similar anchor tags with different urls...the question in nutshell is that i am just making a new window and doing document.write(this newly created html page)...and other than the urls I am not changing anything....
so basically are the scripts somehow synchronized with the urls present on the page or does it really matter to the scripts what data is contained within as long as the body contains the same DOM tree.

Please people whatever you know or have idea about it.. please tell me...

i need to finish this thing quickly..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一页 2024-10-07 20:28:48

当您使用 document.write 将内容写入新页面时,您需要使用 document.close() 告诉浏览器您已完成 - 在此之前,浏览器认为还有更多内容,并继续显示加载图标。

When you use document.write to write content into a new page, you need to use document.close() to tell the browser that you're done - until then, the browser thinks there is more content to come and continues to display the loading icon.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文